ioutil.cc

Go to the documentation of this file.
00001 
00003 
00004 //
00005 // Copyright (c) 1999-2004 California Institute of Technology
00006 // Copyright (c) 2004-2007 University of Southern California
00007 // Rob Peters <rjpeters at usc dot edu>
00008 //
00009 // created: Fri Jun 11 21:43:28 1999
00010 // commit: $Id: ioutil.cc 10065 2007-04-12 05:54:56Z rjpeters $
00011 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/io/ioutil.cc $
00012 //
00013 // --------------------------------------------------------------------
00014 //
00015 // This file is part of GroovX.
00016 //   [http://ilab.usc.edu/rjpeters/groovx/]
00017 //
00018 // GroovX is free software; you can redistribute it and/or modify it
00019 // under the terms of the GNU General Public License as published by
00020 // the Free Software Foundation; either version 2 of the License, or
00021 // (at your option) any later version.
00022 //
00023 // GroovX is distributed in the hope that it will be useful, but
00024 // WITHOUT ANY WARRANTY; without even the implied warranty of
00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00026 // General Public License for more details.
00027 //
00028 // You should have received a copy of the GNU General Public License
00029 // along with GroovX; if not, write to the Free Software Foundation,
00030 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00031 //
00033 
00034 #ifndef GROOVX_IO_IOUTIL_CC_UTC20050626084021_DEFINED
00035 #define GROOVX_IO_IOUTIL_CC_UTC20050626084021_DEFINED
00036 
00037 #include "io/ioutil.h"
00038 
00039 #include "io/asciistreamreader.h"
00040 #include "io/asciistreamwriter.h"
00041 #include "io/io.h"
00042 #include "io/iolegacy.h"
00043 #include "io/xmlwriter.h"
00044 
00045 #include "nub/ref.h"
00046 
00047 #include "rutz/cstrstream.h"
00048 #include "rutz/error.h"
00049 #include "rutz/fstring.h"
00050 #include "rutz/shared_ptr.h"
00051 
00052 #include <iostream>
00053 #include <sstream>
00054 
00055 #include "rutz/trace.h"
00056 #include "rutz/debug.h"
00057 GVX_DBG_REGISTER
00058 
00059 using rutz::fstring;
00060 using rutz::shared_ptr;
00061 
00062 fstring io::write_lgx(nub::ref<io::serializable> obj)
00063 {
00064   std::ostringstream ost;
00065 
00066   io::legacy_writer writer(ost);
00067   writer.write_root(obj.get());
00068 
00069   return fstring(ost.str().c_str());
00070 }
00071 
00072 void io::read_lgx(nub::ref<io::serializable> obj, const char* buf)
00073 {
00074   rutz::icstrstream ist(buf);
00075 
00076   io::legacy_reader reader(ist);
00077   reader.read_root(obj.get());
00078 }
00079 
00080 fstring io::write_asw(nub::ref<io::serializable> obj)
00081 {
00082   std::ostringstream ost;
00083 
00084   shared_ptr<io::writer> writer = io::make_asw_writer(ost);
00085   writer->write_root(obj.get());
00086 
00087   return fstring(ost.str().c_str());
00088 }
00089 
00090 void io::read_asw(nub::ref<io::serializable> obj, const char* buf)
00091 {
00092   rutz::icstrstream ist(buf);
00093 
00094   shared_ptr<io::reader> reader = io::make_asw_reader(ist);
00095   reader->read_root(obj.get());
00096 }
00097 
00098 fstring io::write_gvx(nub::ref<io::serializable> obj)
00099 {
00100   std::ostringstream ost;
00101 
00102   shared_ptr<io::writer> writer = io::make_xml_writer(ost);
00103   writer->write_root(obj.get());
00104 
00105   return fstring(ost.str().c_str());
00106 }
00107 
00108 void io::save_asw(nub::ref<io::serializable> obj, fstring fname)
00109 {
00110   shared_ptr<io::writer> writer = io::make_asw_writer(fname.c_str());
00111   writer->write_root(obj.get());
00112 }
00113 
00114 void io::load_asw(nub::ref<io::serializable> obj, fstring fname)
00115 {
00116   shared_ptr<io::reader> reader = io::make_asw_reader(fname.c_str());
00117   reader->read_root(obj.get());
00118 }
00119 
00120 void io::save_gvx(nub::ref<io::serializable> obj, fstring filename)
00121 {
00122   shared_ptr<io::writer> writer = io::make_xml_writer(filename.c_str());
00123   writer->write_root(obj.get());
00124 }
00125 
00126 nub::ref<io::serializable> io::retrieve_asw(fstring fname)
00127 {
00128   shared_ptr<io::reader> reader = io::make_asw_reader(fname.c_str());
00129   return reader->read_root();
00130 }
00131 
00132 static const char __attribute__((used)) vcid_groovx_io_ioutil_cc_utc20050626084021[] = "$Id: ioutil.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00133 #endif // !GROOVX_IO_IOUTIL_CC_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.