ARTS 2.5.11 (git: 6827797f)
xml_io_base.cc File Reference
#include "xml_io_base.h"
#include "arts.h"
#include "bifstream.h"
#include "bofstream.h"
#include "file.h"
#include <iterator>
#include <string_view>

Go to the source code of this file.

Functions

FileType string2filetype (const String &file_format)
 
void xml_open_output_file (ofstream &file, const String &name)
 Open file for XML output.
 
void xml_open_input_file (ifstream &ifs, const String &name, const Verbosity &verbosity)
 Open file for XML input.
 
void xml_parse_error (const String &str_error)
 Throws XML parser runtime error.
 
void xml_data_parse_error (XMLTag &tag, const String &str_error)
 Throws XML parser runtime error.
 
void xml_read_header_from_stream (istream &is, FileType &ftype, NumericType &ntype, EndianType &etype, const Verbosity &verbosity)
 Reads XML header and root tag.
 
void xml_read_footer_from_stream (istream &is, const Verbosity &verbosity)
 Reads closing root tag.
 
void xml_write_header_to_stream (ostream &os, FileType ftype, const Verbosity &verbosity)
 Writes XML header and root tag.
 
void xml_write_footer_to_stream (ostream &os, const Verbosity &verbosity)
 Write closing root tag.
 
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.
 

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 706 of file xml_io_base.cc.

Referenced by xml_read_from_stream().

◆ string2filetype()

FileType string2filetype ( const String file_format)

◆ xml_data_parse_error()

void xml_data_parse_error ( XMLTag tag,
const 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 537 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 432 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 342 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 522 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_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 638 of file xml_io_base.cc.

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

Referenced by xml_read_from_file_base().

◆ 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 557 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(), 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 688 of file xml_io_base.cc.

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 679 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 650 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().