#include <Files.hxx>
Inheritance diagram for Talos::ExtStream:
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. | |
ExtStream & | SkipDiscarded () |
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. | |
ExtStream & | SkipDelimiters () |
Skips delimiters. | |
string | RemoveDelimiters (const string &str) const |
Removes delimiters at both ends of a string. | |
ExtStream & | Skip () |
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. | |
ExtStream & | Rewind () |
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. |
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.
file_name | file to be opened. |
Talos::ExtStream::~ExtStream | ( | ) | [virtual] |
Destructor.
Closes the stream.
bool Talos::ExtStream::Discard | ( | string | line | ) | const |
Checks whether a line should be discarded.
line | line to be checked. |
ExtStream & Talos::ExtStream::SkipDiscarded | ( | ) |
Skips discarded lines.
Extracts discarded lines.
void Talos::ExtStream::SetDelimiters | ( | string | delimiters | ) |
Sets the characters considered as delimiters.
delimiters | delimiters. |
void Talos::ExtStream::SetComments | ( | string | comments | ) |
Sets the characters that denote a comment line.
comments | the characters that denote a comment line. |
string Talos::ExtStream::GetDelimiters | ( | ) | const |
Returns the characters considered as delimiters..
string Talos::ExtStream::GetComments | ( | ) | const |
Returns the characters that denote a comment line.
string Talos::ExtStream::GetFileName | ( | ) | const |
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.
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.
str | string. |
ExtStream & Talos::ExtStream::Skip | ( | ) |
Skips discarded lines and delimiters.
Extracts discarded lines and delimiters.
void Talos::ExtStream::Open | ( | string | file_name, | |
openmode | mode = in | |||
) |
Opens a file.
file_name | file name. | |
mode | (optional) flags describing the requested I/O mode for the file. Default: in. |
void Talos::ExtStream::Close | ( | ) |
Closes the current file.
bool Talos::ExtStream::IsEmpty | ( | ) |
Checks whether the stream is empty.
Checks whether the stream has still valid elements to be read.
Reimplemented in Talos::ConfigStream.
ExtStream & Talos::ExtStream::Rewind | ( | ) |
Rewinds the stream.
Goes back to the beginning of the stream and clears the control state.
string Talos::ExtStream::GetFullLine | ( | ) |
Returns the next line.
bool Talos::ExtStream::GetFullLine | ( | string & | line | ) |
Returns the next line.
line | (output) the next line. |
string Talos::ExtStream::PeekFullLine | ( | ) |
Returns the next line without extracting it from the stream.
string Talos::ExtStream::PeekFullLine | ( | streampos & | position | ) |
Returns the next line without extracting it from the stream.
position | (output) the position of the line following the next line. |
bool Talos::ExtStream::PeekFullLine | ( | string & | line | ) |
Returns the next line without extracting it from the stream.
line | (output) the next line. |
void Talos::ExtStream::SkipFullLines | ( | int | nb | ) |
Skips full lines.
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.
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.
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.
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.
position | (output) the position of the line following the next 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.
line | (output) the next valid line. |
void Talos::ExtStream::SkipLines | ( | int | nb | ) |
Skips valid lines.
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.
element | the element to be found. |
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.
element | the element to be found from the beginning of the stream. |
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.
Reimplemented in Talos::ConfigStream.
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.
element | (output) the next valid element. |
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.
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.
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.
element | (output) the next valid element. |
void Talos::ExtStream::SkipElements | ( | int | nb | ) |
Skips valid elements.
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.
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.
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.
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.
number | (output) the next valid number. |
void Talos::ExtStream::SkipNumbers | ( | int | nb | ) |
Skips numbers.
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.
name | the name 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.
name | the name of the variable. |
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.
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.
name | the name of the variable. | |
value | value associated with the variable. |
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.
name | the name of the variable. | |
value | value associated with the variable. |
void Talos::ExtStream::GetValue | ( | string | name, | |
T | min, | |||
T | 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.
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. |
void Talos::ExtStream::PeekValue | ( | string | name, | |
T | min, | |||
T | 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.
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. |
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.
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::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.
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.
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.
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.
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.
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.
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.
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.
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. |