ARTS  2.3.1285(git:92a29ea9-dirty)
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 */
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
void xml_open_input_file(ifstream &file, const String &name, const Verbosity &verbosity)
Open file for XML input.
Definition: xml_io.cc:569
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
Declarations having to do with the four output streams.
XML attribute class.
String & get_name()
void xml_parse_error(const String &str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:690
This file contains basic functions to handle XML data files.
FileType
Definition: xml_io.h:37
This file contains the definition of Array.
const Verbosity & verbosity
The ARTS XML tag class.
ArtsXMLTag(const Verbosity &rverbosity)
void xml_set_stream_precision(ostream &os)
Definition: xml_io.cc:856
void set_name(const String &new_name)
Declarations for agendas.
This file contains the class declaration of bifstream.
This file contains the class declaration of bofstream.
void xml_write_footer_to_stream(ostream &os, const Verbosity &verbosity)
Write closing root tag.
Definition: xml_io.cc:847
A tag group can consist of the sum of several of these.
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
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
Declarations for the gas absorption lookup table.
Declarations required for the calculation of absorption coefficients.
Propagation path structure and functions.
Container class for Quantum Numbers.
Definition: quantum.h:222
void xml_write_header_to_stream(ostream &os, FileType ftype, const Verbosity &verbosity)
Writes XML header and root tag.
Definition: xml_io.cc:818
Array< XMLAttribute > attribs
EndianType
Definition: xml_io.h:44
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
void xml_data_parse_error(ArtsXMLTag &tag, String str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:705
NumericType
Definition: xml_io.h:43
void xml_read_footer_from_stream(istream &is, const Verbosity &verbosity)
Reads closing root tag.
Definition: xml_io.cc:806
Scattering database structure and functions.
void xml_open_output_file(ostream &file, const String &name)