GammaLib
2.1.0.dev
|
XML attribute class. More...
#include <GXmlAttribute.hpp>
Public Member Functions | |
GXmlAttribute (void) | |
Void constructor. More... | |
GXmlAttribute (const GXmlAttribute &attr) | |
Copy constructor. More... | |
GXmlAttribute (const std::string &name, const std::string &value) | |
Name-Value pair constructor. More... | |
virtual | ~GXmlAttribute (void) |
Destructor. More... | |
GXmlAttribute & | operator= (const GXmlAttribute &attr) |
Assignment operator. More... | |
void | clear (void) |
Clear element attribute. More... | |
GXmlAttribute * | clone (void) const |
Clone element attribute. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | write (GUrl &url) const |
Write attribute into URL. More... | |
const std::string & | name (void) const |
Return attribute name. More... | |
const std::string & | value (void) const |
Return attribute value. More... | |
void | name (const std::string &name) |
Set attribute name. More... | |
void | value (const std::string &value) |
Set attribute value. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print element attribute. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GXmlAttribute &attr) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
std::string | m_name |
Attribute name. More... | |
std::string | m_value |
Attribute value. More... | |
XML attribute class.
This class implements an attribute of an XML element. An attribute consists of a name-value pair. There can only be one attribute with a given name. Here an example of an XML element with attributes:
<element type="singleton" name="gamma-ray">
The element has two attributes:
type
has a value of "singleton"name
has a value of "gamma-ray"The hyphens are stripped from the attribute value before storing in the name-value pair constructor. Hyphens are added when writing an attribute using the write() method. Allowed hyphens are " and '.
Definition at line 55 of file GXmlAttribute.hpp.
GXmlAttribute::GXmlAttribute | ( | void | ) |
Void constructor.
Definition at line 53 of file GXmlAttribute.cpp.
References init_members().
Referenced by clone().
GXmlAttribute::GXmlAttribute | ( | const GXmlAttribute & | attr | ) |
Copy constructor.
[in] | attr | Element attribute. |
Definition at line 68 of file GXmlAttribute.cpp.
References copy_members(), and init_members().
GXmlAttribute::GXmlAttribute | ( | const std::string & | name, |
const std::string & | value | ||
) |
Name-Value pair constructor.
[in] | name | Attribute name. |
[in] | value | Attribute value. |
Construct attribute form a name
and a value
. Predefined entities (e.g. ") in attribute values are automatically converted into normal characters. The constructor strips any existing " or ' leading and trailing hyphens from the value
string.
Definition at line 92 of file GXmlAttribute.cpp.
References init_members(), name(), value(), and gammalib::xml2str().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 96 of file GXmlAttribute.hpp.
|
virtual |
Clear element attribute.
Resets element attribute to a clean initial state.
Implements GBase.
Definition at line 180 of file GXmlAttribute.cpp.
References free_members(), and init_members().
Referenced by GXmlDocument::init_members().
|
virtual |
Clone element attribute.
Implements GBase.
Definition at line 198 of file GXmlAttribute.cpp.
References GXmlAttribute().
|
protected |
Copy class members.
[in] | attr | Element attribute. |
Definition at line 275 of file GXmlAttribute.cpp.
References m_name, and m_value.
Referenced by GXmlAttribute(), and operator=().
|
protected |
Delete class members.
Definition at line 289 of file GXmlAttribute.cpp.
Referenced by clear(), operator=(), and ~GXmlAttribute().
|
protected |
Initialise class members.
Definition at line 259 of file GXmlAttribute.cpp.
References m_name, and m_value.
Referenced by clear(), GXmlAttribute(), and operator=().
|
inline |
Return attribute name.
Definition at line 108 of file GXmlAttribute.hpp.
References m_name.
Referenced by GXmlElement::attribute(), GXmlAttribute(), GXmlDocument::init_members(), and name().
|
inline |
Set attribute name.
[in] | name | Attribute name. |
Definition at line 120 of file GXmlAttribute.hpp.
GXmlAttribute & GXmlAttribute::operator= | ( | const GXmlAttribute & | attr | ) |
Assignment operator.
[in] | attr | Element attribute. |
Definition at line 148 of file GXmlAttribute.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
Return attribute value.
Definition at line 133 of file GXmlAttribute.hpp.
References m_value.
Referenced by GXmlElement::attribute(), GXmlDocument::encoding(), GXmlAttribute(), GXmlDocument::init_members(), GXmlDocument::standalone(), value(), GXmlDocument::version(), and write().
|
inline |
Set attribute value.
[in] | value | Attribute value. |
Definition at line 144 of file GXmlAttribute.hpp.
void GXmlAttribute::write | ( | GUrl & | url | ) | const |
Write attribute into URL.
[in] | url | Unified Resource Locator. |
Writes the element attribute into the url
. Special characters are automatically transformed into predefined entities (e.g. ").
Definition at line 213 of file GXmlAttribute.cpp.
References m_name, m_value, GUrl::printf(), gammalib::str2xml(), and value().
Referenced by GXmlDocument::write().
|
protected |
Attribute name.
Definition at line 85 of file GXmlAttribute.hpp.
Referenced by copy_members(), init_members(), name(), print(), and write().
|
protected |
Attribute value.
Definition at line 86 of file GXmlAttribute.hpp.
Referenced by copy_members(), init_members(), print(), value(), and write().