writer.h

Go to the documentation of this file.
00001 
00004 
00005 //
00006 // Copyright (c) 1999-2004 California Institute of Technology
00007 // Copyright (c) 2004-2007 University of Southern California
00008 // Rob Peters <rjpeters at usc dot edu>
00009 //
00010 // created: Mon Jun  7 12:49:49 1999
00011 // commit: $Id: writer.h 10065 2007-04-12 05:54:56Z rjpeters $
00012 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/io/writer.h $
00013 //
00014 // --------------------------------------------------------------------
00015 //
00016 // This file is part of GroovX.
00017 //   [http://ilab.usc.edu/rjpeters/groovx/]
00018 //
00019 // GroovX is free software; you can redistribute it and/or modify it
00020 // under the terms of the GNU General Public License as published by
00021 // the Free Software Foundation; either version 2 of the License, or
00022 // (at your option) any later version.
00023 //
00024 // GroovX is distributed in the hope that it will be useful, but
00025 // WITHOUT ANY WARRANTY; without even the implied warranty of
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027 // General Public License for more details.
00028 //
00029 // You should have received a copy of the GNU General Public License
00030 // along with GroovX; if not, write to the Free Software Foundation,
00031 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:39 2008 by Doxygen version 1.5.5.