parseTools.h File Reference

input file and input stream parsing utils More...

#include <string>
#include <assert.h>
#include <sstream>
#include <vector>
#include <iostream>
#include <string.h>
Include dependency graph for parseTools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void eatWS (char *str, unsigned int &stelle)
 jumps over next whitespaces series in the string 'str', starting at position 'stelle'. * The position is then set to the next first position with a non-whitespace char
std::string eatWS (const std::string &str)
 'eats' leading whitespaces in the string str, and returns the result string
template<class _istream >
char extractChar (char schar, _istream &sstream)
 extracts given char from a stream, throws an error, if failed
template<class _istream >
char extractChar (_istream &sstream, char schar)
 extracts given char from a stream, throws an error, if failed
template<class _istream >
int getSign (_istream &sstream)
 extracts a '-' or '+' from sstream if possible, and returns -1 if '-' , otherwise 1.
template<class _istream >
std::string stripComment (_istream &data, bool &isComment)
 if leading stream entries is a Macaulay-comment sequence, the function strips all chars until next line starts .
template<class _istream >
void stripComments (_istream &data)
 jumps over Macaulay-comments
template<class _istream >
std::string readCurrentComment (_istream &data)
 try to read a comment from input stream. Comment starts with two
template<class _istream >
void seekToBraceLevel (_istream &inputData, int &currentLevel, int braceLevel)
 seeks tho given braceLevel in the input stream if possible. Needs information about currentBraceLevel, which is also kept up to date
std::string extractNextData (std::stringstream &Data)
 extracts data until ',' of '}' at current brace level occur. Comments (
std::string extractNextBracedData (std::stringstream &Data)
 extracts data starting with '{' until of '}' at current brace level occurs.
template<class _istream >
std::string readParamName (_istream &inputData)
 Reads Macaulay parameter name in current line. Assumption: the input stream points to first char of a parameter name (whitespaces are ignored). Parameter name ends with '='.
template<class _istream >
std::string readParamValue (_istream &inputData, std::string name)
 Reads macaulay parameter value in current line. Assumption: the input stream points to first char of a parameter name (whitespaces are ignored). Parameter name ends with '='.
int countSubGroups (std::stringstream &polynomStream)
 count subgroups in braces, example: count result for "{1,2,{..}}"-stream is 1. Assumes, that comments are already stripped. Inside string are currently not handled.
int countGroups (std::stringstream &polynomStream)
 count groups in braces, example: count result for "{1,2,{..}},{...},{...},{...}"-stream is 4. Assumes, that comments are already stripped. Inside string are currently not handled.
int countElements (std::stringstream &str)
 count elements in braces, example: count result for "{1,2,{4,5}}"-stream is 3. Assumes, that comments are already stripped. Inside string are currently not handled.
template<class RingType >
RingType::ElementType parseNumber (RingType *ring1, std::string strNum, int _epsPrecision)
 reads scalar from string strNum with following format:
int getMonomDegree (std::string monomGroup)
 monomgroup: monoms with dame degree, format (implicit) {coeff*x^deg*y^0,coeff*x^(deg-1)*y^0}. in Reality{coeff,coeff,...}
int getMaxMonomDegree (std::string polynomString)
std::string ltrim (const std::string &str)
std::string rtrim (const std::string &str)
std::string trim (const std::string &str)
template<class _istream >
std::string readStringValue (_istream &inputData, std::string paramName)

Detailed Description

Todo:
die Datei ist bestimmt noch voller Fehler... (fail-test, potenzielle Segfaults, string escaping, Kommentare in der Eingabedatei, etc.)

Definition in file parseTools.h.


Function Documentation

int countElements ( std::stringstream &  str  )  [inline]
int countGroups ( std::stringstream &  polynomStream  )  [inline]

Definition at line 833 of file parseTools.h.

Referenced by TVector< TRing >::createFromStream().

int countSubGroups ( std::stringstream &  polynomStream  )  [inline]

Definition at line 803 of file parseTools.h.

Referenced by TMatrix< TRing >::createFromStream(), and createFromStream().

std::string eatWS ( const std::string &  str  )  [inline]

Definition at line 317 of file parseTools.h.

void eatWS ( char str,
unsigned int &  stelle 
) [inline]
template<class _istream >
char extractChar ( _istream &  sstream,
char  schar 
) [inline]

Definition at line 376 of file parseTools.h.

References extractChar().

Here is the call graph for this function:

template<class _istream >
char extractChar ( char  schar,
_istream &  sstream 
) [inline]
std::string extractNextBracedData ( std::stringstream &  Data  )  [inline]
std::string extractNextData ( std::stringstream &  Data  )  [inline]

Kommentieren !

'--' 

) are stripped

Definition at line 535 of file parseTools.h.

References stripComments().

Referenced by createFromStream(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readMonomGroup().

Here is the call graph for this function:

int getMaxMonomDegree ( std::string  polynomString  )  [inline]

Definition at line 228 of file parseTools.h.

References extractChar(), extractNextBracedData(), and getMonomDegree().

Referenced by createFromStream(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynom().

Here is the call graph for this function:

int getMonomDegree ( std::string  monomGroup  )  [inline]
template<class _istream >
int getSign ( _istream &  sstream  )  [inline]

Definition at line 383 of file parseTools.h.

Referenced by parseNumber().

std::string ltrim ( const std::string &  str  )  [inline]

Definition at line 276 of file parseTools.h.

Referenced by nCenterFocus::testTrim(), and trim().

template<class RingType >
RingType::ElementType parseNumber ( RingType *  ring1,
std::string  strNum,
int  _epsPrecision 
) [inline]
 <num>+<num>*e^1++<num>*e^2+... 

and converts result before returning in a element of Ring ring1 with maximal possible epsPrecision<=_epsPrecision for template class RingType::ElementType

from kk only one thing is important: the convert-function.

Todo:
evtl. weitere Verbesserung: ein Element kann sich selbst aus einem String einlesen. Dabei ist aber zu beachten, dass hier eventuell epsPrecision eingeschraenkt werden soll (Parameter _epsPrecision) Eine weitere Moeglichkeit besteht darin, den Ring in dieser Funktion zu erzeugen.

Definition at line 141 of file parseTools.h.

References extractChar(), and getSign().

Referenced by createFromStream(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readMonomGroup().

Here is the call graph for this function:

template<class _istream >
std::string readCurrentComment ( _istream &  data  )  [inline]
'--' 

. Whether comment reading was successful, return value contains the extracted comment string, otherwise the return value is empty.

Definition at line 498 of file parseTools.h.

References stripComment().

Referenced by nCenterFocus::gotoLParamValue(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList(), and seekToBraceLevel().

Here is the call graph for this function:

template<class _istream >
std::string readParamName ( _istream &  inputData  )  [inline]

extracts a parametername, from a input stream

Grammatic: <name>=<value> ; <comment>
 <comment>={}\n | {--commentText}}n
 
Todo:
: maybe using an free parser generator is an optimal and higly portable solution instead of writing unreadable, complex, errneous and unflexible hardcoded parser

todo : exclude further illegal chars - ',' etc.

Definition at line 623 of file parseTools.h.

Referenced by nCenterFocus::gotoLParamValue(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList().

template<class _istream >
std::string readParamValue ( _istream &  inputData,
std::string  paramName 
) [inline]

extracts a parameter value from a input stream

Grammatic:
%<name%>=%<value%> ; %<comment%> %<comment%>={}
| {--commentText}}n

Todo:
: maybe using an free parser generator is an optimal and higly portable solution instead of writing unreadable, complex, errneous and unflexible hardcoded parser

Definition at line 731 of file parseTools.h.

References readStringValue(), and stripComment().

Referenced by nCenterFocus::gotoLParamValue(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList().

Here is the call graph for this function:

template<class _istream >
std::string readStringValue ( _istream &  inputData,
std::string  paramName 
) [inline]
Todo:
eskaped anfuehrungszeichen werden von readStringValue nicht erkannt

Definition at line 693 of file parseTools.h.

Referenced by readParamValue().

std::string rtrim ( const std::string &  str  )  [inline]

Definition at line 293 of file parseTools.h.

Referenced by nCenterFocus::testTrim(), and trim().

template<class _istream >
void seekToBraceLevel ( _istream &  inputData,
int &  currentLevel,
int  braceLevel 
) [inline]

Definition at line 505 of file parseTools.h.

References readCurrentComment().

Referenced by nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readNextPolynoms().

Here is the call graph for this function:

template<class _istream >
std::string stripComment ( _istream &  data,
bool &  isComment 
) [inline]

if leading stream entries are

'--'  (Macaulay-comment) 

, strips all chars until next line starts (after

'\n' or '\r' 

).

Definition at line 408 of file parseTools.h.

Referenced by readCurrentComment(), readParamValue(), and stripComments().

template<class _istream >
void stripComments ( _istream &  data  )  [inline]
std::string trim ( const std::string &  str  )  [inline]

Definition at line 311 of file parseTools.h.

References ltrim(), and rtrim().

Referenced by nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::initExperimentTag(), and nCenterFocus::testTrim().

Here is the call graph for this function:

Generated on Tue Nov 23 13:10:52 2010 for centerfocus by  doxygen 1.6.3