ARTS  2.3.1285(git:92a29ea9-dirty)
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
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
FileType
Definition: xml_io.h:37
void xml_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads data from XML file.
Definition: xml_io.cc:901
void filename_xml(String &filename, const String &varname)
Gives the default filename for the XML formats.
Definition: xml_io.cc:434
Declarations required for the calculation of absorption coefficients.
Stuff related to time in ARTS.
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
EndianType
Definition: xml_io.h:44
NumericType
Definition: xml_io.h:43
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
This file contains the definition of String, the ARTS string class.
FileType string2filetype(const String &file_format)
Definition: xml_io.h:79