libxcks  0.1.0.1
libxcks::XMLParserAttributes Class Referencefinal

Manages elements' attributes. More...

#include <xmlparser.hpp>

Public Member Functions

 XMLParserAttributes ()
 Default constructor. More...
 
 XMLParserAttributes (const XMLParserAttributes &)=delete
 Deleted copy constructor. More...
 
XMLParserAttributesoperator= (const XMLParserAttributes &)=delete
 Deleted copy assignment operator. More...
 
void addAttribute (const std::string &name, const std::string &value)
 Adds an attribute to the end of the list. More...
 
void addAttribute (const XMLParserAttribute &&attribute)
 Adds an attribute to the end of the list. More...
 
void clear ()
 Clears the attribute list for reuse. More...
 
int getIndex (const std::string &name) const
 Looks up an attribute's index by name. More...
 
size_t getCount () const
 Returns the number of attributes in the list. More...
 
bool getName (size_t index, std::string &name) const
 Gets an attribute's name. More...
 
bool getValue (size_t index, std::string &value) const
 Returns an attribute's value by index. More...
 
bool getValue (const std::string &name, std::string &value) const
 Looks up an attribute's value by name. More...
 

Static Public Attributes

static constexpr int Not_Found = -1
 Not found index. More...
 

Protected Attributes

std::vector< XMLParserAttributeattributes
 Attributes. More...
 

Detailed Description

Manages elements' attributes.

Definition at line 83 of file xmlparser.hpp.

Constructor & Destructor Documentation

◆ XMLParserAttributes() [1/2]

libxcks::XMLParserAttributes::XMLParserAttributes ( )
inline

Default constructor.

Definition at line 93 of file xmlparser.hpp.

◆ XMLParserAttributes() [2/2]

libxcks::XMLParserAttributes::XMLParserAttributes ( const XMLParserAttributes )
delete

Deleted copy constructor.

Member Function Documentation

◆ addAttribute() [1/2]

void libxcks::XMLParserAttributes::addAttribute ( const std::string &  name,
const std::string &  value 
)

Adds an attribute to the end of the list.

For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.

Parameters
nameThe attribute's name.
valueThe attribute's value.

Definition at line 168 of file xmlparser.cpp.

◆ addAttribute() [2/2]

void libxcks::XMLParserAttributes::addAttribute ( const XMLParserAttribute &&  attribute)

Adds an attribute to the end of the list.

For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.

Parameters
attributeThe attribute.

Definition at line 183 of file xmlparser.cpp.

◆ clear()

void libxcks::XMLParserAttributes::clear ( )

Clears the attribute list for reuse.

Definition at line 193 of file xmlparser.cpp.

◆ getCount()

size_t libxcks::XMLParserAttributes::getCount ( ) const

Returns the number of attributes in the list.

Returns
The number of attributes in the list.

Definition at line 230 of file xmlparser.cpp.

◆ getIndex()

int libxcks::XMLParserAttributes::getIndex ( const std::string &  name) const

Looks up an attribute's index by name.

Parameters
nameThe name of the attribute.
Returns
The attribute's index, or Not_Found if none matches.

Definition at line 207 of file xmlparser.cpp.

◆ getName()

bool libxcks::XMLParserAttributes::getName ( size_t  index,
std::string &  name 
) const

Gets an attribute's name.

Parameters
indexThe attribute's index (zero-based).
[out]nameThe attribute's name, if the index is out of bounds this parameter's value is not changed.
Returns
true if the index is valid, otherwise.

Definition at line 245 of file xmlparser.cpp.

◆ getValue() [1/2]

bool libxcks::XMLParserAttributes::getValue ( const std::string &  name,
std::string &  value 
) const

Looks up an attribute's value by name.

Parameters
nameThe attribute's name.
[out]valueThe attribute's value, if there is no matching attribute this parameter's value is not changed.
Returns
true if there is a matching attribute, otherwise.

Definition at line 284 of file xmlparser.cpp.

◆ getValue() [2/2]

bool libxcks::XMLParserAttributes::getValue ( size_t  index,
std::string &  value 
) const

Returns an attribute's value by index.

Parameters
indexThe attribute's index (zero-based).
[out]valueThe attribute's value, if the index is out of bounds this parameter's value is not changed.
Returns
true if the index is valid, otherwise.

Definition at line 264 of file xmlparser.cpp.

◆ operator=()

XMLParserAttributes& libxcks::XMLParserAttributes::operator= ( const XMLParserAttributes )
delete

Deleted copy assignment operator.

Member Data Documentation

◆ attributes

std::vector<XMLParserAttribute> libxcks::XMLParserAttributes::attributes
protected

Attributes.

Definition at line 86 of file xmlparser.hpp.

◆ Not_Found

constexpr int libxcks::XMLParserAttributes::Not_Found = -1
staticconstexpr

Not found index.

Definition at line 90 of file xmlparser.hpp.


The documentation for this class was generated from the following files: