input file and input stream parsing utils More...
#include <string>
#include <assert.h>
#include <sstream>
#include <vector>
#include <iostream>
#include <string.h>
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 ¤tLevel, 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) |
Definition in file parseTools.h.
int countElements | ( | std::stringstream & | str | ) | [inline] |
Definition at line 863 of file parseTools.h.
Referenced by TVector< TRing >::createFromStream(), TMatrix< TRing >::createFromStream(), and createFromStream().
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] |
Definition at line 267 of file parseTools.h.
Referenced by Parameterlist::addDefaultParameter(), Parameterlist::addParameter(), nCenterFocus::isAllMarker(), nCenterFocus::isRandomMarker(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynomsFromDifferentialForm(), xyOneForm< PolynomXYType >::xyOneForm(), and xyOneFormTerm< xyMonomType >::xyOneFormTerm().
Definition at line 376 of file parseTools.h.
References extractChar().
Definition at line 333 of file parseTools.h.
Referenced by xyMonom< ccoeff >::createFromStream(), TVector< TRing >::createFromStream(), TMatrix< TRing >::createFromStream(), createFromStream(), extractChar(), extractNextBracedData(), nCenterFocus::extractStreamFromPQStream(), getMaxMonomDegree(), nCenterFocus::gotoLParamValue(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::initExperimentTag(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList(), parseNumber(), rationalNumber::rationalNumber(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readMonomGroup(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readNextPolynoms(), nCenterFocus::readNextPQPolynomStream(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynom(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynomsFromDifferentialForm(), and xyOneFormTerm< xyMonomType >::xyOneFormTerm().
std::string extractNextBracedData | ( | std::stringstream & | Data | ) | [inline] |
Definition at line 582 of file parseTools.h.
References extractChar(), and stripComments().
Referenced by TVector< TRing >::createFromStream(), TMatrix< TRing >::createFromStream(), createFromStream(), nCenterFocus::extractStreamFromPQStream(), getMaxMonomDegree(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynom().
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().
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().
int getMonomDegree | ( | std::string | monomGroup | ) | [inline] |
Definition at line 217 of file parseTools.h.
Referenced by getMaxMonomDegree(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::updatePolynom().
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().
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.
Definition at line 141 of file parseTools.h.
References extractChar(), and getSign().
Referenced by createFromStream(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readMonomGroup().
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().
std::string readParamName | ( | _istream & | inputData | ) | [inline] |
extracts a parametername, from a input stream
Grammatic: <name>=<value> ; <comment> <comment>={}\n | {--commentText}}n
todo : exclude further illegal chars - ',' etc.
Definition at line 623 of file parseTools.h.
Referenced by nCenterFocus::gotoLParamValue(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList().
std::string readParamValue | ( | _istream & | inputData, | |
std::string | paramName | |||
) | [inline] |
extracts a parameter value from a input stream
Grammatic:
%<name%>=%<value%> ; %<comment%> %<comment%>={}
| {--commentText}}n
Definition at line 731 of file parseTools.h.
References readStringValue(), and stripComment().
Referenced by nCenterFocus::gotoLParamValue(), and nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList().
std::string readStringValue | ( | _istream & | inputData, | |
std::string | paramName | |||
) | [inline] |
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().
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().
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().
void stripComments | ( | _istream & | data | ) | [inline] |
'--'
,until a non-comment char occurs in the input stream
Definition at line 486 of file parseTools.h.
References stripComment().
Referenced by extractNextBracedData(), extractNextData(), nCenterFocus::gotoLParamValue(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::loadParamList(), nCenterFocus::CenterfocusParams< TPolynomXY, TRing >::readNextPolynoms(), and nCenterFocus::readNextPQPolynomStream().
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().