From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/file_8h-source.html | 232 +++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 docs/doxygen/nel/file_8h-source.html (limited to 'docs/doxygen/nel/file_8h-source.html') diff --git a/docs/doxygen/nel/file_8h-source.html b/docs/doxygen/nel/file_8h-source.html new file mode 100644 index 00000000..968ae527 --- /dev/null +++ b/docs/doxygen/nel/file_8h-source.html @@ -0,0 +1,232 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

file.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_FILE_H
+00027 #define NL_FILE_H
+00028 
+00029 #include "nel/misc/stream.h"
+00030 
+00031 
+00032 
+00033 namespace NLMISC
+00034 {
+00035 
+00036 // ======================================================================================================
+00043 struct EFile : public EStream
+00044 {
+00045 public:
+00046         EFile () : EStream( "Unknown file error" ) {}
+00047         EFile (const std::string& filename) : EStream( "Unknown file error in '"+filename+"'" ) {}
+00048 };
+00049 
+00050 struct EFileNotOpened : public EFile
+00051 {
+00052         EFileNotOpened( const std::string& filename ) : EFile( "File '"+filename+"' not opened" ) {}
+00053 };
+00054 
+00055 struct EReadError : public EFile
+00056 {
+00057         EReadError( const std::string& filename ) : EFile( "Read error in file '" +filename+"' (End of file?)" ) {}
+00058 };
+00059 
+00060 struct EWriteError : public EFile
+00061 {
+00062         EWriteError( const std::string& filename ) : EFile( "Write Error in file '" +filename+"'" ) {}
+00063 };
+00064 
+00065 
+00066 // ======================================================================================================
+00073 class CIFile : public IStream
+00074 {
+00075 public:         // Basic Usage.
+00077         CIFile();
+00078         CIFile(const std::string &path, bool text=false);
+00079         ~CIFile();
+00080 
+00082         bool    open (const std::string &path, bool text=false);
+00083 
+00085         void    setCacheFileOnOpen (bool newState);
+00086 
+00090         void    allowBNPCacheFileOnOpen(bool newState);
+00091 
+00093         void    setAsyncLoading (bool newState);
+00094 
+00095 public:         // Advanced Usage.
+00097         void    close();
+00099         void    flush();
+00101         bool    seek (sint32 offset, IStream::TSeekOrigin origin) throw(EStream);
+00103         sint32  getPos () throw(EStream);
+00104 
+00105         // Imp the Name of the stream as the name of the file.
+00106         virtual std::string             getStreamName() const;
+00107 
+00108         // same function that in ifstream
+00109         // return a string separated by \n or eof, used to parsing text file
+00110         void getline (char *buffer, uint32 bufferSize);
+00111 
+00112         // return the size of the file
+00113         uint32 getFileSize () { return _FileSize; }
+00114 
+00115         // return true if there s nothing more to read (same as ifstream)
+00116         bool eof ();
+00117 
+00118         virtual void            serialBuffer(uint8 *buf, uint len)throw(EReadError);
+00119         
+00120 protected:
+00121         virtual void            serialBit(bool &bit) throw(EReadError);
+00122 
+00123 private:
+00124         FILE            *_F;
+00125         std::string _FileName;
+00126 
+00127         // Async
+00128         static uint32 _NbBytesSerialized;
+00129         static uint32 _NbBytesLoaded;
+00130         bool _IsAsyncLoading;
+00131 
+00132         // Cache 
+00133         bool    _CacheFileOnOpen;
+00134         bool    _AllowBNPCacheFileOnOpen;
+00135         uint8   *_Cache;
+00136         sint32  _ReadPos;
+00137         uint32  _FileSize;
+00138 
+00139         // Big file
+00140         bool    _AlwaysOpened;
+00141         bool    _IsInBigFile;
+00142         uint32  _BigFileOffset;
+00143 
+00144         // Load async if needed in the cache.
+00145         void    loadIntoCache();
+00146 };
+00147 
+00148 
+00149 // ======================================================================================================
+00156 class COFile : public IStream
+00157 {
+00158 public:         // Basic Usage.
+00160         COFile();
+00161         COFile(const std::string &path, bool append=false, bool text=false);
+00162         ~COFile();
+00163 
+00165         bool    open(const std::string &path, bool append=false, bool text=false);
+00166 
+00167         
+00168 public:         // Advanced Usage.
+00170         void    close();
+00172         void    flush();
+00174         bool    seek (sint32 offset, IStream::TSeekOrigin origin) throw(EStream);
+00176         sint32  getPos () throw(EStream);
+00177 
+00178         // Imp the Name of the stream as the name of the file.
+00179         virtual std::string             getStreamName() const;
+00180 
+00181         // very useful to serialize string in text mode (without the size)
+00182         virtual void            serialBuffer(uint8 *buf, uint len) throw(EWriteError);
+00183 
+00184 protected:
+00185         virtual void            serialBit(bool &bit) throw(EWriteError);
+00186 
+00187 private:
+00188         FILE    *_F;
+00189         std::string _FileName;
+00190 };
+00191 
+00192 
+00193 }
+00194 
+00195 
+00196 #endif // NL_FILE_H
+00197 
+00198 /* End of file.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1