Biorbd
Public Member Functions | Protected Attributes | List of all members
biorbd::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 biorbd::utils::Path &path, std::ios_base::openmode mode)
 Construct IfStream. More...
 
 IfStream (const char *path, std::ios_base::openmode mode)
 Construct IfStream. More...
 
bool open (const biorbd::utils::Path &path, std::ios_base::openmode mode)
 Open the file. More...
 
bool read (biorbd::utils::String &text)
 Read a word in the file skipping the word if it is c-like commented. More...
 
bool readAWord (biorbd::utils::String &text)
 Read a word in the file. More...
 
bool read (int &val)
 Read an integer in the file. More...
 
bool read (bool &val)
 Read an boolean in the file. More...
 
bool read (unsigned int &val)
 Read an unsigned integer in the file. More...
 
bool read (double &val)
 Read an double in the file. More...
 
bool read (double &result, const std::map< biorbd::utils::Equation, double > &variables)
 Read and evaluate an equation. More...
 
bool readSpecificTag (const biorbd::utils::String &tag, biorbd::utils::String &text)
 Advance in the file to a specific tag. More...
 
bool reachSpecificTag (const biorbd::utils::String &tag)
 Advance in the file to a specific tag. More...
 
int countTagsInAConsecutiveLines (const biorbd::utils::String &tag)
 Counts the number of consecutive lines starting with the same tag and then brings it back to the initial position. More...
 
void getline (biorbd::utils::String &text)
 Read a whole line. More...
 
bool close ()
 Close the file.
 
bool eof ()
 Return if the file is at the end. More...
 

Protected Attributes

std::shared_ptr< bool > m_isOpen
 If file is open.
 

Detailed Description

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

Definition at line 16 of file IfStream.h.

Constructor & Destructor Documentation

◆ IfStream() [1/2]

biorbd::utils::IfStream::IfStream ( const biorbd::utils::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 17 of file IfStream.cpp.

◆ IfStream() [2/2]

biorbd::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 27 of file IfStream.cpp.

Member Function Documentation

◆ countTagsInAConsecutiveLines()

int biorbd::utils::IfStream::countTagsInAConsecutiveLines ( const biorbd::utils::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 72 of file IfStream.cpp.

◆ eof()

bool biorbd::utils::IfStream::eof ( )

Return if the file is at the end.

Returns
If the file is at the end

Definition at line 190 of file IfStream.cpp.

◆ getline()

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

Read a whole line.

Parameters
textThe text read (output)

Definition at line 179 of file IfStream.cpp.

◆ open()

bool biorbd::utils::IfStream::open ( const biorbd::utils::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 biorbd::utils::IfStream::reachSpecificTag ( const biorbd::utils::String tag)

Advance in the file to a specific tag.

Parameters
tagThe tag to reach
Returns
True on success

Definition at line 58 of file IfStream.cpp.

◆ read() [1/6]

bool biorbd::utils::IfStream::read ( biorbd::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 94 of file IfStream.cpp.

◆ read() [2/6]

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

Read an boolean in the file.

Parameters
valThe value read (output)
Returns
True on success

Definition at line 171 of file IfStream.cpp.

◆ read() [3/6]

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

Read and evaluate an equation.

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

Definition at line 129 of file IfStream.cpp.

◆ read() [4/6]

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

Read an double in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 117 of file IfStream.cpp.

◆ read() [5/6]

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

Read an integer in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 157 of file IfStream.cpp.

◆ read() [6/6]

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

Read an unsigned integer in the file.

Parameters
valThe number read (output)
Returns
True on success

Definition at line 164 of file IfStream.cpp.

◆ readAWord()

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

Read a word in the file.

Parameters
textThe text read (output)
Returns
True on success

Definition at line 113 of file IfStream.cpp.

◆ readSpecificTag()

bool biorbd::utils::IfStream::readSpecificTag ( const biorbd::utils::String tag,
biorbd::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.


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