ARTS 2.5.11 (git: 6827797f)
|
The ARTS XML tag class. More...
#include <xml_io_base.h>
Public Member Functions | |
XMLTag (const Verbosity &rverbosity) | |
String & | get_name () |
void | check_name (const String &expected_name) |
Check tag name. | |
void | set_name (const String &new_name) |
void | add_attribute (const String &aname, String value) |
void | add_attribute (const String &aname, const Index &value) |
Adds an Index attribute to tag. | |
void | add_attribute (const String &aname, const Numeric &value) |
Adds value of attribute as type Numeric to tag. | |
void | check_attribute (const String &aname, const String &value) |
Checks whether attribute has the expected value. | |
void | get_attribute_value (const String &aname, String &value) |
void | get_attribute_value (const String &aname, Index &value) |
Returns value of attribute as type Index. | |
void | get_attribute_value (const String &aname, Numeric &value) |
Returns value of attribute as type Numeric. | |
void | read_from_stream (istream &is) |
Reads next XML tag. | |
void | write_to_stream (ostream &os) |
Write XML tag. | |
bool | has_attribute (const String &aname) const |
Returns if the attribute exists or not. | |
Protected Attributes | |
String | name |
Array< XMLAttribute > | attribs |
const Verbosity & | verbosity |
The ARTS XML tag class.
Handles reading, writing and constructing of XML tags.
Definition at line 53 of file xml_io_base.h.
|
inline |
Definition at line 55 of file xml_io_base.h.
void XMLTag::add_attribute | ( | const String & | aname, |
const Index & | value | ||
) |
Adds an Index attribute to tag.
aname | Attribute name |
value | Attribute value |
Definition at line 71 of file xml_io_base.cc.
void XMLTag::add_attribute | ( | const String & | aname, |
const Numeric & | value | ||
) |
Adds value of attribute as type Numeric to tag.
[in] | aname | Attribute name |
[in] | value | Set value |
Definition at line 78 of file xml_io_base.cc.
References add_attribute(), and v.
Adds a String attribute to tag
All " are replaced by ” to work in the XML tag
aname | Attribute name |
value | Attribute value |
Definition at line 50 of file xml_io_base.cc.
References attribs, XMLAttribute::name, and XMLAttribute::value.
Referenced by add_attribute(), xml_write_header_to_stream(), and xml_write_to_stream().
Checks whether attribute has the expected value.
If the attribute has another value or is unknown an exception is thrown.
aname | Attribute name |
value | Expected value |
Definition at line 94 of file xml_io_base.cc.
References get_attribute_value(), and xml_parse_error().
Referenced by xml_parse_from_stream(), and xml_read_from_stream().
void XMLTag::check_name | ( | const String & | expected_name | ) |
Check tag name.
Checks whether the name of the tag is correct. Throws runtime error otherwise.
expected_name | Expected tag name |
Definition at line 37 of file xml_io_base.cc.
References name, and xml_parse_error().
Referenced by read_from_stream(), ReadArrayOfARTSCAT(), ReadARTSCAT(), xml_read_footer_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().
void XMLTag::get_attribute_value | ( | const String & | aname, |
Index & | value | ||
) |
Returns value of attribute as type Index.
Searches for the matching attribute and returns it value. If no attribute with the given name exists, return value is set to not found*.
aname | Attribute name |
value | Return value |
Definition at line 152 of file xml_io_base.cc.
References get_attribute_value(), name, and xml_parse_error().
void XMLTag::get_attribute_value | ( | const String & | aname, |
Numeric & | value | ||
) |
Returns value of attribute as type Numeric.
Searches for the matching attribute and returns it value. If no attribute with the given name exists, return value is set to -1e99.
[in] | aname | Attribute name |
[out] | value | Return value |
Definition at line 165 of file xml_io_base.cc.
References get_attribute_value(), name, and xml_parse_error().
Returns value of attribute as String
Searches for the matching attribute and returns it value. If no attribute with the given name exists, return value is set to not found*.
Replaces all ” with " to counter XML-tag problems
aname | Attribute name |
value | Return value |
Definition at line 123 of file xml_io_base.cc.
References attribs.
Referenced by check_attribute(), get_attribute_value(), xml_parse_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().
|
inline |
bool XMLTag::has_attribute | ( | const String & | aname | ) | const |
Returns if the attribute exists or not.
[in] | aname | Attribute name |
Definition at line 108 of file xml_io_base.cc.
References attribs.
Referenced by xml_read_from_stream().
void XMLTag::read_from_stream | ( | istream & | is | ) |
Reads next XML tag.
Reads the name and attributes of the next XML tag from stream.
is | Input stream |
Definition at line 184 of file xml_io_base.cc.
References attribs, check_name(), CREATE_OUT3, XMLAttribute::name, name, my_basic_string< char >::npos, read_from_stream(), XMLAttribute::value, and xml_parse_error().
Referenced by read_from_stream(), ReadArrayOfARTSCAT(), ReadARTSCAT(), xml_read_footer_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().
|
inline |
Definition at line 61 of file xml_io_base.h.
References name.
Referenced by xml_write_footer_to_stream(), xml_write_header_to_stream(), and xml_write_to_stream().
void XMLTag::write_to_stream | ( | ostream & | os | ) |
Write XML tag.
Puts the tag together and writes it to stream.
os | Output stream |
Definition at line 305 of file xml_io_base.cc.
Referenced by xml_data_parse_error(), xml_write_footer_to_stream(), xml_write_header_to_stream(), and xml_write_to_stream().
|
protected |
List of attributes
Definition at line 104 of file xml_io_base.h.
Referenced by add_attribute(), get_attribute_value(), has_attribute(), read_from_stream(), and write_to_stream().
|
protected |
Tag name
Definition at line 103 of file xml_io_base.h.
Referenced by check_name(), ArtsXMLTag::get_attribute_value(), get_attribute_value(), get_name(), read_from_stream(), set_name(), and write_to_stream().
|
protected |
Definition at line 105 of file xml_io_base.h.