|
GammaLib 2.2.0.dev
|
XML attribute class. More...
#include <GXmlAttribute.hpp>
Public Member Functions | |
| GXmlAttribute (void) | |
| Void constructor. | |
| GXmlAttribute (const GXmlAttribute &attr) | |
| Copy constructor. | |
| GXmlAttribute (const std::string &name, const std::string &value) | |
| Name-Value pair constructor. | |
| virtual | ~GXmlAttribute (void) |
| Destructor. | |
| GXmlAttribute & | operator= (const GXmlAttribute &attr) |
| Assignment operator. | |
| void | clear (void) |
| Clear element attribute. | |
| GXmlAttribute * | clone (void) const |
| Clone element attribute. | |
| std::string | classname (void) const |
| Return class name. | |
| void | write (GUrl &url) const |
| Write attribute into URL. | |
| const std::string & | name (void) const |
| Return attribute name. | |
| const std::string & | value (void) const |
| Return attribute value. | |
| void | name (const std::string &name) |
| Set attribute name. | |
| void | value (const std::string &value) |
| Set attribute value. | |
| std::string | print (const GChatter &chatter=NORMAL) const |
| Print element attribute. | |
Public Member Functions inherited from GBase | |
| virtual | ~GBase (void) |
| Destructor. | |
Protected Member Functions | |
| void | init_members (void) |
| Initialise class members. | |
| void | copy_members (const GXmlAttribute &attr) |
| Copy class members. | |
| void | free_members (void) |
| Delete class members. | |
Protected Attributes | |
| std::string | m_name |
| Attribute name. | |
| std::string | m_value |
| Attribute value. | |
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(), GXmlAttribute(), GXmlAttribute(), and operator=().
|
inline |
Set attribute name.
| [in] | name | Attribute name. |
Definition at line 120 of file GXmlAttribute.hpp.
|
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().
| 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 |
Set attribute value.
| [in] | value | Attribute value. |
Definition at line 144 of file GXmlAttribute.hpp.
|
inline |
Return attribute value.
Definition at line 133 of file GXmlAttribute.hpp.
References m_value.
Referenced by GXmlElement::attribute(), GXmlDocument::encoding(), GXmlDocument::encoding(), GXmlAttribute(), GXmlDocument::init_members(), GXmlDocument::standalone(), GXmlDocument::standalone(), value(), GXmlDocument::version(), GXmlDocument::version(), and write().
| 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(), name(), print(), and write().
|
protected |
Attribute value.
Definition at line 86 of file GXmlAttribute.hpp.
Referenced by copy_members(), init_members(), print(), value(), value(), and write().