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, Number = 0x080, Binary = 0x100, Cdata = 0x200 } |
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 Int number) |
Initialize as Integer token. | |
void | SetInteger16 (const Int number) |
Initialize as Integer16 token. | |
void | SetBoolean (const Int number) |
Initialize as Boolean token. | |
void | SetFloat (const Float number) |
Initialize as Float token. | |
void | SetBinary (const char *data, std::size_t len) |
Initialize Binary token. | |
void | ClrEnd (void) |
Clear End type (resolve empty section). | |
Int | IntegerValue (void) const |
Get integer value of a numeric token. | |
Float | 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 | IsBegin (const std::string &tag) const |
Test token Type. | |
bool | IsEnd (void) const |
Test token Type. | |
bool | IsEnd (const std::string &tag) const |
Test token Type. | |
bool | IsEmpty (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, Int value) |
Insert named attribute with integer value. | |
void | InsAttributeInteger16 (const std::string &name, Int value) |
Insert named attribute with integer value. | |
void | InsAttributeBoolean (const std::string &name, Int value) |
Insert named attribute with boolean value. | |
void | InsAttributeFloat (const std::string &name, Float 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. | |
Int | AttributeIntegerValue (const std::string &name) |
Access attribute value. | |
Float | 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, std::size_t 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. | |
static int | ReadCharacterData (std::istream *pStream, std::string &rString) |
Read chracter data 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, Int &ival, Float &fval) |
Interpret string a s number. | |
bool | InterpretNumber (void) |
Interpret string a s 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). | |
Int | mIntegerValue |
Token integer value (if Token is of type Integer or Integer16). | |
Float | mFloatValue |
Token float value (if Token is of type Float or Integer). | |
bool | mPreceedingSpace |
When read from stream, record preceeding space. | |
bool | mPreceedingNewline |
When read from stream, record preceeding space. | |
std::map< std::string, AttributeValue > | mAttributes |
Attribute value map. | |
int | mAttributeCount |
Attribute sort index (for nice output only). | |
Friends | |
class | TokenWriter |
class | TokenReader |
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 integer, faudes typedef Int | |
mFloatValue | Token value of C++-type double, faudes typedef Float |
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 638 of file cfl_token.h.
typedef std::map<std::string, AttributeValue>::const_iterator faudes::Token::caiterator [private] |
Definition at line 639 of file cfl_token.h.
Token types:
Definition at line 84 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 42 of file cfl_token.cpp.
faudes::Token::~Token | ( | void | ) |
Token destructor.
Definition at line 71 of file cfl_token.cpp.
Float faudes::Token::AttributeFloatValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 395 of file cfl_token.cpp.
Int faudes::Token::AttributeIntegerValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 385 of file cfl_token.cpp.
const std::string & faudes::Token::AttributeStringValue | ( | const std::string & | name | ) |
Access attribute value.
name | Attribute name |
Definition at line 374 of file cfl_token.cpp.
void faudes::Token::ClearAttributes | ( | void | ) |
Clear all attributes.
Definition at line 281 of file cfl_token.cpp.
void faudes::Token::ClrAttribute | ( | const std::string & | name | ) |
void faudes::Token::ClrEnd | ( | void | ) |
Clear End type (resolve empty section).
Definition at line 164 of file cfl_token.cpp.
bool faudes::Token::ExistsAttributeFloat | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 364 of file cfl_token.cpp.
bool faudes::Token::ExistsAttributeInteger | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 354 of file cfl_token.cpp.
bool faudes::Token::ExistsAttributeString | ( | const std::string & | name | ) |
Test attibute existence.
name | Attribute name |
Definition at line 344 of file cfl_token.cpp.
Float faudes::Token::FloatValue | ( | void | ) | const |
Get float value of a numeric token.
Definition at line 176 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 288 of file cfl_token.cpp.
void faudes::Token::InsAttributeBoolean | ( | const std::string & | name, | |
Int | value | |||
) |
Insert named attribute with boolean value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 325 of file cfl_token.cpp.
void faudes::Token::InsAttributeFloat | ( | const std::string & | name, | |
Float | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 335 of file cfl_token.cpp.
void faudes::Token::InsAttributeInteger | ( | const std::string & | name, | |
Int | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 307 of file cfl_token.cpp.
void faudes::Token::InsAttributeInteger16 | ( | const std::string & | name, | |
Int | value | |||
) |
Insert named attribute with integer value.
Note: only begin tags can have attributes.
name | Attribute name | |
value | Attribute value |
Definition at line 316 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 298 of file cfl_token.cpp.
Int faudes::Token::IntegerValue | ( | void | ) | const |
Get integer value of a numeric token.
Definition at line 170 of file cfl_token.cpp.
void faudes::Token::InterpretAttribute | ( | aiterator | ait | ) | [private] |
Interpret attribute value from string.
Definition at line 704 of file cfl_token.cpp.
bool faudes::Token::InterpretNumber | ( | void | ) | [private] |
Interpret string a s number.
Definition at line 713 of file cfl_token.cpp.
bool faudes::Token::InterpretNumber | ( | const std::string & | numstr, | |
int & | type, | |||
Int & | ival, | |||
Float & | fval | |||
) | [private] |
Interpret string a s number.
Definition at line 718 of file cfl_token.cpp.
bool faudes::Token::IsBegin | ( | const std::string & | tag | ) | const |
Test token Type.
tag | Section tag to test for |
Definition at line 252 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::IsEmpty | ( | void | ) | const |
bool faudes::Token::IsEnd | ( | const std::string & | tag | ) | const |
Test token Type.
tag | Section tag to test for |
Definition at line 263 of file cfl_token.cpp.
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 57 of file cfl_token.cpp.
const std::string & faudes::Token::OptionValue | ( | void | ) | const |
Get option value of a name token.
Definition at line 187 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 1266 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 1013 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 572 of file cfl_token.cpp.
int faudes::Token::ReadCharacterData | ( | std::istream * | pStream, | |
std::string & | rString | |||
) | [static] |
Read chracter data from an input file stream.
Reads the stream untion the next "<" character. The plain character data is returned, no enteties substituted etc.
pStream | Reference to std::istream | |
rString | Reference to result. |
Definition at line 982 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 922 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 1088 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 648 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 914 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 453 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 95 of file cfl_token.cpp.
void faudes::Token::SetBinary | ( | const char * | data, | |
std::size_t | 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 156 of file cfl_token.cpp.
void faudes::Token::SetBoolean | ( | const Int | number | ) |
Initialize as Boolean token.
number | Number to fill the Token |
Definition at line 140 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 109 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 102 of file cfl_token.cpp.
void faudes::Token::SetFloat | ( | const Float | number | ) |
Initialize as Float token.
number | Number to fill the Token |
Definition at line 148 of file cfl_token.cpp.
void faudes::Token::SetInteger | ( | const Int | number | ) |
Initialize as Integer token.
number | Number to fill the Token |
Definition at line 124 of file cfl_token.cpp.
void faudes::Token::SetInteger16 | ( | const Int | number | ) |
Initialize as Integer16 token.
number | Number to fill the Token |
Definition at line 132 of file cfl_token.cpp.
void faudes::Token::SetNone | ( | void | ) |
Initialize None token.
Definition at line 75 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 116 of file cfl_token.cpp.
void faudes::Token::SetString | ( | const std::string & | rName | ) |
Initialize as String token.
Definition at line 88 of file cfl_token.cpp.
std::string faudes::Token::Str | ( | void | ) | const |
Pretty print string representation.
Convenience functio for inspection/debugging
Definition at line 1361 of file cfl_token.cpp.
const std::string & faudes::Token::StringValue | ( | void | ) | const |
Get string value of a name token.
Definition at line 181 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 192 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 809 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 565 of file cfl_token.cpp.
void faudes::Token::WriteBinary | ( | std::ostream * | pStream, | |
const char * | pData, | |||
std::size_t | 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 504 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 875 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 901 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 424 of file cfl_token.cpp.
friend class TokenReader [friend] |
Definition at line 60 of file cfl_token.h.
friend class TokenWriter [friend] |
Definition at line 59 of file cfl_token.h.
int faudes::Token::mAttributeCount [private] |
Attribute sort index (for nice output only).
Definition at line 635 of file cfl_token.h.
std::map<std::string, AttributeValue> faudes::Token::mAttributes [private] |
Attribute value map.
Definition at line 632 of file cfl_token.h.
Float faudes::Token::mFloatValue [private] |
Token float value (if Token is of type Float or Integer).
Definition at line 612 of file cfl_token.h.
Int faudes::Token::mIntegerValue [private] |
Token integer value (if Token is of type Integer or Integer16).
Definition at line 609 of file cfl_token.h.
std::string faudes::Token::mOptionValue [private] |
Token std::string value (if token is of type Option).
Definition at line 606 of file cfl_token.h.
bool faudes::Token::mPreceedingNewline [private] |
When read from stream, record preceeding space.
Definition at line 618 of file cfl_token.h.
bool faudes::Token::mPreceedingSpace [private] |
When read from stream, record preceeding space.
Definition at line 615 of file cfl_token.h.
std::string faudes::Token::mStringValue [private] |
Token std::string value (for any token type).
Definition at line 603 of file cfl_token.h.
int faudes::Token::mType [private] |
Token type.
Definition at line 600 of file cfl_token.h.
libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen