Biorbd Release_1.13.0
Loading...
Searching...
No Matches
BIORBD_NAMESPACE::utils::IfStream Class Reference

Wrapper for the an std::ifstream with increased capacities. More...

#include <IfStream.h>

Public Member Functions

 IfStream ()
 Construct IfStream.
 IfStream (const Path &path, std::ios_base::openmode mode)
 Construct IfStream.
 IfStream (const char *path, std::ios_base::openmode mode)
 Construct IfStream.
bool open (const Path &path, std::ios_base::openmode mode)
 Open the file.
bool read (String &text)
 Read a word in the file skipping the word if it is c-like commented.
bool readAWord (String &text)
 Read a word in the file.
bool read (int &val)
 Read an integer in the file.
bool read (bool &val)
 Read an boolean in the file.
bool read (size_t &val)
 Read an unsigned integer in the file.
bool read (double &val)
 Read an double in the file.
bool read (double &result, const std::map< Equation, double > &variables)
 Read and evaluate an equation.
bool readFromBinary (char *output, int n_elements)
 Read a certain amounts of bits in binary.
bool readFromBinary (float &result)
 Read a float in binary file.
bool readFromBinary (Vector3d &v)
 Read a 3d vector (three floats) in binary file.
bool readSpecificTag (const String &tag, String &text)
 Advance in the file to a specific tag.
bool reachSpecificTag (const String &tag, size_t maxTag=-1)
 Advance in the file to a specific tag.
int countTagsInAConsecutiveLines (const String &tag)
 Counts the number of consecutive lines starting with the same tag and then brings it back to the initial position.
void getline (String &text)
 Read a whole line.
void resetCursor ()
 Reset the file cursor to the 0 position.
bool close ()
 Close the file.
bool eof ()
 Return if the file is at the end.

Protected Attributes

std::shared_ptr< bool > m_isOpen
 If file is open.
char m_floatBuffer [sizeof(float)]
 Buffer for reading float in binaries.

Detailed Description

Wrapper for the an std::ifstream with increased capacities.

Definition at line 20 of file IfStream.h.

Constructor & Destructor Documentation

◆ IfStream() [1/3]

utils::IfStream::IfStream ( )

Construct IfStream.

Definition at line 14 of file IfStream.cpp.

◆ IfStream() [2/3]

utils::IfStream::IfStream ( const Path & path,
std::ios_base::openmode mode = std::ios_base::in )

Construct IfStream.

Parameters
pathThe file path to open
modeThe open mode of "std::ios_base" base

Definition at line 20 of file IfStream.cpp.

◆ IfStream() [3/3]

utils::IfStream::IfStream ( const char * path,
std::ios_base::openmode mode = std::ios_base::in )

Construct IfStream.

Parameters
pathThe file path to open
modeThe open mode of "std::ios_base" base

Definition at line 29 of file IfStream.cpp.

Member Function Documentation

◆ close()

bool utils::IfStream::close ( )

Close the file.

Returns
True on success

Definition at line 220 of file IfStream.cpp.

◆ countTagsInAConsecutiveLines()

int utils::IfStream::countTagsInAConsecutiveLines ( const String & tag)

Counts the number of consecutive lines starting with the same tag and then brings it back to the initial position.

Parameters
tagThe tag to count
Returns
The number of consecutive lines starting with the same tag

Definition at line 80 of file IfStream.cpp.

◆ eof()

bool utils::IfStream::eof ( )

Return if the file is at the end.

Returns
If the file is at the end

Definition at line 225 of file IfStream.cpp.

◆ getline()

void utils::IfStream::getline ( utils::String & text)

Read a whole line.

Parameters
textThe text read (output)

Definition at line 210 of file IfStream.cpp.

◆ open()

bool utils::IfStream::open ( const Path & path,
std::ios_base::openmode mode = std::ios_base::in )

Open the file.

Parameters
pathThe file path to open
modeThe open mode of "std::ios_base" base
Returns
True on success

Definition at line 40 of file IfStream.cpp.

◆ reachSpecificTag()

bool utils::IfStream::reachSpecificTag ( const String & tag,
size_t maxTag = -1 )

Advance in the file to a specific tag.

Parameters
tagThe tag to reach
maxTagThe number of element to read before giving up
Returns
True on success

Definition at line 58 of file IfStream.cpp.

◆ read() [1/6]

bool utils::IfStream::read ( bool & val)

Read an boolean in the file.

Parameters
valThe value read (output)
Returns
True on success

Definition at line 203 of file IfStream.cpp.

◆ read() [2/6]

bool utils::IfStream::read ( double & result,
const std::map< Equation, double > & variables )

Read and evaluate an equation.

Parameters
resultThe number read (output)
variablesThe variable set
Returns
True on success

Definition at line 137 of file IfStream.cpp.

◆ read() [3/6]

bool utils::IfStream::read ( double & val)

Read an double in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 127 of file IfStream.cpp.

◆ read() [4/6]

bool utils::IfStream::read ( int & val)

Read an integer in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 191 of file IfStream.cpp.

◆ read() [5/6]

bool utils::IfStream::read ( size_t & val)

Read an unsigned integer in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 197 of file IfStream.cpp.

◆ read() [6/6]

bool utils::IfStream::read ( utils::String & text)

Read a word in the file skipping the word if it is c-like commented.

Parameters
textThe text read (output)
Returns
True on success

Definition at line 101 of file IfStream.cpp.

◆ readAWord()

bool utils::IfStream::readAWord ( utils::String & text)

Read a word in the file.

Parameters
textThe text read (output)
Returns
True on success

Definition at line 123 of file IfStream.cpp.

◆ readFromBinary() [1/3]

bool utils::IfStream::readFromBinary ( char * output,
int n_elements )

Read a certain amounts of bits in binary.

Parameters
outputWhere the result is store
n_elementsNumber of bits to read
Returns
True on success

Definition at line 152 of file IfStream.cpp.

◆ readFromBinary() [2/3]

bool utils::IfStream::readFromBinary ( float & result)

Read a float in binary file.

Parameters
resultThe float to put the result into
Returns
True on success

Definition at line 157 of file IfStream.cpp.

◆ readFromBinary() [3/3]

bool utils::IfStream::readFromBinary ( utils::Vector3d & v)

Read a 3d vector (three floats) in binary file.

Parameters
vThe vector to put the result into
Returns
True on success

Definition at line 163 of file IfStream.cpp.

◆ readSpecificTag()

bool utils::IfStream::readSpecificTag ( const String & tag,
utils::String & text )

Advance in the file to a specific tag.

Parameters
tagThe tag to reach
textThe text that follows a tag
Returns
True on success

Definition at line 51 of file IfStream.cpp.

◆ resetCursor()

void utils::IfStream::resetCursor ( )

Reset the file cursor to the 0 position.

Definition at line 214 of file IfStream.cpp.

Member Data Documentation

◆ m_floatBuffer

char BIORBD_NAMESPACE::utils::IfStream::m_floatBuffer[sizeof(float)]
protected

Buffer for reading float in binaries.

Definition at line 189 of file IfStream.h.

◆ m_isOpen

std::shared_ptr<bool> BIORBD_NAMESPACE::utils::IfStream::m_isOpen
protected

If file is open.

Definition at line 188 of file IfStream.h.


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