ARTS  2.4.0(git:4fb77825)
xml_io.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 
30 #ifndef xml_io_h
31 #define xml_io_h
32 
33 #include "absorption.h"
34 #include "artstime.h"
35 #include "mystring.h"
36 
37 enum FileType : Index {
41 };
42 
45 
47 // Default file names
49 
50 void filename_xml(String& filename, const String& varname);
51 
52 void filename_xml_with_index(String& filename,
53  const Index& file_index,
54  const String& varname,
55  const Index& digits = 0);
56 
58 // Generic IO routines for XML files
60 
61 template <typename T>
62 void xml_read_from_file(const String& filename,
63  T& type,
64  const Verbosity& verbosity);
65 
66 template <typename T>
67 void xml_write_to_file(const String& filename,
68  const T& type,
69  const FileType ftype,
70  const Index no_clobber,
71  const Verbosity& verbosity);
72 
73 template <typename T>
74 void xml_read_from_file(const String&, T&, const Verbosity&);
75 
76 template <typename T>
77 void xml_write_to_file(const String&, const T&, FileType, const Verbosity&);
78 
79 inline FileType string2filetype(const String& file_format)
80 {
81  if (file_format == "ascii")
82  return FILE_TYPE_ASCII;
83  else if (file_format == "zascii")
85  else if (file_format == "binary")
86  return FILE_TYPE_BINARY;
87  else
88  throw std::runtime_error(
89  "file_format contains illegal string. "
90  "Valid values are:\n"
91  " ascii: XML output\n"
92  " zascii: Zipped XML output\n"
93  " binary: XML + binary output");
94 }
95 
96 #endif
filename_xml_with_index
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:450
NumericType
NumericType
Definition: xml_io.h:43
FILE_TYPE_ASCII
@ FILE_TYPE_ASCII
Definition: xml_io.h:38
absorption.h
Declarations required for the calculation of absorption coefficients.
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
FileType
FileType
Definition: xml_io.h:37
xml_read_from_file
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Definition: xml_io.cc:901
artstime.h
Stuff related to time in ARTS.
NUMERIC_TYPE_DOUBLE
@ NUMERIC_TYPE_DOUBLE
Definition: xml_io.h:43
FILE_TYPE_BINARY
@ FILE_TYPE_BINARY
Definition: xml_io.h:40
my_basic_string< char >
FILE_TYPE_ZIPPED_ASCII
@ FILE_TYPE_ZIPPED_ASCII
Definition: xml_io.h:39
Verbosity
Definition: messages.h:49
xml_write_to_file
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.cc:972
ENDIAN_TYPE_LITTLE
@ ENDIAN_TYPE_LITTLE
Definition: xml_io.h:44
filename_xml
void filename_xml(String &filename, const String &varname)
Gives the default filename for the XML formats.
Definition: xml_io.cc:434
NUMERIC_TYPE_FLOAT
@ NUMERIC_TYPE_FLOAT
Definition: xml_io.h:43
ENDIAN_TYPE_BIG
@ ENDIAN_TYPE_BIG
Definition: xml_io.h:44
EndianType
EndianType
Definition: xml_io.h:44
ARTS::Var::file_index
Index file_index(Workspace &ws) noexcept
Definition: autoarts.h:3475
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
string2filetype
FileType string2filetype(const String &file_format)
Definition: xml_io.h:79
mystring.h
This file contains the definition of String, the ARTS string class.