Version: 8.3.0
SMESH_File Class Reference

High level util for effective file reading and other file operations. More...

#include <SMESH_File.hxx>

Public Member Functions

 SMESH_File (const std::string &name, bool openForReading=true)
 Creator opening the file for reading by default. More...
 
 ~SMESH_File ()
 Destructor closing the file. More...
 
std::string getName () const
 
const std::string & error () const
 
void close ()
 Close the file. More...
 
bool remove ()
 Remove the file. More...
 
long size ()
 Return file size. More...
 
bool exists ()
 Check existence. More...
 
bool isDirectory ()
 Check existence. More...
 
bool open ()
 Open file for reading. More...
 
 operator const char * () const
 
bool operator++ ()
 
void operator+= (int posDelta)
 
bool eof () const
 
const char * end () const
 
const char * getPos () const
 
void setPos (const char *pos)
 Set cursor to the given position. More...
 
std::string getLine ()
 Skip till current line end and return the skipped string. More...
 
void rewind ()
 Move cursor to the file beginning. More...
 
bool getInts (std::vector< int > &ids)
 Fill vector by reading out integers from file. More...
 
bool openForWriting ()
 Open for binary writing only. More...
 
template<typename T >
bool write (const T *values, size_t nbTValues)
 
template<typename T >
bool write (const T &value)
 
bool writeRaw (const void *data, size_t size)
 Write binary data. More...
 

Private Attributes

std::string _name
 file name More...
 
long _size
 file size More...
 
std::string _error
 
int _file
 
void * _map
 
const char * _pos
 current position More...
 
const char * _end
 position after file end More...
 

Detailed Description

High level util for effective file reading and other file operations.

Constructor & Destructor Documentation

SMESH_File::SMESH_File ( const std::string &  name,
bool  openForReading = true 
)

Creator opening the file for reading by default.

References open().

SMESH_File::~SMESH_File ( )

Destructor closing the file.

References close().

Member Function Documentation

void SMESH_File::close ( )

Close the file.

References _end, _file, _map, _pos, and _size.

Referenced by open(), DriverSTL_R_SMDS_Mesh::readAscii(), remove(), and ~SMESH_File().

const char* SMESH_File::end ( ) const
bool SMESH_File::eof ( ) const

Referenced by getInts(), and getLine().

const std::string& SMESH_File::error ( ) const
bool SMESH_File::exists ( )

Check existence.

References _error, and _name.

Referenced by SMESH_Mesh_i::PrepareForWriting().

bool SMESH_File::getInts ( std::vector< int > &  ints)

Fill vector by reading out integers from file.

Vector size gives number of integers to read

References _pos, and eof().

std::string SMESH_File::getLine ( )

Skip till current line end and return the skipped string.

References _pos, and eof().

std::string SMESH_File::getName ( ) const
const char* SMESH_File::getPos ( ) const
bool SMESH_File::isDirectory ( )

Check existence.

References _error, and _name.

Referenced by SMESH_Mesh_i::PrepareForWriting().

bool SMESH_File::open ( )

Open file for reading.

Return true if there is something to read

References _end, _error, _file, _map, _name, _pos, _size, close(), and size().

Referenced by openForWriting(), DriverSTL_R_SMDS_Mesh::Perform(), and SMESH_File().

bool SMESH_File::openForWriting ( )
SMESH_File::operator const char * ( ) const
bool SMESH_File::operator++ ( )
void SMESH_File::operator+= ( int  posDelta)
bool SMESH_File::remove ( )

Remove the file.

References _error, _name, and close().

Referenced by SMESH_Mesh_i::PrepareForWriting().

void SMESH_File::rewind ( )

Move cursor to the file beginning.

References _map, and _pos.

void SMESH_File::setPos ( const char *  pos)

Set cursor to the given position.

References _end, _map, and _pos.

long SMESH_File::size ( )
template<typename T >
bool SMESH_File::write ( const T *  values,
size_t  nbTValues 
)
template<typename T >
bool SMESH_File::write ( const T &  value)
bool SMESH_File::writeRaw ( const void *  data,
size_t  size 
)

Write binary data.

References _file, and write().

Referenced by DriverSTL_W_SMDS_Mesh::writeAscii(), and DriverSTL_W_SMDS_Mesh::writeBinary().

Field Documentation

const char* SMESH_File::_end
private

position after file end

Referenced by close(), open(), and setPos().

std::string SMESH_File::_error
private

Referenced by exists(), isDirectory(), open(), remove(), and size().

int SMESH_File::_file
private

Referenced by close(), open(), openForWriting(), and writeRaw().

void* SMESH_File::_map
private

Referenced by close(), open(), rewind(), and setPos().

std::string SMESH_File::_name
private

file name

Referenced by exists(), isDirectory(), open(), openForWriting(), remove(), and size().

const char* SMESH_File::_pos
private

current position

Referenced by close(), getInts(), getLine(), open(), rewind(), and setPos().

long SMESH_File::_size
private

file size

Referenced by close(), open(), and size().