Talos::ExtStream Class Reference

Extended streams. More...

#include <Files.hxx>

Inheritance diagram for Talos::ExtStream:

Talos::ConfigStream List of all members.

Public Member Functions

 ExtStream ()
 Default constructor.
 ExtStream (string file_name, string comments="#%", string delimiters=" \t:=|\n,;\r\x0D\x0A")
 Main constructor.
virtual ~ExtStream ()
 Destructor.
bool Discard (string line) const
 Checks whether a line should be discarded.
ExtStreamSkipDiscarded ()
 Skips discarded lines.
void SetDelimiters (string delimiters)
 Sets the characters considered as delimiters.
void SetComments (string comments)
 Sets the characters that denote a comment line.
string GetDelimiters () const
 Returns the characters considered as delimiters..
string GetComments () const
 Returns the characters that denote a comment line.
string GetFileName () const
 Returns the name of the file that was opened.
ExtStreamSkipDelimiters ()
 Skips delimiters.
string RemoveDelimiters (const string &str) const
 Removes delimiters at both ends of a string.
ExtStreamSkip ()
 Skips discarded lines and delimiters.
void Open (string file_name, openmode mode=in)
 Opens a file.
void Close ()
 Closes the current file.
bool IsEmpty ()
 Checks whether the stream is empty.
ExtStreamRewind ()
 Rewinds the stream.
string GetFullLine ()
 Returns the next line.
bool GetFullLine (string &line)
 Returns the next line.
string PeekFullLine ()
 Returns the next line without extracting it from the stream.
string PeekFullLine (streampos &position)
 Returns the next line without extracting it from the stream.
bool PeekFullLine (string &line)
 Returns the next line without extracting it from the stream.
void SkipFullLines (int nb)
 Skips full lines.
virtual string GetLine ()
 Returns the next valid line.
virtual bool GetLine (string &line)
 Returns the next valid line.
virtual string PeekLine ()
 Returns the next valid line without extracting it from the stream.
virtual string PeekLine (streampos &position)
 Returns the next valid line without extracting it from the stream.
virtual bool PeekLine (string &line)
 Returns the next valid line without extracting it from the stream.
void SkipLines (int nb)
 Skips valid lines.
bool Find (string element)
 Sets the position of the get pointer after a given element.
bool FindFromBeginning (string element)
 Sets the position of the get pointer after a given element.
virtual string GetElement ()
 Returns the next valid element.
template<class T>
bool GetElement (T &element)
 Gets the next valid element.
template<class T>
bool GetRawElement (T &element)
 Gets the next valid element.
string PeekElement ()
 Returns the next valid element without extracting it from the stream.
template<class T>
bool PeekElement (T &element)
 Gets the next valid element without extracting it from the stream.
void SkipElements (int nb)
 Skips valid elements.
double GetNumber ()
 Returns the next valid number.
template<class T>
bool GetNumber (T &number)
 Gets the next valid number.
double PeekNumber ()
 Returns the next valid number without extracting it from the stream.
template<class T>
bool PeekNumber (T &number)
 Gets the next valid number without extracting it from the stream.
void SkipNumbers (int nb)
 Skips numbers.
string GetValue (string name)
 Gets the value of a given variable.
string PeekValue (string name)
 Gets the value of a given variable without extracting from the stream.
template<class T>
void GetValue (string name, T &value)
 Gets the value of a given variable.
void GetValue (string name, int &value)
 Gets the value of a given variable.
template<class T>
void PeekValue (string name, T &value)
 Gets the value of a given variable without extracting them from the stream.
template<class T>
void GetValue (string name, T min, T max, T &value)
 Gets the value of a given variable.
template<class T>
void PeekValue (string name, T min, T max, T &value)
 Gets the value of a given variable without extracting them from the stream.
template<class T>
void GetValue (string name, string constraints, T &value)
 Gets the value of a given variable.
template<class T>
void PeekValue (string name, string constraints, T &value)
 Gets the value of a given variable without extracting them from the stream.
void GetValue (string name, string &value)
 Gets the value of a given variable.
void PeekValue (string name, string &value)
 Gets the value of a given variable without extracting them from the stream.
void GetValue (string name, string accepted, string &value, string delimiter)
 Gets the value of a given variable.
void PeekValue (string name, string accepted, string &value, string delimiter)
 Gets the value of a given variable without extracting them from the stream.
void GetValue (string name, bool &value)
 Gets the value of a given variable.
void PeekValue (string name, bool &value)
 Gets the value of a given variable without extracting from the stream.

Protected Member Functions

void CheckAccepted (string name, string value, string accepted, string delimiter) const
 Checks that a value is in a given list of accepted values.

Protected Attributes

string file_name_
 File name associated with the stream.
string comments_
 Characters that denote a comment line.
string delimiters_
 Characters considered as delimiters.
string searching_
 Field currently searched.

Detailed Description

Extended streams.


Constructor & Destructor Documentation

Talos::ExtStream::ExtStream (  ) 

Default constructor.

Nothing is performed.

Talos::ExtStream::ExtStream ( string  file_name,
string  comments = "#%",
string  delimiters = " \t:=|\n,;\r\x0D\x0A" 
)

Main constructor.

Opens a file.

Parameters:
file_name file to be opened.

Talos::ExtStream::~ExtStream (  )  [virtual]

Destructor.

Closes the stream.


Member Function Documentation

bool Talos::ExtStream::Discard ( string  line  )  const

Checks whether a line should be discarded.

Parameters:
line line to be checked.
Returns:
true if the line should be discarded, false otherwise.

ExtStream & Talos::ExtStream::SkipDiscarded (  ) 

Skips discarded lines.

Extracts discarded lines.

Returns:
A reference to the current stream.

void Talos::ExtStream::SetDelimiters ( string  delimiters  ) 

Sets the characters considered as delimiters.

Parameters:
delimiters delimiters.

void Talos::ExtStream::SetComments ( string  comments  ) 

Sets the characters that denote a comment line.

Parameters:
comments the characters that denote a comment line.

string Talos::ExtStream::GetDelimiters (  )  const

Returns the characters considered as delimiters..

Returns:
Delimiters.

string Talos::ExtStream::GetComments (  )  const

Returns the characters that denote a comment line.

Returns:
The characters that denote a comment line.

string Talos::ExtStream::GetFileName (  )  const

Returns the name of the file that was opened.

Returns:
The name of the file that was opened.

ExtStream & Talos::ExtStream::SkipDelimiters (  ) 

Skips delimiters.

Extracts following delimiters from the string, until another character is found.

Returns:
A reference to the current stream.

string Talos::ExtStream::RemoveDelimiters ( const string &  str  )  const

Removes delimiters at both ends of a string.

Removes delimiters at the beginning and at the end of a string.

Parameters:
str string.
Returns:
The string without delimiters at both ends.

ExtStream & Talos::ExtStream::Skip (  ) 

Skips discarded lines and delimiters.

Extracts discarded lines and delimiters.

Returns:
A reference to the current stream.

void Talos::ExtStream::Open ( string  file_name,
openmode  mode = in 
)

Opens a file.

Parameters:
file_name file name.
mode (optional) flags describing the requested I/O mode for the file. Default: in.
Note:
If a file was previously opened, it is closed and the stream is cleared.

void Talos::ExtStream::Close (  ) 

Closes the current file.

Note:
The stream is cleared.

bool Talos::ExtStream::IsEmpty (  ) 

Checks whether the stream is empty.

Checks whether the stream has still valid elements to be read.

Returns:
'true' is the stream is empty, 'false' otherwise.

Reimplemented in Talos::ConfigStream.

ExtStream & Talos::ExtStream::Rewind (  ) 

Rewinds the stream.

Goes back to the beginning of the stream and clears the control state.

Returns:
A reference to the current stream.

string Talos::ExtStream::GetFullLine (  ) 

Returns the next line.

Returns:
The next line.

bool Talos::ExtStream::GetFullLine ( string &  line  ) 

Returns the next line.

Parameters:
line (output) the next line.

string Talos::ExtStream::PeekFullLine (  ) 

Returns the next line without extracting it from the stream.

Returns:
The next line.

string Talos::ExtStream::PeekFullLine ( streampos &  position  ) 

Returns the next line without extracting it from the stream.

Parameters:
position (output) the position of the line following the next line.
Returns:
The next line.

bool Talos::ExtStream::PeekFullLine ( string &  line  ) 

Returns the next line without extracting it from the stream.

Parameters:
line (output) the next line.
Returns:
true if a line has been found, false otherwise.

void Talos::ExtStream::SkipFullLines ( int  nb  ) 

Skips full lines.

Parameters:
nb number of lines to be skipped.

string Talos::ExtStream::GetLine (  )  [virtual]

Returns the next valid line.

Returns the next valid line, i.e. the next line that is not a line to be discarded and from which comments have been extracted.

Returns:
The next valid line.

Reimplemented in Talos::ConfigStream.

bool Talos::ExtStream::GetLine ( string &  line  )  [virtual]

Returns the next valid line.

Returns the next valid line, i.e. the next line that is not a line to be discarded and from which comments have been extracted.

Parameters:
line (output) the next valid line.

Reimplemented in Talos::ConfigStream.

string Talos::ExtStream::PeekLine (  )  [virtual]

Returns the next valid line without extracting it from the stream.

Returns the next valid line, i.e. the next line that is not a line to be discarded and from which comments have been extracted. Nothing is extracted from the stream.

Returns:
The next valid line.

string Talos::ExtStream::PeekLine ( streampos &  position  )  [virtual]

Returns the next valid line without extracting it from the stream.

Returns the next valid line, i.e. the next line that is not a line to be discarded and from which comments have been extracted. Nothing is extracted from the stream.

Parameters:
position (output) the position of the line following the next valid line.
Returns:
The valid line.

bool Talos::ExtStream::PeekLine ( string &  line  )  [virtual]

Returns the next valid line without extracting it from the stream.

Returns the next valid line, i.e. the next line that is not a line to be discarded and from which comments have been extracted. Nothing is extracted from the stream.

Parameters:
line (output) the next valid line.

void Talos::ExtStream::SkipLines ( int  nb  ) 

Skips valid lines.

Parameters:
nb number of lines to be skipped.

bool Talos::ExtStream::Find ( string  element  ) 

Sets the position of the get pointer after a given element.

Sets the position of the get pointer exactly after a given element.

Parameters:
element the element to be found.
Returns:
true if the element was found, false otherwise.

Reimplemented in Talos::ConfigStream.

bool Talos::ExtStream::FindFromBeginning ( string  element  ) 

Sets the position of the get pointer after a given element.

Sets the position of the get pointer exactly after a given element.

Parameters:
element the element to be found from the beginning of the stream.
Returns:
true if the element was found, false otherwise.

Reimplemented in Talos::ConfigStream.

string Talos::ExtStream::GetElement (  )  [virtual]

Returns the next valid element.

Returns the next valid element, i.e. the next element that is not in a line to be discarded.

Returns:
The next valid element.

Reimplemented in Talos::ConfigStream.

template<class T>
bool Talos::ExtStream::GetElement ( T &  element  ) 

Gets the next valid element.

Gets the next valid element, i.e. the next element that is not in a line to be discarded.

Parameters:
element (output) the next valid element.

template<class T>
bool Talos::ExtStream::GetRawElement ( T &  element  ) 

Gets the next valid element.

Gets the next valid element, i.e. the next element that is not in a line to be discarded.

Parameters:
element (output) the next valid element.

string Talos::ExtStream::PeekElement (  ) 

Returns the next valid element without extracting it from the stream.

Returns the next valid element, i.e. the next element that is not in a line to be discarded.

Returns:
The next valid element.

template<class T>
bool Talos::ExtStream::PeekElement ( T &  element  ) 

Gets the next valid element without extracting it from the stream.

Gets the next valid element, i.e. the next element that is not in a line to be discarded.

Parameters:
element (output) the next valid element.

void Talos::ExtStream::SkipElements ( int  nb  ) 

Skips valid elements.

Parameters:
nb number of valid elements to be skipped.

double Talos::ExtStream::GetNumber (  ) 

Returns the next valid number.

Returns the next valid number, i.e. the next number that is not in a line to be discarded.

Returns:
The next valid number.

template<class T>
bool Talos::ExtStream::GetNumber ( T &  number  ) 

Gets the next valid number.

Gets the next valid number, i.e. the next number that is not in a line to be discarded.

Parameters:
element (output) the next valid number.

double Talos::ExtStream::PeekNumber (  ) 

Returns the next valid number without extracting it from the stream.

Returns the next valid number, i.e. the next number that is not in a line to be discarded.

Returns:
The next valid number.

template<class T>
bool Talos::ExtStream::PeekNumber ( T &  number  ) 

Gets the next valid number without extracting it from the stream.

Gets the next valid number, i.e. the next number that is not in a line to be discarded.

Parameters:
number (output) the next valid number.

void Talos::ExtStream::SkipNumbers ( int  nb  ) 

Skips numbers.

Parameters:
nb number of numbers to be skipped.

string Talos::ExtStream::GetValue ( string  name  ) 

Gets the value of a given variable.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) element following the variable name.

Parameters:
name the name of the variable.
Returns:
the value of the variable.

string Talos::ExtStream::PeekValue ( string  name  ) 

Gets the value of a given variable without extracting from the stream.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) element following the variable name. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
Returns:
the value associated with the variable.

template<class T>
void Talos::ExtStream::GetValue ( string  name,
T &  value 
)

Gets the value of a given variable.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name.

Parameters:
name the name of the variable.
value value associated with the variable.

void Talos::ExtStream::GetValue ( string  name,
int &  value 
)

Gets the value of a given variable.

Gets the integral value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name.

Parameters:
name the name of the variable.
value value associated with the variable.

template<class T>
void Talos::ExtStream::PeekValue ( string  name,
T &  value 
)

Gets the value of a given variable without extracting them from the stream.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
value value associated with the variable.

template<class T>
void Talos::ExtStream::GetValue ( string  name,
min,
max,
T &  value 
)

Gets the value of a given variable.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name.

Parameters:
name the name of the variable.
min the minimum value that the variable should take.
max the maximum value that the variable should take.
value value associated with the variable.

template<class T>
void Talos::ExtStream::PeekValue ( string  name,
min,
max,
T &  value 
)

Gets the value of a given variable without extracting them from the stream.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
min the minimum value that the variable should take.
max the maximum value that the variable should take.
value value associated with the variable.

template<class T>
void Talos::ExtStream::GetValue ( string  name,
string  constraint,
T &  value 
)

Gets the value of a given variable.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. This methods also checks that the value meets given constraints.

Parameters:
name the name of the variable.
constraint the list of constraints. The constraints are delimited by |. The supported constraints are: positive, strictly positive, negative, strictly negative, non zero, integer, > x, >= x, < x, <= x, != x y z, = x y z.
value value associated with the variable.

template<class T>
void Talos::ExtStream::PeekValue ( string  name,
string  constraint,
T &  value 
)

Gets the value of a given variable without extracting them from the stream.

Gets the (numerical) value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. This methods also checks that the value meets given constraints. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
constraint the list of constraints. The constraints are delimited by |. The supported constraints are: positive, strictly positive, negative, strictly negative, non zero, integer, > x, >= x, < x, <= x, != x y z, = x y z.
value value associated with the variable.

void Talos::ExtStream::GetValue ( string  name,
string &  value 
)

Gets the value of a given variable.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name.

Parameters:
name the name of the variable.
value value associated with the variable.

void Talos::ExtStream::PeekValue ( string  name,
string &  value 
)

Gets the value of a given variable without extracting them from the stream.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
value value associated with the variable.

void Talos::ExtStream::GetValue ( string  name,
string  accepted,
string &  value,
string  delimiter = "|" 
)

Gets the value of a given variable.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. In addition, this method checks that the value is in an acceptable list of values.

Parameters:
name the name of the variable.
accepted list of accepted values.
value value associated with the variable.
delimiter delimiter in accepted. Default: |.

void Talos::ExtStream::PeekValue ( string  name,
string  accepted,
string &  value,
string  delimiter = "|" 
)

Gets the value of a given variable without extracting them from the stream.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. In addition, this method checks that the value is in an acceptable list of values. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
accepted list of accepted values.
value value associated with the variable.
delimiter delimiter in accepted. Default: |.

void Talos::ExtStream::GetValue ( string  name,
bool &  value 
)

Gets the value of a given variable.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name.

Parameters:
name the name of the variable.
value boolean associated with the variable.

void Talos::ExtStream::PeekValue ( string  name,
bool &  value 
)

Gets the value of a given variable without extracting from the stream.

Gets the value of a given variable, i.e. the next valid (not in a discarded line) number or element following the variable name. Nothing is extracted from the stream.

Parameters:
name the name of the variable.
value boolean associated with the variable.

void Talos::ExtStream::CheckAccepted ( string  name,
string  value,
string  accepted,
string  delimiter 
) const [protected]

Checks that a value is in a given list of accepted values.

Parameters:
name the name of the entry with value value.
value the value to be checked.
accepted the list of accepted values.
delimiter delimiter in accepted.


The documentation for this class was generated from the following files:
Generated on Mon Nov 17 18:20:41 2008 for Talos by  doxygen 1.5.1