1
// *************************************************************************
4
// * File: gsm_parser.h
6
// * Purpose: Parser to parse MA/TA result strings
8
// * Author: Peter Hofmann (software@pxh.de)
10
// * Created: 13.5.1999
11
// *************************************************************************
16
#include <gsmlib/gsm_util.h>
17
#include <gsmlib/gsm_error.h>
25
class Parser : public RefBase
28
unsigned int _i; // index into _s, next character
29
string _s; // string to parse
30
bool _eos; // true if end-of-string reached in nextChar()
32
// return next character or -1 if end of string
33
int nextChar(bool skipWhiteSpace = true);
35
// "puts back" a character
36
void putBackChar() {if (! _eos) --_i;}
38
// check for empty parameter (ie. "," or end of string)
40
// returns true if no parameter
41
// or throw an GsmException if allowNoParameter == false
42
bool checkEmptyParameter(bool allowNoParameter) throw(GsmException);
44
// parse a string (like "string")
45
// throw an exception if not well-formed
46
string parseString2(bool stringWithQuotationMarks) throw(GsmException);
48
// parse a int (like 1234)
49
// throw an exception if not well-formed
50
int parseInt2() throw(GsmException);
52
// throw a parser exception
53
void throwParseException(string message = "") throw(GsmException);
58
// the following functions skip white space
59
// parse a character, if absent throw a GsmException
60
// return false if allowNoChar == true and character not encountered
61
bool parseChar(char c, bool allowNoChar = false) throw(GsmException);
63
// parse a list of the form "("ABC", DEF")"
64
// the list can be empty (ie. == "" ) if allowNoList == true
65
vector<string> parseStringList(bool allowNoList = false)
68
// parse a list of the form "(12, 14)" or "(1-4, 10)"
69
// the result is returned as a bit vector where for each integer
70
// in the list and/or range(s) a bit is set
71
// the list can be empty (ie. == "") if allowNoList == true
72
vector<bool> parseIntList(bool allowNoList = false)
75
// parse an integer range of the form "(1-125)"
76
// the range may be absent if allowNoRange == true
77
// then IntRange::_high and _low are set to NOT_SET
78
IntRange parseRange(bool allowNoRange = false)
81
// parse an integer of the form "1234"
82
// allow absent int if allowNoInt == true
83
// then it returns NOT_SET
84
int parseInt(bool allowNoInt = false) throw(GsmException);
86
// parse a string of the form ""string""
87
// allow absent string if allowNoString == true
89
// if stringWithQuotationMarks == true the string may contain """
90
// the string is then parsed till the end of the line
91
string parseString(bool allowNoString = false,
92
bool stringWithQuotationMarks = false)
96
// the comma may be absent if allowNoComma == true
97
// returns true if there was a comma
98
bool parseComma(bool allowNoComma = false) throw(GsmException);
100
// parse till end of line, return result without whitespace
101
string parseEol() throw(GsmException);
103
// check that end of line is reached
104
void checkEol() throw(GsmException);
106
// return string till end of line without whitespace
107
// (does not change internal state)
112
#endif // GSM_PARSER_H