|
libFAUDES
Sections
Index
|
faudes::Token Class Reference
|
Classes | |
class | AttributeValue |
Attribute value. More... | |
Public Types | |
enum | TokenType { None = 0x000, Begin = 0x001, End = 0x002, String = 0x004, Option = 0x008, Integer = 0x010, Integer16 = 0x020, Boolean = 0x040, Float = 0x080, Binary = 0x100 } |
Token types: More... | |
Public Member Functions | |
Token (void) | |
Empty constructor, constructs None token. | |
Token (const Token &rToken) | |
Copy constructor. | |
~Token (void) | |
Token destructor. | |
Token & | operator= (const Token &rOther) |
Assignment operator. | |
void | SetNone (void) |
Initialize None token. | |
void | SetString (const std::string &rName) |
Initialize as String token. | |
void | SetBegin (const std::string &rName) |
Initialize as Begin token. | |
void | SetEnd (const std::string &rName) |
Initialize as End token. | |
void | SetEmpty (const std::string &rName) |
Initialize as empty-tag token. | |
void | SetOption (const std::string &rName) |
Initialize as Option token. | |
void | SetInteger (const long int number) |
Initialize as Integer token. | |
void | SetInteger16 (const long int number) |
Initialize as Integer16 token. | |
void | SetBoolean (const long int number) |
Initialize as Boolean token. | |
void | SetFloat (const double number) |
Initialize as Float token. | |
void | SetBinary (const char *data, long int len) |
Initialize Binary token. | |
long int | IntegerValue (void) const |
Get integer value of a numeric token. | |
double | FloatValue (void) const |
Get float value of a numeric token. | |
const std::string & | StringValue (void) const |
Get string value of a name token. | |
const std::string & | OptionValue (void) const |
Get option value of a name token. | |
TokenType | Type (void) const |
Get token Type. | |
bool | IsNone (void) const |
Test token Type. | |
bool | IsInteger (void) const |
Test token Type. | |
bool | IsInteger16 (void) const |
Test token Type. | |
bool | IsBoolean (void) const |
Test token Type. | |
bool | IsFloat (void) const |
Test token Type. | |
bool | IsOption (void) const |
Test token Type. | |
bool | IsString (void) const |
Test token Type. | |
bool | IsBinary (void) const |
Test token Type. | |
bool | IsBegin (void) const |
Test token Type. | |
bool | IsEnd (void) const |
Test token Type. | |
void | ClearAttributes () |
Clear all attributes. | |
void | ClrAttribute (const std::string &name) |
Clear attribute. | |
void | InsAttribute (const std::string &name, const std::string &value) |
Insert named attribute, no type. | |
void | InsAttributeString (const std::string &name, const std::string &value) |
Insert named attribute with string value. | |
void | InsAttributeInteger (const std::string &name, long int value) |
Insert named attribute with integer value. | |
void | InsAttributeInteger16 (const std::string &name, long int value) |
Insert named attribute with integer value. | |
void | InsAttributeBoolean (const std::string &name, long int value) |
Insert named attribute with boolean value. | |
void | InsAttributeFloat (const std::string &name, double value) |
Insert named attribute with integer value. | |
bool | ExistsAttributeString (const std::string &name) |
Test attibute existence. | |
bool | ExistsAttributeInteger (const std::string &name) |
Test attibute existence. | |
bool | ExistsAttributeFloat (const std::string &name) |
Test attibute existence. | |
const std::string & | AttributeStringValue (const std::string &name) |
Access attribute value. | |
long int | AttributeIntegerValue (const std::string &name) |
Access attribute value. | |
double | AttributeFloatValue (const std::string &name) |
Access attribute value. | |
int | Read (std::istream *pStream) |
Read Token from input stream. | |
void | Write (std::ostream *pStream) const |
Write Token to output stream. | |
std::string | Str (void) const |
Pretty print string representation. | |
Static Public Member Functions | |
static void | WriteBinary (std::ostream *pStream, const char *pData, long int len) |
Write specified binary data as base64 string to output stream. | |
static void | WriteVerbatim (std::ostream *pStream, const std::string &rString) |
Write a std::string value to an output stream. | |
static int | WriteEscapedString (std::ostream *pStream, const std::string &outstr) |
Write a std::string value to an output stream. | |
static int | ReadEscapedString (std::istream *pStream, char stop, std::string &rString) |
Read a std::string value from an input file stream. | |
Private Types | |
typedef std::map< std::string, AttributeValue >::iterator | aiterator |
Convenience typedef. | |
typedef std::map< std::string, AttributeValue > ::const_iterator | caiterator |
Private Member Functions | |
void | InterpretAttribute (aiterator ait) |
Interpret attribute value from string. | |
bool | InterpretNumber (const std::string &numstr, int &type, long int &ival, double &fval) |
Interpret string a s number. | |
bool | InterpretNumber (void) |
Interpret token as number. | |
void | WriteString (std::ostream *pStream, const std::string &delim) const |
Write a std::string value to an output stream. | |
void | WriteBinary (std::ostream *pStream) const |
Write my binary data as base64 string to output stream. | |
int | ReadString (std::istream *pStream, char stop) |
Read a std::string value from an input file stream. | |
int | ReadAttributes (std::istream *pStream) |
Read and interpret attribute definitions of begin tags from an input file stream. | |
int | ReadMarkup (std::istream *pStream) |
Read and interpret markup an input file stream. | |
int | ReadVerbatim (std::istream *pStream) |
Read a std::string value from an input file stream. | |
int | ReadBinary (std::istream *pStream) |
Read a base64 binary string from an input file stream. | |
int | ReadSpace (std::istream *pStream) |
Read (ignore) spaces and comments in an input file stream. | |
Private Attributes | |
int | mType |
Token type. | |
std::string | mStringValue |
Token std::string value (for any token type). | |
std::string | mOptionValue |
Token std::string value (if token is of type Option). | |
long int | mIntegerValue |
Token integer value (if Token is of type Integer or Integer16). | |
double | mFloatValue |
Token float value (if Token is of type Float or Integer). | |
std::map< std::string, AttributeValue > | mAttributes |
Attribute value map. | |
int | mAttributeCount |
Attribute sort index (for nice output only). |
Tokens model atomic data for stream IO.
A Token models a string or numeric datum that can be read from a or written to a C++ stream. The class itself implements the representation of the data including its type. For section handling and actual file processing see TokenReader and TokenWriter.
mType | faudes::TokenType of the Token | |
mStringValue | Token value as C++-type std::string | |
mOptionValue | Token value as interpreted option token | |
mIntegerValue | Token value as C++-type long integer | |
mFloatValue | Token value of C++-type double |
Definition at line 56 of file cfl_token.h.
typedef std::map<std::string, AttributeValue>::iterator faudes::Token::aiterator [private] |
Convenience typedef.
Definition at line 578 of file cfl_token.h.
typedef std::map<std::string, AttributeValue>::const_iterator faudes::Token::caiterator [private] |
Definition at line 579 of file cfl_token.h.
Token types:
Definition at line 81 of file cfl_token.h.
faudes::Token::Token | ( | void | ) |
Empty constructor, constructs None token.
Definition at line 29 of file cfl_token.cpp.
faudes::Token::Token | ( | const Token & | rToken | ) |
Copy constructor.
Definition at line 40 of file cfl_token.cpp.
faudes::Token::~Token | ( | void | ) |
Token destructor.
Definition at line 65 of file cfl_token.cpp.
double faudes::Token::AttributeFloatValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 365 of file cfl_token.cpp.
long int faudes::Token::AttributeIntegerValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 355 of file cfl_token.cpp.
const std::string & faudes::Token::AttributeStringValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 344 of file cfl_token.cpp.
void faudes::Token::ClearAttributes | ( | void | ) |
Clear all attributes.
Definition at line 251 of file cfl_token.cpp.
void faudes::Token::ClrAttribute | ( | const std::string & | name | ) |
bool faudes::Token::ExistsAttributeFloat | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 334 of file cfl_token.cpp.
bool faudes::Token::ExistsAttributeInteger | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 324 of file cfl_token.cpp.
bool faudes::Token::ExistsAttributeString | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 314 of file cfl_token.cpp.
double faudes::Token::FloatValue | ( | void | ) | const |
Get float value of a numeric token.
Definition at line 162 of file cfl_token.cpp.
void faudes::Token::InsAttribute | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Insert named attribute, no type.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 258 of file cfl_token.cpp.
void faudes::Token::InsAttributeBoolean | ( | const std::string & | name, | |
long int | value | |||
) |
Insert named attribute with boolean value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 295 of file cfl_token.cpp.
void faudes::Token::InsAttributeFloat | ( | const std::string & | name, | |
double | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 305 of file cfl_token.cpp.
void faudes::Token::InsAttributeInteger | ( | const std::string & | name, | |
long int | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 277 of file cfl_token.cpp.
void faudes::Token::InsAttributeInteger16 | ( | const std::string & | name, | |
long int | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 286 of file cfl_token.cpp.
void faudes::Token::InsAttributeString | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Insert named attribute with string value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 268 of file cfl_token.cpp.
long int faudes::Token::IntegerValue | ( | void | ) | const |
Get integer value of a numeric token.
Definition at line 156 of file cfl_token.cpp.
void faudes::Token::InterpretAttribute | ( | aiterator | ait | ) | [private] |
Interpret attribute value from string.
Definition at line 620 of file cfl_token.cpp.
bool faudes::Token::InterpretNumber | ( | void | ) | [private] |
Interpret token as number.
numstr | String to interpret |
Definition at line 629 of file cfl_token.cpp.
bool faudes::Token::InterpretNumber | ( | const std::string & | numstr, | |
int & | type, | |||
long int & | ival, | |||
double & | fval | |||
) | [private] |
Interpret string a s number.
Definition at line 634 of file cfl_token.cpp.
bool faudes::Token::IsBegin | ( | void | ) | const |
bool faudes::Token::IsBinary | ( | void | ) | const |
bool faudes::Token::IsBoolean | ( | void | ) | const |
bool faudes::Token::IsEnd | ( | void | ) | const |
bool faudes::Token::IsFloat | ( | void | ) | const |
bool faudes::Token::IsInteger | ( | void | ) | const |
bool faudes::Token::IsInteger16 | ( | void | ) | const |
bool faudes::Token::IsNone | ( | void | ) | const |
bool faudes::Token::IsOption | ( | void | ) | const |
bool faudes::Token::IsString | ( | void | ) | const |
Assignment operator.
Definition at line 53 of file cfl_token.cpp.
const std::string & faudes::Token::OptionValue | ( | void | ) | const |
Get option value of a name token.
Definition at line 173 of file cfl_token.cpp.
int faudes::Token::Read | ( | std::istream * | pStream | ) |
Read Token from input stream.
pStream | Pointer to std::ifstream |
Exception |
|
Definition at line 1108 of file cfl_token.cpp.
int faudes::Token::ReadAttributes | ( | std::istream * | pStream | ) | [private] |
Read and interpret attribute definitions of begin tags from an input file stream.
pStream | Reference to std::istream |
Definition at line 886 of file cfl_token.cpp.
int faudes::Token::ReadBinary | ( | std::istream * | pStream | ) | [private] |
Read a base64 binary string from an input file stream.
pStream | Reference to std::istream |
Definition at line 505 of file cfl_token.cpp.
int faudes::Token::ReadEscapedString | ( | std::istream * | pStream, | |
char | stop, | |||
std::string & | rString | |||
) | [static] |
Read a std::string value from an input file stream.
Read an XML escaped string until and excl. the specified stop character.
pStream | Reference to std::istream | |
stop | Stop character | |
rString | Reference to result. |
Definition at line 831 of file cfl_token.cpp.
int faudes::Token::ReadMarkup | ( | std::istream * | pStream | ) | [private] |
Read and interpret markup an input file stream.
This method will identify begin and end tags. Any other XML markup is meant to be gracefully ignored be ignored.
pStream | Reference to std::istream |
Definition at line 962 of file cfl_token.cpp.
int faudes::Token::ReadSpace | ( | std::istream * | pStream | ) | [private] |
Read (ignore) spaces and comments in an input file stream.
pStream | Reference to std::istream |
Definition at line 581 of file cfl_token.cpp.
int faudes::Token::ReadString | ( | std::istream * | pStream, | |
char | stop | |||
) | [private] |
Read a std::string value from an input file stream.
This method assumes that the string was written in the format of WriteString, i.e. enclosed by single stop characters. However, for practical reasons, it is assumed that the first stop character has been allready read .
pStream | Reference to std::istream | |
stop | Stop character |
Definition at line 823 of file cfl_token.cpp.
int faudes::Token::ReadVerbatim | ( | std::istream * | pStream | ) | [private] |
Read a std::string value from an input file stream.
This method assumes that the string was written in the format of WriteVerbatim, i.e. enclosed by a start and stop markers "__VERBATIM__" or variations thereof. However, for practical reasons, it is assumed that the first character "_" has been read allready. Note: verbatim sections are in general *NOT* XML compliant.
pStream | Reference to std::istream |
Definition at line 391 of file cfl_token.cpp.
void faudes::Token::SetBegin | ( | const std::string & | rName | ) |
Initialize as Begin token.
rName | Title of section to fill the Token |
Definition at line 87 of file cfl_token.cpp.
void faudes::Token::SetBinary | ( | const char * | data, | |
long int | len | |||
) |
Initialize Binary token.
This method allocates a copy of the data. For writing only, you may use the TokenWriter interface to avoid the local copy.
data | Reference to raw data record | |
len | Number of bytes in record |
Definition at line 148 of file cfl_token.cpp.
void faudes::Token::SetBoolean | ( | const long int | number | ) |
Initialize as Boolean token.
number | Number to fill the Token |
Definition at line 132 of file cfl_token.cpp.
void faudes::Token::SetEmpty | ( | const std::string & | rName | ) |
Initialize as empty-tag token.
rName | Title of section to fill the Token |
Definition at line 101 of file cfl_token.cpp.
void faudes::Token::SetEnd | ( | const std::string & | rName | ) |
Initialize as End token.
rName | Title of section to fill the Token |
Definition at line 94 of file cfl_token.cpp.
void faudes::Token::SetFloat | ( | const double | number | ) |
Initialize as Float token.
number | Number to fill the Token |
Definition at line 140 of file cfl_token.cpp.
void faudes::Token::SetInteger | ( | const long int | number | ) |
Initialize as Integer token.
number | Number to fill the Token |
Definition at line 116 of file cfl_token.cpp.
void faudes::Token::SetInteger16 | ( | const long int | number | ) |
Initialize as Integer16 token.
number | Number to fill the Token |
Definition at line 124 of file cfl_token.cpp.
void faudes::Token::SetNone | ( | void | ) |
Initialize None token.
Definition at line 69 of file cfl_token.cpp.
void faudes::Token::SetOption | ( | const std::string & | rName | ) |
Initialize as Option token.
rName | Option to fill the Token |
Definition at line 108 of file cfl_token.cpp.
void faudes::Token::SetString | ( | const std::string & | rName | ) |
Initialize as String token.
Definition at line 80 of file cfl_token.cpp.
std::string faudes::Token::Str | ( | void | ) | const |
Pretty print string representation.
Convenience functio for inspection/debugging
Definition at line 1203 of file cfl_token.cpp.
const std::string & faudes::Token::StringValue | ( | void | ) | const |
Get string value of a name token.
Definition at line 167 of file cfl_token.cpp.
Token::TokenType faudes::Token::Type | ( | void | ) | const |
Get token Type.
This method is for backward compatibility only. It returns a token type with only oe bit set to indicate the type as in libfaudes up to version 2.17. To test for possible token interpretations, use the 2.17 interface IsInteger(), IsString() etc.
Definition at line 178 of file cfl_token.cpp.
void faudes::Token::Write | ( | std::ostream * | pStream | ) | const |
Write Token to output stream.
pStream | Pointer to ostream |
Exception |
|
Definition at line 725 of file cfl_token.cpp.
void faudes::Token::WriteBinary | ( | std::ostream * | pStream | ) | const [private] |
Write my binary data as base64 string to output stream.
pStream | Reference to std::ostream |
Definition at line 498 of file cfl_token.cpp.
void faudes::Token::WriteBinary | ( | std::ostream * | pStream, | |
const char * | pData, | |||
long int | len | |||
) | [static] |
Write specified binary data as base64 string to output stream.
pStream | Reference to std::ostream | |
len | Number of bytes to write | |
pData | Data to write |
Definition at line 437 of file cfl_token.cpp.
int faudes::Token::WriteEscapedString | ( | std::ostream * | pStream, | |
const std::string & | outstr | |||
) | [static] |
Write a std::string value to an output stream.
This method replace critical characters by their XML entities and streams the resulting string. No whitespace etc added.
pStream | Reference to std::ostream | |
outstr | String to stream |
Definition at line 784 of file cfl_token.cpp.
void faudes::Token::WriteString | ( | std::ostream * | pStream, | |
const std::string & | delim | |||
) | const [private] |
Write a std::string value to an output stream.
This method writes the string enclosed by a the specified delimiter, typically '"' or ' '. Relevant XML entities are replaced by references, e.g. < && etc. A single white space is added as a sepqrqtor.
pStream | Reference to std::ostream | |
delim | Delimiter |
Definition at line 810 of file cfl_token.cpp.
void faudes::Token::WriteVerbatim | ( | std::ostream * | pStream, | |
const std::string & | rString | |||
) | [static] |
Write a std::string value to an output stream.
This method writes a string verbatim, i.e. incl all control characters. It is enclosed by a marker which defaults to "__VERBATIM__". If the string contains the marker, a variation is used.
pStream | Reference to std::ostream | |
rString | String to write |
Definition at line 375 of file cfl_token.cpp.
int faudes::Token::mAttributeCount [private] |
Attribute sort index (for nice output only).
Definition at line 575 of file cfl_token.h.
std::map<std::string, AttributeValue> faudes::Token::mAttributes [private] |
Attribute value map.
Definition at line 572 of file cfl_token.h.
double faudes::Token::mFloatValue [private] |
Token float value (if Token is of type Float or Integer).
Definition at line 558 of file cfl_token.h.
long int faudes::Token::mIntegerValue [private] |
Token integer value (if Token is of type Integer or Integer16).
Definition at line 555 of file cfl_token.h.
std::string faudes::Token::mOptionValue [private] |
Token std::string value (if token is of type Option).
Definition at line 552 of file cfl_token.h.
std::string faudes::Token::mStringValue [private] |
Token std::string value (for any token type).
Definition at line 549 of file cfl_token.h.
int faudes::Token::mType [private] |
Token type.
Definition at line 546 of file cfl_token.h.
libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3