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

FXMemoryStream.h

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,2004 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.3 2004/02/08 17:17:33 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 unsigned long writeBuffer(unsigned long count); 00038 virtual unsigned long readBuffer(unsigned long count); 00039 public: 00040 00041 /// Create memory store 00042 FXMemoryStream(const FXObject* cont=NULL); 00043 00044 /// Open file store 00045 FXbool open(FXStreamDirection save_or_load,FXuchar* data); 00046 00047 /// Open memory store 00048 FXbool open(FXStreamDirection save_or_load,unsigned long size,FXuchar* data); 00049 00050 /// Take buffer away from stream 00051 void takeBuffer(FXuchar*& data,unsigned long& size); 00052 00053 /// Give buffer to stream 00054 void giveBuffer(FXuchar *data,unsigned long size); 00055 00056 /// Close memory store 00057 virtual FXbool close(); 00058 00059 /// Move to position 00060 virtual FXbool position(long offset,FXWhence whence=FXFromStart); 00061 00062 /// Save single items to stream 00063 FXMemoryStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; } 00064 FXMemoryStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; } 00065 FXMemoryStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; } 00066 FXMemoryStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; } 00067 FXMemoryStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; } 00068 FXMemoryStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; } 00069 FXMemoryStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; } 00070 FXMemoryStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; } 00071 #ifdef FX_LONG 00072 FXMemoryStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; } 00073 FXMemoryStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; } 00074 #endif 00075 00076 /// Save arrays of items to stream 00077 FXMemoryStream& save(const FXuchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00078 FXMemoryStream& save(const FXchar* p,unsigned long n){ FXStream::save(p,n); return *this; } 00079 FXMemoryStream& save(const FXushort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00080 FXMemoryStream& save(const FXshort* p,unsigned long n){ FXStream::save(p,n); return *this; } 00081 FXMemoryStream& save(const FXuint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00082 FXMemoryStream& save(const FXint* p,unsigned long n){ FXStream::save(p,n); return *this; } 00083 FXMemoryStream& save(const FXfloat* p,unsigned long n){ FXStream::save(p,n); return *this; } 00084 FXMemoryStream& save(const FXdouble* p,unsigned long n){ FXStream::save(p,n); return *this; } 00085 #ifdef FX_LONG 00086 FXMemoryStream& save(const FXlong* p,unsigned long n){ FXStream::save(p,n); return *this; } 00087 FXMemoryStream& save(const FXulong* p,unsigned long n){ FXStream::save(p,n); return *this; } 00088 #endif 00089 00090 /// Load single items from stream 00091 FXMemoryStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; } 00092 FXMemoryStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; } 00093 FXMemoryStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; } 00094 FXMemoryStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; } 00095 FXMemoryStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; } 00096 FXMemoryStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; } 00097 FXMemoryStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; } 00098 FXMemoryStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; } 00099 #ifdef FX_LONG 00100 FXMemoryStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; } 00101 FXMemoryStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; } 00102 #endif 00103 00104 /// Load arrays of items from stream 00105 FXMemoryStream& load(FXuchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00106 FXMemoryStream& load(FXchar* p,unsigned long n){ FXStream::load(p,n); return *this; } 00107 FXMemoryStream& load(FXushort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00108 FXMemoryStream& load(FXshort* p,unsigned long n){ FXStream::load(p,n); return *this; } 00109 FXMemoryStream& load(FXuint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00110 FXMemoryStream& load(FXint* p,unsigned long n){ FXStream::load(p,n); return *this; } 00111 FXMemoryStream& load(FXfloat* p,unsigned long n){ FXStream::load(p,n); return *this; } 00112 FXMemoryStream& load(FXdouble* p,unsigned long n){ FXStream::load(p,n); return *this; } 00113 #ifdef FX_LONG 00114 FXMemoryStream& load(FXlong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00115 FXMemoryStream& load(FXulong* p,unsigned long n){ FXStream::load(p,n); return *this; } 00116 #endif 00117 00118 /// Save object 00119 FXMemoryStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; } 00120 00121 /// Load object 00122 FXMemoryStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; } 00123 }; 00124 00125 } 00126 00127 #endif

Copyright © 1997-2004 Jeroen van der Zijp