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

FXFileStream.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                       F i l e   S t r e a m   C l a s 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: FXFileStream.h,v 1.5 2004/02/08 17:17:33 fox Exp $                       *
00023 ********************************************************************************/
00024 #ifndef FXFILESTREAM_H
00025 #define FXFILESTREAM_H
00026 
00027 #ifndef FXSTREAM_H
00028 #include "FXStream.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// File Store Definition
00035 class FXAPI FXFileStream : public FXStream {
00036 private:
00037   FXint file;
00038 protected:
00039   virtual unsigned long writeBuffer(unsigned long count);
00040   virtual unsigned long readBuffer(unsigned long count);
00041 public:
00042 
00043   /// Create file store
00044   FXFileStream(const FXObject* cont=NULL);
00045 
00046   /**
00047   * Open binary data file stream; allocate a buffer of the given size
00048   * for the file I/O; the buffer must be at least 16 bytes.
00049   */
00050   FXbool open(const FXString& filename,FXStreamDirection save_or_load,unsigned long size=8192);
00051 
00052   /// Close file store
00053   virtual FXbool close();
00054 
00055   /// Move to position
00056   virtual FXbool position(long offset,FXWhence whence=FXFromStart);
00057 
00058   /// Save single items to stream
00059   FXFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
00060   FXFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
00061   FXFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
00062   FXFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
00063   FXFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
00064   FXFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
00065   FXFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
00066   FXFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
00067 #ifdef FX_LONG
00068   FXFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
00069   FXFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
00070 #endif
00071 
00072   /// Save arrays of items to stream
00073   FXFileStream& save(const FXuchar* p,unsigned long n){ FXStream::save(p,n); return *this; }
00074   FXFileStream& save(const FXchar* p,unsigned long n){ FXStream::save(p,n); return *this; }
00075   FXFileStream& save(const FXushort* p,unsigned long n){ FXStream::save(p,n); return *this; }
00076   FXFileStream& save(const FXshort* p,unsigned long n){ FXStream::save(p,n); return *this; }
00077   FXFileStream& save(const FXuint* p,unsigned long n){ FXStream::save(p,n); return *this; }
00078   FXFileStream& save(const FXint* p,unsigned long n){ FXStream::save(p,n); return *this; }
00079   FXFileStream& save(const FXfloat* p,unsigned long n){ FXStream::save(p,n); return *this; }
00080   FXFileStream& save(const FXdouble* p,unsigned long n){ FXStream::save(p,n); return *this; }
00081 #ifdef FX_LONG
00082   FXFileStream& save(const FXlong* p,unsigned long n){ FXStream::save(p,n); return *this; }
00083   FXFileStream& save(const FXulong* p,unsigned long n){ FXStream::save(p,n); return *this; }
00084 #endif
00085 
00086   /// Load single items from stream
00087   FXFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
00088   FXFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
00089   FXFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
00090   FXFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
00091   FXFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
00092   FXFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
00093   FXFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
00094   FXFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
00095 #ifdef FX_LONG
00096   FXFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
00097   FXFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
00098 #endif
00099 
00100   /// Load arrays of items from stream
00101   FXFileStream& load(FXuchar* p,unsigned long n){ FXStream::load(p,n); return *this; }
00102   FXFileStream& load(FXchar* p,unsigned long n){ FXStream::load(p,n); return *this; }
00103   FXFileStream& load(FXushort* p,unsigned long n){ FXStream::load(p,n); return *this; }
00104   FXFileStream& load(FXshort* p,unsigned long n){ FXStream::load(p,n); return *this; }
00105   FXFileStream& load(FXuint* p,unsigned long n){ FXStream::load(p,n); return *this; }
00106   FXFileStream& load(FXint* p,unsigned long n){ FXStream::load(p,n); return *this; }
00107   FXFileStream& load(FXfloat* p,unsigned long n){ FXStream::load(p,n); return *this; }
00108   FXFileStream& load(FXdouble* p,unsigned long n){ FXStream::load(p,n); return *this; }
00109 #ifdef FX_LONG
00110   FXFileStream& load(FXlong* p,unsigned long n){ FXStream::load(p,n); return *this; }
00111   FXFileStream& load(FXulong* p,unsigned long n){ FXStream::load(p,n); return *this; }
00112 #endif
00113 
00114   /// Save object
00115   FXFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
00116 
00117   /// Load object
00118   FXFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
00119 
00120   /// Destructor
00121   virtual ~FXFileStream();
00122   };
00123 
00124 }
00125 
00126 #endif

Copyright © 1997-2004 Jeroen van der Zijp