ARTS  2.2.66
ArtsXMLTag Class Reference

The ARTS XML tag class. More...

#include <xml_io_private.h>

Collaboration diagram for ArtsXMLTag:

Public Member Functions

 ArtsXMLTag (const Verbosity &rverbosity)
 
Stringget_name ()
 
void check_name (const String &expected_name)
 Check tag name. More...
 
void set_name (const String &new_name)
 
void add_attribute (const String &aname, const String &value)
 Adds a String attribute to tag. More...
 
void add_attribute (const String &aname, const Index &value)
 Adds an Index attribute to tag. More...
 
void check_attribute (const String &aname, const String &value)
 Checks whether attribute has the expected value. More...
 
void get_attribute_value (const String &aname, String &value)
 Returns value of attribute as String. More...
 
void get_attribute_value (const String &aname, Index &value)
 Returns value of attribute as type Index. More...
 
void read_from_stream (istream &is)
 Reads next XML tag. More...
 
void write_to_stream (ostream &os)
 Write XML tag. More...
 

Private Attributes

String name
 
Array< XMLAttributeattribs
 
const Verbosityverbosity
 

Detailed Description

The ARTS XML tag class.

Handles reading, writing and constructing of XML tags.

Definition at line 79 of file xml_io_private.h.

Constructor & Destructor Documentation

◆ ArtsXMLTag()

ArtsXMLTag::ArtsXMLTag ( const Verbosity rverbosity)
inline

Definition at line 81 of file xml_io_private.h.

Member Function Documentation

◆ add_attribute() [1/2]

void ArtsXMLTag::add_attribute ( const String aname,
const String value 
)

Adds a String attribute to tag.

Parameters
anameAttribute name
valueAttribute value

Definition at line 69 of file xml_io.cc.

References attribs, XMLAttribute::name, and XMLAttribute::value.

Referenced by add_attribute(), xml_write_header_to_stream(), and xml_write_to_stream().

◆ add_attribute() [2/2]

void ArtsXMLTag::add_attribute ( const String aname,
const Index value 
)

Adds an Index attribute to tag.

Parameters
anameAttribute name
valueAttribute value

Definition at line 85 of file xml_io.cc.

References add_attribute().

◆ check_attribute()

void ArtsXMLTag::check_attribute ( const String aname,
const String value 
)

Checks whether attribute has the expected value.

If the attribute has another value or is unknown an exception is thrown.

Parameters
anameAttribute name
valueExpected value

Definition at line 103 of file xml_io.cc.

References get_attribute_value(), and xml_parse_error().

Referenced by xml_parse_from_stream(), and xml_read_from_stream().

◆ check_name()

void ArtsXMLTag::check_name ( const String expected_name)

Check tag name.

Checks whether the name of the tag is correct. Throws runtime error otherwise.

Parameters
expected_nameExpected tag name

Definition at line 56 of file xml_io.cc.

References name, and xml_parse_error().

Referenced by read_from_stream(), xml_read_footer_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().

◆ get_attribute_value() [1/2]

void ArtsXMLTag::get_attribute_value ( const String aname,
String value 
)

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*.

Parameters
anameAttribute name
valueReturn value

Definition at line 131 of file xml_io.cc.

References attribs.

Referenced by check_attribute(), get_attribute_value(), xml_parse_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().

◆ get_attribute_value() [2/2]

void ArtsXMLTag::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*.

Parameters
anameAttribute name
valueReturn value

Definition at line 160 of file xml_io.cc.

References get_attribute_value(), name, and xml_parse_error().

◆ get_name()

String& ArtsXMLTag::get_name ( )
inline

Definition at line 83 of file xml_io_private.h.

References XMLAttribute::name.

Referenced by xml_read_from_stream().

◆ read_from_stream()

void ArtsXMLTag::read_from_stream ( istream &  is)

Reads next XML tag.

Reads the name and attributes of the next XML tag from stream.

Parameters
isInput stream

Definition at line 183 of file xml_io.cc.

References attribs, check_name(), CREATE_OUT3, XMLAttribute::name, name, my_basic_string< charT >::npos, XMLAttribute::value, and xml_parse_error().

Referenced by xml_read_footer_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().

◆ set_name()

void ArtsXMLTag::set_name ( const String new_name)
inline

◆ write_to_stream()

void ArtsXMLTag::write_to_stream ( ostream &  os)

Write XML tag.

Puts the tag together and writes it to stream.

Parameters
osOutput stream

Definition at line 321 of file xml_io.cc.

References attribs, and name.

Referenced by xml_data_parse_error(), xml_write_footer_to_stream(), xml_write_header_to_stream(), and xml_write_to_stream().

Member Data Documentation

◆ attribs

Array<XMLAttribute> ArtsXMLTag::attribs
private

List of attributes

Definition at line 105 of file xml_io_private.h.

Referenced by add_attribute(), get_attribute_value(), read_from_stream(), and write_to_stream().

◆ name

String ArtsXMLTag::name
private

◆ verbosity

const Verbosity& ArtsXMLTag::verbosity
private

Definition at line 106 of file xml_io_private.h.

Referenced by xml_open_input_file().


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