ARTS  2.3.1285(git:92a29ea9-dirty)
ArtsXMLTag Class Reference

The ARTS XML tag class. More...

#include <xml_io_private.h>

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 add_attribute (const String &aname, const Numeric &value)
 Adds value of attribute as type Numeric to tag. More...
 
void add_attribute (const String &aname, const std::vector< QuantumNumberType > &value)
 Adds value of attribute as type std::vector<QuantumNumberType> to tag. More...
 
void add_attribute (const String &aname, const ArrayOfSpeciesTag &value, const bool self, const bool bath)
 Adds value of attribute. 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 get_attribute_value (const String &aname, Numeric &value)
 Returns value of attribute as type Numeric. More...
 
void get_attribute_value (const String &aname, SpeciesTag &value)
 Returns value of attribute as type SpeciesTag. More...
 
void get_attribute_value (const String &aname, ArrayOfSpeciesTag &value, bool &self, bool &bath)
 Returns value of attribute as type ArrayOfSpeciesTag. More...
 
void get_attribute_value (const String &aname, std::vector< QuantumNumberType > &value)
 Returns value of attribute as type ArrayOfSpeciesTag. More...
 
void get_attribute_value (const String &aname, QuantumNumbers &value)
 Returns value of attribute as type ArrayOfSpeciesTag. 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 90 of file xml_io_private.h.

Constructor & Destructor Documentation

◆ ArtsXMLTag()

ArtsXMLTag::ArtsXMLTag ( const Verbosity rverbosity)
inline

Definition at line 92 of file xml_io_private.h.

Member Function Documentation

◆ add_attribute() [1/5]

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

Adds a String attribute to tag.

Parameters
anameAttribute name
valueAttribute value

Definition at line 66 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/5]

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

Adds an Index attribute to tag.

Parameters
anameAttribute name
valueAttribute value

Definition at line 80 of file xml_io.cc.

References add_attribute(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ add_attribute() [3/5]

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

Adds value of attribute as type Numeric to tag.

Parameters
[in]anameAttribute name
[in]valueSet value

Definition at line 87 of file xml_io.cc.

References add_attribute(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ add_attribute() [4/5]

void ArtsXMLTag::add_attribute ( const String aname,
const std::vector< QuantumNumberType > &  value 
)

Adds value of attribute as type std::vector<QuantumNumberType> to tag.

Parameters
[in]anameAttribute name
[in]valueSet value

Definition at line 94 of file xml_io.cc.

References add_attribute(), i, quantumnumbertype2string(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ add_attribute() [5/5]

void ArtsXMLTag::add_attribute ( const String aname,
const ArrayOfSpeciesTag value,
const bool  self,
const bool  bath 
)

Adds value of attribute.

Parameters
[in]anameAttribute name
[in]valueSpeciesTag(s) for all lines. Basic initialization at self and bath
[in]selfTrue if LineShape::self_broadening in list
[in]bathTrue if LineShape::bath_broadening in list

Definition at line 108 of file xml_io.cc.

References add_attribute(), i, Array< base >::nelem(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ 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 131 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 54 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/7]

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 153 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/7]

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 176 of file xml_io.cc.

References get_attribute_value(), name, _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), and xml_parse_error().

◆ get_attribute_value() [3/7]

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

Parameters
[in]anameAttribute name
[out]valueReturn value

Definition at line 189 of file xml_io.cc.

References get_attribute_value(), name, _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), and xml_parse_error().

◆ get_attribute_value() [4/7]

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

Returns value of attribute as type SpeciesTag.

Searches for the matching attribute and returns it value. If no attribute with the given name exists, it fails exceptionally.

Parameters
[in]anameAttribute name
[out]valueReturn value

Definition at line 202 of file xml_io.cc.

References get_attribute_value().

◆ get_attribute_value() [5/7]

void ArtsXMLTag::get_attribute_value ( const String aname,
ArrayOfSpeciesTag value,
bool &  self,
bool &  bath 
)

Returns value of attribute as type ArrayOfSpeciesTag.

Searches for the matching attribute and returns it value. If no attribute with the given name exists, it fails exceptionally.

Parameters
[in]anameAttribute name
[out]valueSpeciesTag(s) for all lines. Basic initialization at self and bath
[out]selfTrue if LineShape::self_broadening in list
[out]bathTrue if LineShape::bath_broadening in list

Definition at line 209 of file xml_io.cc.

References get_attribute_value(), name, my_basic_string< charT >::nelem(), _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), and xml_parse_error().

◆ get_attribute_value() [6/7]

void ArtsXMLTag::get_attribute_value ( const String aname,
std::vector< QuantumNumberType > &  value 
)

Returns value of attribute as type ArrayOfSpeciesTag.

Searches for the matching attribute and returns it value

Parameters
[in]anameAttribute name
[out]valueReturn value

Definition at line 243 of file xml_io.cc.

References get_attribute_value(), name, my_basic_string< charT >::nelem(), _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str(), string2quantumnumbertype(), and xml_parse_error().

◆ get_attribute_value() [7/7]

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

Returns value of attribute as type ArrayOfSpeciesTag.

Searches for the matching attribute and returns it value

Parameters
[in]anameAttribute name
[in,out]valueReturn value

Definition at line 265 of file xml_io.cc.

References get_attribute_value(), r, QuantumNumbers::Set(), and _CS_basic_sstream_base< _CS_cT, _CS_Tr, _CS_Al >::str().

◆ get_name()

String& ArtsXMLTag::get_name ( )
inline

Definition at line 94 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)

◆ 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 410 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 190 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 191 of file xml_io_private.h.

Referenced by xml_open_input_file().


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