# 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  

NLMISC::CIFile Class Reference

Input File. More...

#include <file.h>

Inheritance diagram for NLMISC::CIFile:

NLMISC::IStream List of all members.

Public Methods

 CIFile ()
 Object. NB: destructor close() the stream. More...

 CIFile (const std::string &path, bool text=false)
 ~CIFile ()
bool open (const std::string &path, bool text=false)
 Open a file for reading. false if failed. close() if a file was opened. More...

void setCacheFileOnOpen (bool newState)
 Set the cache file on open option (default behaviour is false (file is not cached at opening). More...

void allowBNPCacheFileOnOpen (bool newState)
 If the file is opened with a big file, CacheFileOnOpen is replaced with big file option. More...

void setAsyncLoading (bool newState)
 Set the async loading state (to go to sleep 5 ms after 100 Ko serialized). More...

void close ()
 Explicit close. More...

void flush ()
 flush the file. More...

bool seek (sint32 offset, IStream::TSeekOrigin origin) throw (EStream)
 Seek the file. More...

sint32 getPos () throw (EStream)
 Gt the location of the file pointer. More...

virtual std::string getStreamName () const
 Get a name for this stream. More...

void getline (char *buffer, uint32 bufferSize)
uint32 getFileSize ()
bool eof ()
virtual void serialBuffer (uint8 *buf, uint len) throw (EReadError)
 Method to be specified by the Deriver. More...


Protected Methods

virtual void serialBit (bool &bit) throw (EReadError)

Private Methods

void loadIntoCache ()

Private Attributes

FILE * _F
std::string _FileName
bool _IsAsyncLoading
bool _CacheFileOnOpen
bool _AllowBNPCacheFileOnOpen
uint8_Cache
sint32 _ReadPos
uint32 _FileSize
bool _AlwaysOpened
bool _IsInBigFile
uint32 _BigFileOffset

Static Private Attributes

uint32 _NbBytesSerialized = 0
uint32 _NbBytesLoaded = 0

Detailed Description

Input File.

Author:
Lionel Berenguier , Nevrax France
Date:
2000

Definition at line 73 of file file.h.


Constructor & Destructor Documentation

NLMISC::CIFile::CIFile  
 

Object. NB: destructor close() the stream.

Definition at line 41 of file file.cpp.

References _AllowBNPCacheFileOnOpen, _BigFileOffset, _Cache, _CacheFileOnOpen, _F, _FileSize, _IsAsyncLoading, _IsInBigFile, and _ReadPos.

NLMISC::CIFile::CIFile const std::string &    path,
bool    text = false
 

Definition at line 55 of file file.cpp.

References _AllowBNPCacheFileOnOpen, _BigFileOffset, _Cache, _CacheFileOnOpen, _F, _FileSize, _IsAsyncLoading, _IsInBigFile, _ReadPos, and open.

NLMISC::CIFile::~CIFile  
 

Definition at line 70 of file file.cpp.

References close.


Member Function Documentation

void NLMISC::CIFile::allowBNPCacheFileOnOpen bool    newState
 

If the file is opened with a big file, CacheFileOnOpen is replaced with big file option.

Except if allowBNPCacheFileOnOpen(false) is called. true is default.

Definition at line 395 of file file.cpp.

References _AllowBNPCacheFileOnOpen.

Referenced by NL3D::CTextureFile::buildBitmapFromFile.

void NLMISC::CIFile::close  
 

Explicit close.

Definition at line 209 of file file.cpp.

References _AlwaysOpened, _Cache, _F, and NLMISC::IStream::resetPtrTable.

Referenced by NLPACS::CRetrieverBank::addRetriever, loadForm, NL3D::CAnimationSet::loadFromFiles, open, and ~CIFile.

bool NLMISC::CIFile::eof  
 

Definition at line 300 of file file.cpp.

References _FileSize, and _ReadPos.

void NLMISC::CIFile::flush  
 

flush the file.

Definition at line 245 of file file.cpp.

References _F.

uint32 NLMISC::CIFile::getFileSize   [inline]
 

Definition at line 113 of file file.h.

References _FileSize.

void NLMISC::CIFile::getline char *    buffer,
uint32    bufferSize
 

Definition at line 260 of file file.cpp.

References serialBuffer.

sint32 NLMISC::CIFile::getPos   throw (EStream) [virtual]
 

Gt the location of the file pointer.

Reimplemented from NLMISC::IStream.

Definition at line 381 of file file.cpp.

std::string NLMISC::CIFile::getStreamName   const [virtual]
 

Get a name for this stream.

maybe a fileName if FileStream. Default is to return "".

Reimplemented from NLMISC::IStream.

Definition at line 388 of file file.cpp.

References _FileName.

void NLMISC::CIFile::loadIntoCache   [private]
 

Definition at line 77 of file file.cpp.

References _Cache, _F, _FileSize, _IsAsyncLoading, _NbBytesLoaded, index, and NLMISC::nlSleep.

Referenced by open.

bool NLMISC::CIFile::open const std::string &    path,
bool    text = false
 

Open a file for reading. false if failed. close() if a file was opened.

Definition at line 115 of file file.cpp.

References _AlwaysOpened, _BigFileOffset, _Cache, _CacheFileOnOpen, _F, _FileName, _FileSize, _IsInBigFile, _ReadPos, close, and loadIntoCache.

Referenced by NL3D::CAnimationSetUser::addAnimation, NLPACS::CRetrieverBank::addRetriever, NL3D::CAnimationSetUser::addSkeletonWeight, NL3D::CTextureFile::buildBitmapFromFile, CIFile, NL3D::UAnimation::createAnimation, NL3D::CSceneUser::createAnimationSet, loadForm, and NL3D::CAnimationSet::loadFromFiles.

bool NLMISC::CIFile::seek sint32    offset,
IStream::TSeekOrigin    origin
throw (EStream)
 

Seek the file.

Definition at line 349 of file file.cpp.

References nlstop, and offset.

void NLMISC::CIFile::serialBit bool &    bit throw (EReadError) [protected, virtual]
 

Implements NLMISC::IStream.

Definition at line 340 of file file.cpp.

References v.

void NLMISC::CIFile::serialBuffer uint8   buf,
uint    len
throw (EReadError) [virtual]
 

Method to be specified by the Deriver.

Warning:
Do not call these methods from outside, unless you really know what you are doing. Using them instead of serial() can lead to communication problems between different platforms !

Implements NLMISC::IStream.

Definition at line 306 of file file.cpp.

References NLMISC::nlSleep.

Referenced by getline.

void NLMISC::CIFile::setAsyncLoading bool    newState
 

Set the async loading state (to go to sleep 5 ms after 100 Ko serialized).

Definition at line 202 of file file.cpp.

References _IsAsyncLoading.

Referenced by NL3D::CTextureFile::buildBitmapFromFile.

void NLMISC::CIFile::setCacheFileOnOpen bool    newState
 

Set the cache file on open option (default behaviour is false (file is not cached at opening).

Definition at line 196 of file file.cpp.

References _CacheFileOnOpen.

Referenced by NL3D::CTextureFile::buildBitmapFromFile, and loadForm.


Member Data Documentation

bool NLMISC::CIFile::_AllowBNPCacheFileOnOpen [private]
 

Definition at line 134 of file file.h.

Referenced by allowBNPCacheFileOnOpen, and CIFile.

bool NLMISC::CIFile::_AlwaysOpened [private]
 

Definition at line 140 of file file.h.

Referenced by close, and open.

uint32 NLMISC::CIFile::_BigFileOffset [private]
 

Definition at line 142 of file file.h.

Referenced by CIFile, and open.

uint8* NLMISC::CIFile::_Cache [private]
 

Definition at line 135 of file file.h.

Referenced by CIFile, close, loadIntoCache, and open.

bool NLMISC::CIFile::_CacheFileOnOpen [private]
 

Definition at line 133 of file file.h.

Referenced by CIFile, open, and setCacheFileOnOpen.

FILE* NLMISC::CIFile::_F [private]
 

Definition at line 124 of file file.h.

Referenced by CIFile, close, flush, loadIntoCache, and open.

std::string NLMISC::CIFile::_FileName [private]
 

Definition at line 125 of file file.h.

Referenced by getStreamName, and open.

uint32 NLMISC::CIFile::_FileSize [private]
 

Definition at line 137 of file file.h.

Referenced by CIFile, eof, getFileSize, loadIntoCache, and open.

bool NLMISC::CIFile::_IsAsyncLoading [private]
 

Definition at line 130 of file file.h.

Referenced by CIFile, loadIntoCache, and setAsyncLoading.

bool NLMISC::CIFile::_IsInBigFile [private]
 

Definition at line 141 of file file.h.

Referenced by CIFile, and open.

uint32 NLMISC::CIFile::_NbBytesLoaded = 0 [static, private]
 

Definition at line 38 of file file.cpp.

Referenced by loadIntoCache.

uint32 NLMISC::CIFile::_NbBytesSerialized = 0 [static, private]
 

Definition at line 37 of file file.cpp.

sint32 NLMISC::CIFile::_ReadPos [private]
 

Definition at line 136 of file file.h.

Referenced by CIFile, eof, and open.


The documentation for this class was generated from the following files: