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... | |
High level util for effective file reading and other file operations.
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().
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 |
Referenced by DriverSTL_R_SMDS_Mesh::Perform().
const std::string& SMESH_File::error | ( | ) | const |
Referenced by DriverSTL_R_SMDS_Mesh::Perform().
bool SMESH_File::exists | ( | ) |
std::string SMESH_File::getLine | ( | ) |
std::string SMESH_File::getName | ( | ) | const |
Referenced by SMESH_Mesh_i::PrepareForWriting().
const char* SMESH_File::getPos | ( | ) | const |
bool SMESH_File::isDirectory | ( | ) |
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 | ( | ) |
Open for binary writing only.
References _file, _name, and open().
Referenced by SMESH_Mesh_i::PrepareForWriting(), DriverSTL_W_SMDS_Mesh::writeAscii(), and DriverSTL_W_SMDS_Mesh::writeBinary().
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::setPos | ( | const char * | pos | ) |
long SMESH_File::size | ( | ) |
Return file size.
References _error, _name, and _size.
Referenced by SMESH_Mesh_i::ImportMEDFile(), open(), DriverSTL_R_SMDS_Mesh::readAscii(), and DriverSTL_R_SMDS_Mesh::readBinary().
bool SMESH_File::write | ( | const T * | values, |
size_t | nbTValues | ||
) |
Referenced by DriverSTL_W_SMDS_Mesh::writeBinary(), writeFloat(), writeInteger(), and writeRaw().
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().
|
private |
|
private |
Referenced by exists(), isDirectory(), open(), remove(), and size().
|
private |
Referenced by close(), open(), openForWriting(), and writeRaw().
|
private |
file name
Referenced by exists(), isDirectory(), open(), openForWriting(), remove(), and size().
|
private |