ARTS  2.4.0(git:4fb77825)
xml_io_private.h
Go to the documentation of this file.
1 /* Copyright (C) 2002-2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
19 // File description
21 
31 #ifndef xml_io_private_h
32 #define xml_io_private_h
33 
34 #include <cfloat>
35 #include <memory>
36 #include <stdexcept>
37 #include "absorption.h"
38 #include "agenda_class.h"
39 #include "array.h"
40 #include "bifstream.h"
41 #include "bofstream.h"
42 #include "gas_abs_lookup.h"
43 #include "matpackVII.h"
44 #include "messages.h"
45 #include "optproperties.h"
46 #include "ppath.h"
47 #include "xml_io.h"
48 
50 // Functions to open and read XML files
52 
53 void xml_open_output_file(ostream& file, const String& name);
54 
55 void xml_open_input_file(ifstream& file,
56  const String& name,
57  const Verbosity& verbosity);
58 
67 void xml_find_and_open_input_file(std::shared_ptr<istream>& ifs,
68  const String& filename,
69  const Verbosity& verbosity);
70 
72 // XML parser classes
74 
76 
80 class XMLAttribute {
81  public:
84 };
85 
87 
90 class ArtsXMLTag {
91  public:
92  ArtsXMLTag(const Verbosity& rverbosity) : verbosity(rverbosity){};
93 
94  String& get_name() { return name; }
95 
96  void check_name(const String& expected_name);
97 
98  void set_name(const String& new_name) { name = new_name; }
99 
100  void add_attribute(const String& aname, const String& value);
101 
102  void add_attribute(const String& aname, const Index& value);
103 
109  void add_attribute(const String& aname, const Numeric& value);
110 
116  void add_attribute(const String& aname, const std::vector<QuantumNumberType>& value);
117 
125  void add_attribute(const String& aname, const ArrayOfSpeciesTag& value, const bool self, const bool bath);
126 
127  void check_attribute(const String& aname, const String& value);
128 
129  void get_attribute_value(const String& aname, String& value);
130 
131  void get_attribute_value(const String& aname, Index& value);
132 
142  void get_attribute_value(const String& aname, Numeric& value);
143 
152  void get_attribute_value(const String& aname, SpeciesTag& value);
153 
164  void get_attribute_value(const String& aname, ArrayOfSpeciesTag& value, bool& self, bool& bath);
165 
173  void get_attribute_value(const String& aname, std::vector<QuantumNumberType>& value);
174 
182  void get_attribute_value(const String& aname, QuantumNumbers& value);
183 
184  void read_from_stream(istream& is);
185 
186  void write_to_stream(ostream& os);
187 
188  private:
192 };
193 
195 // General XML handling routines
197 
198 void xml_parse_error(const String& str_error);
199 
200 void xml_data_parse_error(ArtsXMLTag& tag, String str_error);
201 
202 void xml_read_header_from_stream(istream& is,
203  FileType& ftype,
204  NumericType& ntype,
205  EndianType& etype,
206  const Verbosity& verbosity);
207 
208 void xml_read_footer_from_stream(istream& is, const Verbosity& verbosity);
209 
210 void xml_write_header_to_stream(ostream& os,
211  FileType ftype,
212  const Verbosity& verbosity);
213 
214 void xml_write_footer_to_stream(ostream& os, const Verbosity& verbosity);
215 
216 void xml_set_stream_precision(ostream& os);
217 
218 void parse_xml_tag_content_as_string(std::istream& is_xml, String& content);
219 
220 #endif /* xml_io_private_h */
ArtsXMLTag::ArtsXMLTag
ArtsXMLTag(const Verbosity &rverbosity)
Definition: xml_io_private.h:92
NumericType
NumericType
Definition: xml_io.h:43
ArtsXMLTag::verbosity
const Verbosity & verbosity
Definition: xml_io_private.h:191
QuantumNumbers
Container class for Quantum Numbers.
Definition: quantum.h:222
ArtsXMLTag::check_name
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io.cc:54
absorption.h
Declarations required for the calculation of absorption coefficients.
xml_set_stream_precision
void xml_set_stream_precision(ostream &os)
Definition: xml_io.cc:856
XMLAttribute
XML attribute class.
Definition: xml_io_private.h:80
xml_open_input_file
void xml_open_input_file(ifstream &file, const String &name, const Verbosity &verbosity)
Open file for XML input.
Definition: xml_io.cc:569
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
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.
Definition: xml_io.cc:725
ArtsXMLTag::get_attribute_value
void get_attribute_value(const String &aname, String &value)
Returns value of attribute as String.
Definition: xml_io.cc:153
FileType
FileType
Definition: xml_io.h:37
ArtsXMLTag::check_attribute
void check_attribute(const String &aname, const String &value)
Checks whether attribute has the expected value.
Definition: xml_io.cc:131
ArtsXMLTag::name
String name
Definition: xml_io_private.h:189
array.h
This file contains the definition of Array.
ArtsXMLTag::write_to_stream
void write_to_stream(ostream &os)
Write XML tag.
Definition: xml_io.cc:410
xml_data_parse_error
void xml_data_parse_error(ArtsXMLTag &tag, String str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:705
Array
This can be used to make arrays out of anything.
Definition: array.h:108
SpeciesTag
A tag group can consist of the sum of several of these.
Definition: abs_species_tags.h:44
ArtsXMLTag::attribs
Array< XMLAttribute > attribs
Definition: xml_io_private.h:190
agenda_class.h
Declarations for agendas.
messages.h
Declarations having to do with the four output streams.
xml_write_header_to_stream
void xml_write_header_to_stream(ostream &os, FileType ftype, const Verbosity &verbosity)
Writes XML header and root tag.
Definition: xml_io.cc:818
ArtsXMLTag::read_from_stream
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io.cc:289
my_basic_string< char >
optproperties.h
Scattering database structure and functions.
xml_read_footer_from_stream
void xml_read_footer_from_stream(istream &is, const Verbosity &verbosity)
Reads closing root tag.
Definition: xml_io.cc:806
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Verbosity
Definition: messages.h:49
ArtsXMLTag::add_attribute
void add_attribute(const String &aname, const String &value)
Adds a String attribute to tag.
Definition: xml_io.cc:66
ArtsXMLTag::get_name
String & get_name()
Definition: xml_io_private.h:94
xml_find_and_open_input_file
void xml_find_and_open_input_file(std::shared_ptr< istream > &ifs, const String &filename, const Verbosity &verbosity)
Open plain or zipped xml file.
Definition: xml_io.cc:648
bifstream.h
This file contains the class declaration of bifstream.
bofstream.h
This file contains the class declaration of bofstream.
xml_parse_error
void xml_parse_error(const String &str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:690
ppath.h
Propagation path structure and functions.
EndianType
EndianType
Definition: xml_io.h:44
xml_write_footer_to_stream
void xml_write_footer_to_stream(ostream &os, const Verbosity &verbosity)
Write closing root tag.
Definition: xml_io.cc:847
xml_open_output_file
void xml_open_output_file(ostream &file, const String &name)
ArtsXMLTag
The ARTS XML tag class.
Definition: xml_io_private.h:90
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
XMLAttribute::name
String name
Definition: xml_io_private.h:82
ArtsXMLTag::set_name
void set_name(const String &new_name)
Definition: xml_io_private.h:98
XMLAttribute::value
String value
Definition: xml_io_private.h:83
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: xml_io.cc:874
gas_abs_lookup.h
Declarations for the gas absorption lookup table.
matpackVII.h
xml_io.h
This file contains basic functions to handle XML data files.