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

FXFileStream.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                       F i l e   S t r e a m   C l a s s                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2009 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (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                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 *********************************************************************************
00021 * $Id: FXFileStream.h,v 1.23 2009/01/06 13:07:24 fox Exp $                      *
00022 ********************************************************************************/
00023 #ifndef FXFILESTREAM_H
00024 #define FXFILESTREAM_H
00025 
00026 #ifndef FXSTREAM_H
00027 #include "FXStream.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 /// File Store Definition
00034 class FXAPI FXFileStream : public FXStream {
00035 protected:
00036   FXFile file;
00037 protected:
00038   virtual FXuval writeBuffer(FXuval count);
00039   virtual FXuval readBuffer(FXuval count);
00040 public:
00041 
00042   /// Create file stream
00043   FXFileStream(const FXObject* cont=NULL);
00044 
00045   /// Create and open file stream
00046   FXFileStream(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
00047 
00048   /**
00049   * Open binary data file stream; allocate a buffer of the given size
00050   * for the file I/O; the buffer must be at least 16 bytes.
00051   */
00052   FXbool open(const FXString& filename,FXStreamDirection save_or_load=FXStreamLoad,FXuval size=8192UL);
00053 
00054   /// Close file stream
00055   virtual FXbool close();
00056 
00057   /// Get position
00058   FXlong position() const { return FXStream::position(); }
00059 
00060   /// Move to position
00061   virtual FXbool position(FXlong offset,FXWhence whence=FXFromStart);
00062 
00063   /// Save single items to stream
00064   FXFileStream& operator<<(const FXuchar& v){ FXStream::operator<<(v); return *this; }
00065   FXFileStream& operator<<(const FXchar& v){ FXStream::operator<<(v); return *this; }
00066   FXFileStream& operator<<(const FXbool& v){ FXStream::operator<<(v); return *this; }
00067   FXFileStream& operator<<(const FXushort& v){ FXStream::operator<<(v); return *this; }
00068   FXFileStream& operator<<(const FXshort& v){ FXStream::operator<<(v); return *this; }
00069   FXFileStream& operator<<(const FXuint& v){ FXStream::operator<<(v); return *this; }
00070   FXFileStream& operator<<(const FXint& v){ FXStream::operator<<(v); return *this; }
00071   FXFileStream& operator<<(const FXfloat& v){ FXStream::operator<<(v); return *this; }
00072   FXFileStream& operator<<(const FXdouble& v){ FXStream::operator<<(v); return *this; }
00073   FXFileStream& operator<<(const FXlong& v){ FXStream::operator<<(v); return *this; }
00074   FXFileStream& operator<<(const FXulong& v){ FXStream::operator<<(v); return *this; }
00075 
00076   /// Save arrays of items to stream
00077   FXFileStream& save(const FXuchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00078   FXFileStream& save(const FXchar* p,FXuval n){ FXStream::save(p,n); return *this; }
00079   FXFileStream& save(const FXbool* p,FXuval n){ FXStream::save(p,n); return *this; }
00080   FXFileStream& save(const FXushort* p,FXuval n){ FXStream::save(p,n); return *this; }
00081   FXFileStream& save(const FXshort* p,FXuval n){ FXStream::save(p,n); return *this; }
00082   FXFileStream& save(const FXuint* p,FXuval n){ FXStream::save(p,n); return *this; }
00083   FXFileStream& save(const FXint* p,FXuval n){ FXStream::save(p,n); return *this; }
00084   FXFileStream& save(const FXfloat* p,FXuval n){ FXStream::save(p,n); return *this; }
00085   FXFileStream& save(const FXdouble* p,FXuval n){ FXStream::save(p,n); return *this; }
00086   FXFileStream& save(const FXlong* p,FXuval n){ FXStream::save(p,n); return *this; }
00087   FXFileStream& save(const FXulong* p,FXuval n){ FXStream::save(p,n); return *this; }
00088 
00089   /// Load single items from stream
00090   FXFileStream& operator>>(FXuchar& v){ FXStream::operator>>(v); return *this; }
00091   FXFileStream& operator>>(FXchar& v){ FXStream::operator>>(v); return *this; }
00092   FXFileStream& operator>>(FXbool& v){ FXStream::operator>>(v); return *this; }
00093   FXFileStream& operator>>(FXushort& v){ FXStream::operator>>(v); return *this; }
00094   FXFileStream& operator>>(FXshort& v){ FXStream::operator>>(v); return *this; }
00095   FXFileStream& operator>>(FXuint& v){ FXStream::operator>>(v); return *this; }
00096   FXFileStream& operator>>(FXint& v){ FXStream::operator>>(v); return *this; }
00097   FXFileStream& operator>>(FXfloat& v){ FXStream::operator>>(v); return *this; }
00098   FXFileStream& operator>>(FXdouble& v){ FXStream::operator>>(v); return *this; }
00099   FXFileStream& operator>>(FXlong& v){ FXStream::operator>>(v); return *this; }
00100   FXFileStream& operator>>(FXulong& v){ FXStream::operator>>(v); return *this; }
00101 
00102   /// Load arrays of items from stream
00103   FXFileStream& load(FXuchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00104   FXFileStream& load(FXchar* p,FXuval n){ FXStream::load(p,n); return *this; }
00105   FXFileStream& load(FXbool* p,FXuval n){ FXStream::load(p,n); return *this; }
00106   FXFileStream& load(FXushort* p,FXuval n){ FXStream::load(p,n); return *this; }
00107   FXFileStream& load(FXshort* p,FXuval n){ FXStream::load(p,n); return *this; }
00108   FXFileStream& load(FXuint* p,FXuval n){ FXStream::load(p,n); return *this; }
00109   FXFileStream& load(FXint* p,FXuval n){ FXStream::load(p,n); return *this; }
00110   FXFileStream& load(FXfloat* p,FXuval n){ FXStream::load(p,n); return *this; }
00111   FXFileStream& load(FXdouble* p,FXuval n){ FXStream::load(p,n); return *this; }
00112   FXFileStream& load(FXlong* p,FXuval n){ FXStream::load(p,n); return *this; }
00113   FXFileStream& load(FXulong* p,FXuval n){ FXStream::load(p,n); return *this; }
00114 
00115   /// Save object
00116   FXFileStream& saveObject(const FXObject* v){ FXStream::saveObject(v); return *this; }
00117 
00118   /// Load object
00119   FXFileStream& loadObject(FXObject*& v){ FXStream::loadObject(v); return *this; }
00120 
00121   /// Destructor
00122   virtual ~FXFileStream();
00123   };
00124 
00125 }
00126 
00127 #endif

Copyright © 1997-2009 Jeroen van der Zijp