ARTS 2.5.11 (git: 6827797f)
xml_io.h
Go to the documentation of this file.
1
2// File description
4
13#ifndef xml_io_h
14#define xml_io_h
15
16#include "arts.h"
17#include "xml_io_base.h"
18#include "xml_io_arts_types.h"
19
21// XML parser classes
23
25
28class ArtsXMLTag : public XMLTag {
29 public:
30 ArtsXMLTag(const Verbosity& rverbosity) : XMLTag(rverbosity){};
31
33
39 void add_attribute(const String& aname, const std::vector<QuantumNumberType>& value);
40
48 void add_attribute(const String& aname, const ArrayOfSpecies& value, const bool self, const bool bath);
49
51
60 void get_attribute_value(const String& aname, SpeciesTag& value);
61
72 void get_attribute_value(const String& aname, ArrayOfSpecies& value, bool& self, bool& bath);
73
81 void get_attribute_value(const String& aname, std::vector<QuantumNumberType>& value);
82};
83
85// General XML handling routines
87
89 istream &, Vector &, bifstream *, ArtsXMLTag &, const Verbosity &verbosity);
90
92 istream &, ArrayOfString &, bifstream *, ArtsXMLTag &, const Verbosity &);
93
95// Generic IO routines for XML files
97
106void xml_find_and_open_input_file(std::shared_ptr<istream>& ifs,
107 const String& filename,
108 const Verbosity& verbosity);
109
111// Default file names
113
114void filename_xml(String& filename, const String& varname);
115
116void filename_xml_with_index(String& filename,
117 const Index& file_index,
118 const String& varname,
119 const Index& digits = 0);
120
122// Generic IO routines for XML files
124
126
133template <typename T>
134void xml_read_from_file(const String& filename,
135 T& type,
136 const Verbosity& verbosity) {
138
139 String xml_file = filename;
140 find_xml_file(xml_file, verbosity);
141 xml_read_from_file_base(xml_file, type, verbosity);
142}
143
145
154template <typename T>
155void xml_write_to_file(const String& filename,
156 const T& type,
157 const FileType ftype,
158 const Index no_clobber,
159 const Verbosity& verbosity) {
161
162 String efilename{add_basedir(filename)};
163
164 std::unique_ptr<ostream> ofs;
165
166 if (no_clobber) efilename = make_filename_unique(efilename, ".xml");
167
168 xml_write_to_file_base(efilename, type, ftype, verbosity);
169}
170
171#endif
The global header file for ARTS.
The ARTS XML tag class.
Definition: xml_io.h:28
void add_attribute(const String &aname, const std::vector< QuantumNumberType > &value)
Adds value of attribute as type std::vector<QuantumNumberType> to tag.
Definition: xml_io.cc:25
void get_attribute_value(const String &aname, SpeciesTag &value)
Returns value of attribute as type SpeciesTag.
Definition: xml_io.cc:53
ArtsXMLTag(const Verbosity &rverbosity)
Definition: xml_io.h:30
The ARTS XML tag class.
Definition: xml_io_base.h:53
void add_attribute(const String &aname, String value)
Definition: xml_io_base.cc:50
void get_attribute_value(const String &aname, String &value)
Definition: xml_io_base.cc:123
Binary output file stream class.
Definition: bifstream.h:26
String add_basedir(const std::string_view path)
Definition: file.cc:424
void find_xml_file(String &filename, const Verbosity &verbosity)
Find an xml file.
Definition: file.cc:338
String make_filename_unique(const std::string_view filename, const String &extension)
Make filename unique.
Definition: file.cc:496
#define CREATE_OUT2
Definition: messages.h:188
Species::Tag SpeciesTag
Definition: species_tags.h:94
void xml_write_to_file(const String &filename, const T &type, const FileType ftype, const Index no_clobber, const Verbosity &verbosity)
Write data to XML file.
Definition: xml_io.h:155
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:119
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Definition: xml_io.h:134
void filename_xml(String &filename, const String &varname)
Gives the default filename for the XML formats.
Definition: xml_io.cc:183
void filename_xml_with_index(String &filename, const Index &file_index, const String &varname, const Index &digits=0)
Gives the default filename, with file index, for the XML formats.
Definition: xml_io.cc:199
void xml_parse_from_stream(istream &, Vector &, bifstream *, ArtsXMLTag &, const Verbosity &verbosity)
This file contains private function declarations and template instantiation to handle XML data files.
FileType
Definition: xml_io_base.h:25
void xml_write_to_file_base(const String &filename, const T &type, const FileType ftype, const Verbosity &verbosity)
Write data to XML file.
Definition: xml_io_base.h:296
void xml_read_from_file_base(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Definition: xml_io_base.h:228