00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00034
00035 #ifndef GROOVX_IO_WRITER_H_UTC20050626084021_DEFINED
00036 #define GROOVX_IO_WRITER_H_UTC20050626084021_DEFINED
00037
00038 #include "io/io.h"
00039
00040 #include "rutz/fileposition.h"
00041 #include "rutz/fstring.h"
00042
00043 namespace rutz
00044 {
00045 class value;
00046 }
00047
00048 namespace nub
00049 {
00050 template <class T> class ref;
00051 template <class T> class soft_ref;
00052 }
00053
00055
00067
00068
00069 class io::writer
00070 {
00071 public:
00072
00074 virtual ~writer() throw();
00075
00080 int ensure_output_version_id(const char* name,
00081 io::version_id actual_version,
00082 io::version_id lowest_supported_version,
00083 const char* msg,
00084 const rutz::file_pos& pos);
00085
00087 virtual void write_char(const char* name, char val) = 0;
00088
00090 virtual void write_int(const char* name, int val) = 0;
00091
00093 virtual void write_bool(const char* name, bool val) = 0;
00094
00096 virtual void write_double(const char* name, double val) = 0;
00097
00099 virtual void write_value_obj(const char* name, const rutz::value& v) = 0;
00100
00102 virtual void write_byte_array(const char* name,
00103 const unsigned char* data,
00104 unsigned int length) = 0;
00105
00114
00115 void write_value(const char* name, char val)
00116 { write_char(name, val); }
00117
00118 void write_value(const char* name, int val)
00119 { write_int(name, val); }
00120
00121 void write_value(const char* name, unsigned int val)
00122 { write_int(name, val); }
00123
00124 void write_value(const char* name, unsigned long val)
00125 { write_int(name, val); }
00126
00127 void write_value(const char* name, bool val)
00128 { write_bool(name, val); }
00129
00130 void write_value(const char* name, double val)
00131 { write_double(name, val); }
00132
00133 void write_value(const char* name, const rutz::fstring& val)
00134 { write_cstring(name, val.c_str()); }
00135
00136 void write_value(const char* name, const rutz::value& v)
00137 { write_value_obj(name, v); }
00138
00140
00142 virtual void write_object(const char* name,
00143 nub::soft_ref<const io::serializable> obj) = 0;
00144
00150 virtual void write_owned_object(const char* name,
00151 nub::ref<const io::serializable> obj) = 0;
00152
00158 virtual void write_base_class(const char* base_class_name,
00159 nub::ref<const io::serializable> base_part) = 0;
00160
00165 virtual void write_root(const io::serializable* root) = 0;
00166
00167 protected:
00169 virtual void write_cstring(const char* name, const char* val) = 0;
00170
00171
00173 void default_write_byte_array(const char* name,
00174 const unsigned char* data,
00175 unsigned int length);
00176 };
00177
00178 static const char __attribute__((used)) vcid_groovx_io_writer_h_utc20050626084021[] = "$Id: writer.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00179 #endif // !GROOVX_IO_WRITER_H_UTC20050626084021_DEFINED