Public Types | |
typedef std::vector< SmartPtr< Element > > | children_t |
Public Member Functions | |
void | setText (const std::string &text_str) |
Change the text value between an element's start and end tags. | |
void | appendText (const std::string &text_str) |
Append text to the existing value. | |
const std::string & | getText () const |
Get the text value between an element's start and end tags. | |
const AttributeMap & | getAttributes () const |
A name-value mapping for the attributes. | |
bool | hasAttribute (const std::string &name) const |
void | setAttribute (const std::string &name, const std::string &value) |
entitites in the value string will be replaced on write. | |
void | setAttribute (const std::string &name, size_t value) |
void | setAttribute (const std::string &name, int value) |
void | setAttribute (const std::string &name, double value) |
const std::string & | getAttributeValue (const std::string &name, const std::string &fallback) const |
Preferred way to use the get attribute method. | |
const std::string & | getAttribute (const std::string &name) const |
get the attribute value. | |
const std::string & | attribute (const std::string &name) const |
get the attribute value. | |
bool | getBooleanAttribute (const std::string &name, bool defaultVal) const |
returns a boolean attribute, returning true if the value is "true", "1" or "y..." This method is not called "getAttributeValue" because const char* will be treated as bool rather than converted to a string for the other getAttributeValue method. | |
bool | readValidAttribute (const std::string &attribute, char &value) const |
high level convenience methods for standard types that get a converted value and check existance at same time. | |
bool | readValidAttribute (const std::string &attribute, int &value) const |
bool | readValidAttribute (const std::string &attribute, float &value) const |
bool | readValidAttribute (const std::string &attribute, double &value) const |
bool | readValidAttribute (const std::string &attribute, bool &value) const |
bool | readValidAttribute (const std::string &attribute, std::string &value) const |
const std::string & | getTagName () const |
Element (const std::string &tagName_in) | |
Element () | |
For STL convenience. | |
void | setTagName (const std::string &tagName_in) |
size_t | getChildren (const std::string &tagName, children_t *result) const |
fills in pointers to immediate children that bear this tag name (unlike the DOM method getElementsByTagName this does not recurse and is therefore, pretty fast. | |
const XML::Element & | getFirstChild () const |
returns the first child element. | |
SmartPtr< Element > | getFirstNamedChild (const std::string &name) const |
returns the first child element that matches the tag name given. | |
const children_t & | getChildren () const |
void | addChild (SmartPtr< Element > e) |
void | appendChild (const Element &e) |
typedef std::vector< SmartPtr<Element> > code::XML::Element::children_t |
code::XML::Element::Element | ( | const std::string & | tagName_in | ) | [inline] |
code::XML::Element::Element | ( | ) | [inline] |
For STL convenience.
You have to call setTagName for this to be a valid element.
void code::XML::Element::appendChild | ( | const Element & | e | ) | [inline] |
void code::XML::Element::appendText | ( | const std::string & | text_str | ) | [inline] |
const std::string& code::XML::Element::attribute | ( | const std::string & | name | ) | const [inline] |
get the attribute value.
const std::string& code::XML::Element::getAttribute | ( | const std::string & | name | ) | const |
get the attribute value.
const AttributeMap& code::XML::Element::getAttributes | ( | ) | const [inline] |
A name-value mapping for the attributes.
The value string has no entities.
const std::string& code::XML::Element::getAttributeValue | ( | const std::string & | name, | |
const std::string & | fallback | |||
) | const [inline] |
Preferred way to use the get attribute method.
bool code::XML::Element::getBooleanAttribute | ( | const std::string & | name, | |
bool | defaultVal | |||
) | const |
returns a boolean attribute, returning true if the value is "true", "1" or "y..." This method is not called "getAttributeValue" because const char* will be treated as bool rather than converted to a string for the other getAttributeValue method.
const children_t& code::XML::Element::getChildren | ( | ) | const [inline] |
size_t code::XML::Element::getChildren | ( | const std::string & | tagName, | |
children_t * | result | |||
) | const |
fills in pointers to immediate children that bear this tag name (unlike the DOM method getElementsByTagName this does not recurse and is therefore, pretty fast.
)
const XML::Element& code::XML::Element::getFirstChild | ( | ) | const [inline] |
returns the first child element.
To get the text, use getText
returns the first child element that matches the tag name given.
This replaces Qt's namedNode function
const std::string& code::XML::Element::getTagName | ( | ) | const [inline] |
const std::string& code::XML::Element::getText | ( | ) | const [inline] |
Get the text value between an element's start and end tags.
It is recommended that you avoid mixed content (having both children and text) as all embedded elements will be moved to the front.
Entities have already been replaced.
bool code::XML::Element::hasAttribute | ( | const std::string & | name | ) | const [inline] |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
std::string & | value | |||
) | const |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
bool & | value | |||
) | const |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
double & | value | |||
) | const |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
float & | value | |||
) | const |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
int & | value | |||
) | const |
bool code::XML::Element::readValidAttribute | ( | const std::string & | attribute, | |
char & | value | |||
) | const |
high level convenience methods for standard types that get a converted value and check existance at same time.
void code::XML::Element::setAttribute | ( | const std::string & | name, | |
double | value | |||
) |
void code::XML::Element::setAttribute | ( | const std::string & | name, | |
int | value | |||
) |
void code::XML::Element::setAttribute | ( | const std::string & | name, | |
size_t | value | |||
) |
void code::XML::Element::setAttribute | ( | const std::string & | name, | |
const std::string & | value | |||
) | [inline] |
entitites in the value string will be replaced on write.
void code::XML::Element::setTagName | ( | const std::string & | tagName_in | ) | [inline] |
void code::XML::Element::setText | ( | const std::string & | text_str | ) | [inline] |
Change the text value between an element's start and end tags.
It is recommended that you avoid mixed content (having both children and text) as all embedded elements will be moved to the front.
Entities in text_str will be replaced when writing out.