ARTS  2.2.66
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 
18 
20 // File description
22 
32 #ifndef xml_io_private_h
33 #define xml_io_private_h
34 
35 #include "xml_io.h"
36 #include <stdexcept>
37 #include <cfloat>
38 #include "matpackVII.h"
39 #include "array.h"
40 #include "messages.h"
41 #include "ppath.h"
42 #include "agenda_class.h"
43 #include "absorption.h"
44 #include "gas_abs_lookup.h"
45 #include "optproperties.h"
46 #include "bifstream.h"
47 #include "bofstream.h"
48 
49 
51 // Functions to open and read XML files
53 
54 void xml_open_output_file(ostream& file, const String& name);
55 
56 void xml_open_input_file(ifstream& file, const String& name, const Verbosity& verbosity);
57 
58 
60 // XML parser classes
62 
64 
68 class XMLAttribute {
69 public:
72 };
73 
74 
76 
79 class ArtsXMLTag {
80 public:
81  ArtsXMLTag(const Verbosity& rverbosity) : verbosity(rverbosity) {};
82 
83  String& get_name() { return name; }
84 
85  void check_name(const String& expected_name);
86 
87  void set_name(const String& new_name) { name = new_name; }
88 
89  void add_attribute(const String& aname, const String& value);
90 
91  void add_attribute(const String& aname, const Index& value);
92 
93  void check_attribute(const String& aname, const String& value);
94 
95  void get_attribute_value(const String& aname, String& value);
96 
97  void get_attribute_value(const String& aname, Index& value);
98 
99  void read_from_stream(istream& is);
100 
101  void write_to_stream(ostream& os);
102 
103 private:
107 };
108 
109 
111 // General XML handling routines
113 
114 void xml_parse_error(const String& str_error);
115 
116 void xml_data_parse_error(ArtsXMLTag& tag, String str_error);
117 
118 void xml_read_header_from_stream(istream& is, FileType& ftype,
119  NumericType& ntype, EndianType& etype,
120  const Verbosity& verbosity);
121 
122 void xml_read_footer_from_stream(istream& is, const Verbosity& verbosity);
123 
124 void xml_write_header_to_stream(ostream& os, FileType ftype, const Verbosity& verbosity);
125 
126 void xml_write_footer_to_stream(ostream& os, const Verbosity& verbosity);
127 
128 void xml_set_stream_precision(ostream& os);
129 
130 
131 #endif /* xml_io_private_h */
ArtsXMLTag::ArtsXMLTag
ArtsXMLTag(const Verbosity &rverbosity)
Definition: xml_io_private.h:81
NumericType
NumericType
Definition: xml_io.h:44
ArtsXMLTag::verbosity
const Verbosity & verbosity
Definition: xml_io_private.h:106
ArtsXMLTag::check_name
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io.cc:56
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:799
XMLAttribute
XML attribute class.
Definition: xml_io_private.h:68
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:507
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:644
ArtsXMLTag::get_attribute_value
void get_attribute_value(const String &aname, String &value)
Returns value of attribute as String.
Definition: xml_io.cc:131
ArtsXMLTag::check_attribute
void check_attribute(const String &aname, const String &value)
Checks whether attribute has the expected value.
Definition: xml_io.cc:103
ArtsXMLTag::name
String name
Definition: xml_io_private.h:104
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:321
xml_data_parse_error
void xml_data_parse_error(ArtsXMLTag &tag, String str_error)
Throws XML parser runtime error.
Definition: xml_io.cc:622
Array< XMLAttribute >
ArtsXMLTag::attribs
Array< XMLAttribute > attribs
Definition: xml_io_private.h:105
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:756
ArtsXMLTag::read_from_stream
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io.cc:183
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:64
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:742
Verbosity
Definition: messages.h:50
ArtsXMLTag::add_attribute
void add_attribute(const String &aname, const String &value)
Adds a String attribute to tag.
Definition: xml_io.cc:69
ArtsXMLTag::get_name
String & get_name()
Definition: xml_io_private.h:83
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:605
FileType
FileType
Definition: xml_io.h:38
ppath.h
Propagation path structure and functions.
EndianType
EndianType
Definition: xml_io.h:45
xml_write_footer_to_stream
void xml_write_footer_to_stream(ostream &os, const Verbosity &verbosity)
Write closing root tag.
Definition: xml_io.cc:788
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:79
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
XMLAttribute::name
String name
Definition: xml_io_private.h:70
ArtsXMLTag::set_name
void set_name(const String &new_name)
Definition: xml_io_private.h:87
XMLAttribute::value
String value
Definition: xml_io_private.h:71
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.