Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXMemoryStream.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                   M e m o r y   S t r e a m   C l a s s e s                   *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXMemoryStream.h,v 1.11 2006/01/22 17:58:06 fox Exp $                    *
00023 ********************************************************************************/
00024 #ifndef FXMEMORYSTREAM_H
00025 #define FXMEMORYSTREAM_H
00026 
00027 #ifndef FXSTREAM_H
00028 #include "FXStream.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Memory Store Definition
00035 class FXAPI FXMemoryStream : public FXStream {
00036 protected:
00037   virtual FXuval writeBuffer(FXuval count);
00038   virtual FXuval readBuffer(FXuval count);
00039 public:
00040 
00041   /// Create memory store
00042   FXMemoryStream(const FXObject* cont=NULL);
00043 
00044   /// Open file store
00045   bool open(FXStreamDirection save_or_load,FXuchar* data);
00046 
00047   /// Open memory store
00048   bool open(FXStreamDirection save_or_load,FXuval size,FXuchar* data);
00049 
00050   /// Take buffer away from stream
00051   void takeBuffer(FXuchar*& data,FXuval& size);
00052 
00053   /// Give buffer to stream
00054   void giveBuffer(FXuchar *data,FXuval size);
00055 
00056   /// Close memory store
00057   virtual bool close();
00058 
00059   /// Get position
00060   FXlong position() const { return FXStream::position(); }
00061 
00062   /// Move to position
00063   virtual bool position(FXlong offset,FXWhence whence=FXFromStart);
00064 
00065   /// Save single items to stream
00066   FXMemoryStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
00067   FXMemoryStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
00068   FXMemoryStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
00069   FXMemoryStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
00070   FXMemoryStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
00071   FXMemoryStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
00072   FXMemoryStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
00073   FXMemoryStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
00074   FXMemoryStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
00075   FXMemoryStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
00076 
00077   /// Save arrays of items to stream
00078   FXMemoryStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00079   FXMemoryStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00080   FXMemoryStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
00081   FXMemoryStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
00082   FXMemoryStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
00083   FXMemoryStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
00084   FXMemoryStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
00085   FXMemoryStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
00086   FXMemoryStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
00087   FXMemoryStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
00088 
00089   /// Load single items from stream
00090   FXMemoryStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
00091   FXMemoryStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
00092   FXMemoryStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
00093   FXMemoryStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
00094   FXMemoryStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
00095   FXMemoryStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
00096   FXMemoryStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
00097   FXMemoryStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
00098   FXMemoryStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
00099   FXMemoryStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
00100 
00101   /// Load arrays of items from stream
00102   FXMemoryStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00103   FXMemoryStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00104   FXMemoryStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
00105   FXMemoryStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
00106   FXMemoryStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
00107   FXMemoryStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
00108   FXMemoryStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
00109   FXMemoryStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
00110   FXMemoryStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
00111   FXMemoryStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
00112 
00113   /// Save object
00114   FXMemoryStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
00115 
00116   /// Load object
00117   FXMemoryStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
00118   };
00119 
00120 }
00121 
00122 #endif

Copyright © 1997-2005 Jeroen van der Zijp