reader.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:46:08 1999
00011 // commit: $Id: reader.h 10065 2007-04-12 05:54:56Z rjpeters $
00012 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/io/reader.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_READER_H_UTC20050626084021_DEFINED
00036 #define GROOVX_IO_READER_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 byte_array;
00046   class value;
00047 }
00048 
00049 namespace nub
00050 {
00051   template <class T> class ref;
00052   template <class T> class soft_ref;
00053 }
00054 
00056 
00068 
00069 
00070 class io::reader
00071 {
00072 public:
00073 
00075   virtual ~reader() throw();
00076 
00081   int ensure_version_id(const char* name,
00082                         io::version_id lowest_supported_version,
00083                         const char* msg,
00084                         const rutz::file_pos& pos);
00085 
00088   virtual io::version_id input_version_id() = 0;
00089 
00091   virtual char read_char(const rutz::fstring& name) = 0;
00092 
00094   virtual int read_int(const rutz::fstring& name) = 0;
00095 
00097   virtual bool read_bool(const rutz::fstring& name) = 0;
00098 
00100   virtual double read_double(const rutz::fstring& name) = 0;
00101 
00103   virtual void read_value_obj(const rutz::fstring& name,
00104                             rutz::value& v) = 0;
00105 
00107   virtual void read_byte_array(const rutz::fstring& name,
00108                            rutz::byte_array& data) = 0;
00109 
00118 
00119   void read_value(const rutz::fstring& name, char& ret)
00120   { ret = read_char(name); }
00121 
00122   void read_value(const rutz::fstring& name, int& ret)
00123   { ret = read_int(name); }
00124 
00125   void read_value(const rutz::fstring& name, unsigned int& ret)
00126   { ret = read_int(name); }
00127 
00128   void read_value(const rutz::fstring& name, unsigned long& ret)
00129   { ret = read_int(name); }
00130 
00131   void read_value(const rutz::fstring& name, bool& ret)
00132   { ret = read_bool(name); }
00133 
00134   void read_value(const rutz::fstring& name, double& ret)
00135   { ret = read_double(name); }
00136 
00137   void read_value(const rutz::fstring& name, rutz::fstring& ret)
00138   { ret = read_string_impl(name); }
00139 
00140   void read_value(const rutz::fstring& name, rutz::value& ret)
00141   { read_value_obj(name, ret); }
00142 
00144 
00148   virtual nub::ref<io::serializable> read_object(const rutz::fstring& name) = 0;
00149 
00154   virtual nub::soft_ref<io::serializable> read_weak_object(const rutz::fstring& name) = 0;
00155 
00159   virtual void read_owned_object(const rutz::fstring& name,
00160                                nub::ref<io::serializable> obj) = 0;
00161 
00167   virtual void read_base_class(const rutz::fstring& base_class_name,
00168                                nub::ref<io::serializable> base_part) = 0;
00169 
00175   virtual nub::ref<io::serializable> read_root(io::serializable* root=0) = 0;
00176 
00177 protected:
00179   virtual rutz::fstring read_string_impl(const rutz::fstring& name) = 0;
00180 
00182   void default_read_byte_array(const rutz::fstring& name, rutz::byte_array& data);
00183 };
00184 
00185 static const char __attribute__((used)) vcid_groovx_io_reader_h_utc20050626084021[] = "$Id: reader.h 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00186 #endif // !GROOVX_IO_READER_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.