ARTS 2.5.0 (git: 9ee3ac6c)
xml_io_base.h File Reference
#include "arts.h"
#include "xml_io_general_types.h"

Go to the source code of this file.

Classes

class  XMLAttribute
 XML attribute class. More...
 
class  XMLTag
 The ARTS XML tag class. More...
 

Enumerations

enum  FileType : Index { FILE_TYPE_ASCII = 0 , FILE_TYPE_ZIPPED_ASCII = 1 , FILE_TYPE_BINARY = 2 }
 
enum  NumericType { NUMERIC_TYPE_FLOAT , NUMERIC_TYPE_DOUBLE }
 
enum  EndianType { ENDIAN_TYPE_LITTLE , ENDIAN_TYPE_BIG }
 

Functions

void xml_parse_error (const String &str_error)
 Throws XML parser runtime error. More...
 
void xml_data_parse_error (XMLTag &tag, String str_error)
 Throws XML parser runtime error. More...
 
void xml_set_stream_precision (ostream &os)
 
void parse_xml_tag_content_as_string (std::istream &is_xml, String &content)
 Get the content of an xml tag as a string. More...
 
void xml_parse_from_stream (istream &, Vector &, bifstream *, XMLTag &, const Verbosity &verbosity)
 Parses Vector from XML input stream. More...
 
void xml_parse_from_stream (istream &, ArrayOfString &, bifstream *, XMLTag &, const Verbosity &)
 Parse ArrayOfString from XML input stream. More...
 
FileType string2filetype (const String &file_format)
 
void xml_read_header_from_stream (istream &is, FileType &ftype, NumericType &ntype, EndianType &etype, const Verbosity &verbosity)
 Reads XML header and root tag. More...
 
void xml_read_footer_from_stream (istream &is, const Verbosity &verbosity)
 Reads closing root tag. More...
 
void xml_write_header_to_stream (ostream &os, FileType ftype, const Verbosity &verbosity)
 Writes XML header and root tag. More...
 
void xml_write_footer_to_stream (ostream &os, const Verbosity &verbosity)
 Write closing root tag. More...
 
void xml_open_input_file (ifstream &ifs, const String &name, const Verbosity &verbosity)
 Open file for XML input. More...
 
void xml_open_output_file (ofstream &file, const String &name)
 Open file for XML output. More...
 
template<typename T >
void xml_read_from_file_base (const String &filename, T &type, const Verbosity &verbosity)
 Reads data from XML file. More...
 
template<typename T >
void xml_write_to_file_base (const String &filename, const T &type, const FileType ftype, const Verbosity &verbosity)
 Write data to XML file. More...
 

Enumeration Type Documentation

◆ EndianType

enum EndianType
Enumerator
ENDIAN_TYPE_LITTLE 
ENDIAN_TYPE_BIG 

Definition at line 47 of file xml_io_base.h.

◆ FileType

enum FileType : Index
Enumerator
FILE_TYPE_ASCII 
FILE_TYPE_ZIPPED_ASCII 
FILE_TYPE_BINARY 

Definition at line 40 of file xml_io_base.h.

◆ NumericType

Enumerator
NUMERIC_TYPE_FLOAT 
NUMERIC_TYPE_DOUBLE 

Definition at line 46 of file xml_io_base.h.

Function Documentation

◆ parse_xml_tag_content_as_string()

void parse_xml_tag_content_as_string ( std::istream &  is_xml,
String content 
)

Get the content of an xml tag as a string.

Definition at line 701 of file xml_io_base.cc.

References Options::char.

Referenced by xml_read_from_stream().

◆ string2filetype()

FileType string2filetype ( const String file_format)

◆ xml_data_parse_error()

void xml_data_parse_error ( XMLTag tag,
String  str_error 
)

Throws XML parser runtime error.

This is used quite often inside the data parsing routines so it's a function for itself.

Parameters
tagXMLTag
str_errorError description

Definition at line 532 of file xml_io_base.cc.

References XMLTag::write_to_stream().

◆ xml_open_input_file()

void xml_open_input_file ( ifstream &  ifs,
const String name,
const Verbosity verbosity 
)

Open file for XML input.

This function opens an XML file for reading.

Parameters
ifsInput filestream
nameFilename

Definition at line 427 of file xml_io_base.cc.

References CREATE_OUT3.

Referenced by xml_find_and_open_input_file(), and xml_read_from_file_base().

◆ xml_open_output_file()

void xml_open_output_file ( ofstream &  file,
const String name 
)

Open file for XML output.

This function opens an XML file for writing.

Parameters
fileOutput filestream
nameFilename

Definition at line 337 of file xml_io_base.cc.

Referenced by xml_write_to_file_base().

◆ xml_parse_error()

void xml_parse_error ( const String str_error)

Throws XML parser runtime error.

This is used quite often inside the parsing routines so it's a function for itself.

Parameters
str_errorError description

Definition at line 517 of file xml_io_base.cc.

Referenced by XMLTag::check_attribute(), XMLTag::check_name(), ArtsXMLTag::get_attribute_value(), XMLTag::get_attribute_value(), XMLTag::read_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().

◆ xml_parse_from_stream() [1/2]

void xml_parse_from_stream ( istream &  is_xml,
ArrayOfString astring,
bifstream pbifs,
XMLTag tag,
const Verbosity verbosity 
)

Parse ArrayOfString from XML input stream.

Parameters
is_xmlXML Input stream
astringArrayOfString return value
pbifsPointer to binary input stream. NULL in case of ASCII file.
tagXML tag object

Definition at line 2715 of file xml_io_array_types.cc.

References XMLTag::check_attribute(), XMLTag::get_attribute_value(), Absorption::nelem(), and xml_read_from_stream().

Referenced by xml_read_from_stream().

◆ xml_parse_from_stream() [2/2]

void xml_parse_from_stream ( istream &  is_xml,
Vector vector,
bifstream pbifs,
XMLTag tag,
const Verbosity verbosity 
)

Parses Vector from XML input stream.

Parameters
is_xmlXML Input stream
vectorVector return value
pbifsPointer to binary input stream. NULL in case of ASCII file.
tagXML tag object

Definition at line 1139 of file xml_io_general_types.cc.

References XMLTag::get_attribute_value(), Absorption::nelem(), Vector::resize(), and xml_data_parse_error().

Referenced by xml_read_from_stream().

◆ xml_read_footer_from_stream()

void xml_read_footer_from_stream ( istream &  is,
const Verbosity verbosity 
)

Reads closing root tag.

Checks whether XML file ends correctly with </arts>.

Parameters
isInput stream

Definition at line 633 of file xml_io_base.cc.

References XMLTag::check_name(), and XMLTag::read_from_stream().

Referenced by xml_read_from_file_base().

◆ xml_read_from_file_base()

template<typename T >
void xml_read_from_file_base ( const String filename,
T &  type,
const Verbosity verbosity 
)

Reads data from XML file.

This is a generic functions that is used to read the XML header and footer info and calls the overloaded functions to read the data.

Parameters
filenameXML filename
typeGeneric return value

Definition at line 243 of file xml_io_base.h.

References CREATE_OUT2, FILE_TYPE_ASCII, my_basic_string< charT >::nelem(), Hitran::type, xml_open_input_file(), xml_read_footer_from_stream(), xml_read_from_stream(), and xml_read_header_from_stream().

Referenced by PartitionFunctions::data_read_file(), main(), and xml_read_from_file().

◆ xml_read_header_from_stream()

void xml_read_header_from_stream ( istream &  is,
FileType ftype,
NumericType ntype,
EndianType etype,
const Verbosity verbosity 
)

Reads XML header and root tag.

Check whether XML file has correct version tag and reads arts root tag information.

Parameters
isInput stream
ftypeFile type
ntypeNumeric type
etypeEndian type

Definition at line 552 of file xml_io_base.cc.

References XMLTag::check_name(), ENDIAN_TYPE_BIG, ENDIAN_TYPE_LITTLE, FILE_TYPE_ASCII, FILE_TYPE_BINARY, XMLTag::get_attribute_value(), NUMERIC_TYPE_DOUBLE, NUMERIC_TYPE_FLOAT, XMLTag::read_from_stream(), str, and xml_parse_error().

Referenced by ReadArrayOfARTSCAT(), ReadARTSCAT(), and xml_read_from_file_base().

◆ xml_set_stream_precision()

void xml_set_stream_precision ( ostream &  os)

Definition at line 683 of file xml_io_base.cc.

References precision.

Referenced by xml_write_to_stream().

◆ xml_write_footer_to_stream()

void xml_write_footer_to_stream ( ostream &  os,
const Verbosity verbosity 
)

Write closing root tag.

Parameters
osOutput stream

Definition at line 674 of file xml_io_base.cc.

References XMLTag::set_name(), and XMLTag::write_to_stream().

Referenced by xml_write_to_file_base().

◆ xml_write_header_to_stream()

void xml_write_header_to_stream ( ostream &  os,
FileType  ftype,
const Verbosity verbosity 
)

Writes XML header and root tag.

Parameters
osOutput stream
ftypeFile type

Definition at line 645 of file xml_io_base.cc.

References XMLTag::add_attribute(), FILE_TYPE_ASCII, FILE_TYPE_BINARY, FILE_TYPE_ZIPPED_ASCII, XMLTag::set_name(), and XMLTag::write_to_stream().

Referenced by xml_write_to_file_base().

◆ xml_write_to_file_base()

template<typename T >
void xml_write_to_file_base ( const String filename,
const T &  type,
const FileType  ftype,
const Verbosity verbosity 
)

Write data to XML file.

This is a generic functions that is used to write the XML header and footer info and calls the overloaded functions to write the data.

Parameters
filenameXML filename
typeGeneric input value
no_clobber0: Overwrite, 1: Use unique filename
ftypeFile type

Definition at line 311 of file xml_io_base.h.

References CREATE_OUT2, FILE_TYPE_ASCII, FILE_TYPE_ZIPPED_ASCII, Hitran::type, xml_open_output_file(), xml_write_footer_to_stream(), xml_write_header_to_stream(), and xml_write_to_stream().

Referenced by main(), and xml_write_to_file().