00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00027 #ifndef m_xml_h
00028 #define m_xml_h
00029
00030 #include "exceptions.h"
00031 #include "xml_io.h"
00032 #include "workspace_ng.h"
00033 #include "agenda_class.h"
00034
00035
00036 template<typename T> void
00037 ReadXML (
00038 T& v,
00039
00040 const String& v_name,
00041
00042 const String& f,
00043
00044 const String& f_name _U_)
00045 {
00046 String filename = f;
00047
00048
00049 filename_xml (filename, v_name);
00050
00051 xml_read_from_file (filename, v);
00052 }
00053
00054
00055
00056 void
00057 ReadXML (Workspace& ws _U_,
00058
00059 Agenda& v,
00060
00061 const String& v_name,
00062
00063 const String& f,
00064
00065 const String& f_name)
00066 {
00067 ReadXML (v, v_name, f, f_name);
00068 }
00069
00070
00071
00072 template<typename T> void
00073 WriteXML (
00074 const String& file_format,
00075
00076 const T& v,
00077 const String& f,
00078
00079 const String& v_name,
00080 const String& f_name _U_)
00081
00082 {
00083 String filename = f;
00084 FileType ftype;
00085
00086
00087 filename_xml (filename, v_name);
00088
00089 if (file_format == "ascii")
00090 ftype = FILE_TYPE_ASCII;
00091 else if (file_format == "zascii")
00092 ftype = FILE_TYPE_ZIPPED_ASCII;
00093 else if (file_format == "binary")
00094 ftype = FILE_TYPE_BINARY;
00095 else
00096 throw runtime_error ("file_format contains illegal string. "
00097 "Valid values are:\n"
00098 " ascii: XML output\n"
00099 " zascii: Zipped XML output\n"
00100 " binary: XML + binary output");
00101
00102 xml_write_to_file (filename, v, ftype);
00103 }
00104
00105
00106
00107 void
00108 WriteXML (Workspace& ws _U_,
00109
00110 const String& file_format,
00111
00112 const Agenda& v,
00113 const String& f,
00114
00115 const String& v_name,
00116 const String& f_name)
00117 {
00118 WriteXML (file_format, v, f, v_name, f_name);
00119 }
00120
00121
00122
00123 template<typename T> void
00124 WriteXMLIndexed (
00125 const String& file_format,
00126 const Index& file_index,
00127
00128 const T& v,
00129 const String& f,
00130
00131 const String& v_name,
00132 const String& f_name _U_)
00133 {
00134 String filename = f;
00135
00136
00137 filename_xml_with_index( filename, file_index, v_name );
00138
00139 WriteXML( file_format, v, filename, v_name, f_name );
00140 }
00141
00142
00143
00144 void
00145 WriteXMLIndexed (Workspace& ws _U_,
00146
00147 const String& file_format,
00148 const Index& file_index,
00149
00150 const Agenda& v,
00151 const String& f,
00152
00153 const String& v_name,
00154 const String& f_name)
00155 {
00156 WriteXMLIndexed (file_format, file_index, v, f, v_name, f_name);
00157 }
00158
00159
00160
00161 void
00162 output_file_formatSetAscii (
00163 String& file_format)
00164 {
00165 file_format = "ascii";
00166 }
00167
00168
00169
00170 void
00171 output_file_formatSetZippedAscii (
00172 String& file_format)
00173 {
00174 file_format = "zascii";
00175 }
00176
00177
00178
00179 void
00180 output_file_formatSetBinary (
00181 String& file_format)
00182 {
00183 file_format = "binary";
00184 }
00185
00186
00187 #endif // m_xml_h
00188