|
|
||||||
|
faudes::TokenReader Class Reference Detailed DescriptionA TokenReader reads sequential tokens from a file or string. It can get or peek the next token and it will track line numbers for informative diagnosis output. The token stream is meant to be XML compliant, i.e., there are two dedicated token types that mark the begin and the end of XML elements while all other token types represent atomic data such as integers or strings that form the XML character data; see the documentation of the class Token for details. The TokenReader maintains a current position in the stream and implements searching within nested elements and for sequential access of the tokens within each element; e.g. ReadBegin(const std::string&) will search for the element with the specified name. Reading from the Tokenreader by a particular method encodes the type of the requested data, e.g. ReadInteger() to read an integer token. If the token at the current position does not match the requiested type, an exception is thrown. There are alose Get() and Peek() methods to retrieve and inspect the token at the current position. For convenience, the TokenReader also implements reading all contents of an alement and larger chunks of data formtated as CDATA markup within an element; e.g. ReadVerbatim(const std::string&, std::string&) reads the contents of the specified element en block as one string. Definition at line 63 of file cfl_tokenreader.h.
Member Enumeration Documentation◆ ModeMode of operation: read from file, stdin or string.
Definition at line 69 of file cfl_tokenreader.h. Constructor & Destructor Documentation◆ TokenReader() [1/2]
TokenReader constructor.
Definition at line 32 of file cfl_tokenreader.cpp. ◆ TokenReader() [2/2]
Creates a TokenReader for reading a file. This is a convenience wrapper for TokenReader(Mode, const std::string&).
Definition at line 68 of file cfl_tokenreader.cpp. ◆ ~TokenReader()
Destruct. Definition at line 89 of file cfl_tokenreader.cpp. Member Function Documentation◆ Eos()
Peek a token and check whether it ends the specified section. This function is meant for scanning a section with a while- construct. ReadBegin("MySec");
...
};
ReadEnd("MySec");
bool Eos(const std::string &rLabel) Peek a token and check whether it ends the specified section. Definition: cfl_tokenreader.cpp:439 void ReadEnd(const std::string &rLabel) Close the current section by matching the previous ReadBegin(). Definition: cfl_tokenreader.cpp:364 void ReadBegin(const std::string &rLabel) Open a section by specified label. Definition: cfl_tokenreader.cpp:249
Definition at line 439 of file cfl_tokenreader.cpp. ◆ ExistsBegin()
Search for specified element. This function searches for the specified section on the current level. It skips any sections on the levels below, and it will wrap to the begin of the current section once. In the case of success, it returns true, else false. In contrast to other token i/o methodes, this method will not throw any execptions. In the case of success, the next token is the begin-tag of the specified element, which can be read with ReadBegin().
Definition at line 314 of file cfl_tokenreader.cpp. ◆ FileLine()
Return "filename:line". Definition at line 667 of file cfl_tokenreader.cpp. ◆ FileName()
Access the filename. Returns the name of the attached file, if any. For string mode and console mode dummy values are returned.
Definition at line 125 of file cfl_tokenreader.cpp. ◆ Get()
Get next token. Same as Pekk() except that the token is removed from the buffer.
Definition at line 151 of file cfl_tokenreader.cpp. ◆ Level()
Return current level of section nesting.
Definition at line 493 of file cfl_tokenreader.h. ◆ Line()
Return number of lines read.
Definition at line 662 of file cfl_tokenreader.cpp. ◆ operator>>()
Operator for get. Definition at line 475 of file cfl_tokenreader.h. ◆ Peek()
Peek next token. Copies the next token to the provided reference and returns true on success. The token remains in an internal buffer. Technical note: we should have used a const-ref as return in orde to avoid the copy. However, this will require a tedious rewrite.
Definition at line 130 of file cfl_tokenreader.cpp. ◆ ReadBegin() [1/2]
Open a section by specified label. This function searches for the section on this level, it skips any sections on levels below this level, and it will wrap once to the begin of the current section. In the case of success, the matching begin token is the last token read. After processing the section, a matching ReadEnd(label) must be called. If the specified element does not exist, an exception is thrown.
Definition at line 249 of file cfl_tokenreader.cpp. ◆ ReadBegin() [2/2]
Open a section by specified label. This wrapper ReadBegin(const std::string&) will return the actual begin tag in its second argument, e.g., to inspect XML attributes.
Definition at line 255 of file cfl_tokenreader.cpp. ◆ ReadBinary()
Read binary token. Reads the next token and interprets it as an base64 encoded binary array.
Definition at line 504 of file cfl_tokenreader.cpp. ◆ ReadCharacterData()
Read plain text. Read all text until and excluding the next markup tag. This method does no interpretation/substitution at all. It is meant to implemet carbon copy of text sections.
Definition at line 610 of file cfl_tokenreader.cpp. ◆ ReadEnd()
Close the current section by matching the previous ReadBegin(). Reads all tokens up to and including end of current section.
Definition at line 364 of file cfl_tokenreader.cpp. ◆ ReadFloat()
Read float token. Reads the next token and interprets it as a float.
Definition at line 467 of file cfl_tokenreader.cpp. ◆ ReadInteger()
Read integer token. Reads the next token and interprets it as an non-negative integer.
Definition at line 455 of file cfl_tokenreader.cpp. ◆ ReadOption()
Read option token. Reads the next token and interprets it as an option.
Definition at line 492 of file cfl_tokenreader.cpp. ◆ ReadSection()
Read XML section. Reads the current element, including all character data and markup, until and excluding the matching end tag. This method does no interpretation whatsoever. The result is a string that represents the respective section in plain XML format and can be used for expernal post-processing.
Definition at line 634 of file cfl_tokenreader.cpp. ◆ ReadString()
Read string token. Reads the next token and interprets it as a string.
Definition at line 479 of file cfl_tokenreader.cpp. ◆ ReadText()
Read plain text. Interpret the specified section as plain charater data section, read the character data and interpret relevant entities. Leading and trailing whitespaces are ignored, other formating is maintained. This method facilitates the input of paragraphs of plain ASCII text with no other markup as the relevant entities (i.e. no HTML or RTF).
Definition at line 517 of file cfl_tokenreader.cpp. ◆ ReadVerbatim()
Read verbatim text. Interpret the section as plain charater data section, read the character data from either one faudes string token or from consecutive CDATA markups. Leading and trailing whitespaces are ignored, other formating is maintained. This method facilitates the input of paragraphs of plain ASCII text with excessive use of special characters, e.g., program fragments.
Definition at line 568 of file cfl_tokenreader.cpp. ◆ Recover()
Recover by skipping tokens until returning to the specified level of section nesting.
Definition at line 397 of file cfl_tokenreader.cpp. ◆ Reset()
Reset to the begining of the specified level of section nesting.
Definition at line 412 of file cfl_tokenreader.cpp. ◆ Rewind()
Rewind stream. Reset the internal state to its initial value, i.e., the current position is the beginning of the stream. This is not functional in console mode.
Definition at line 99 of file cfl_tokenreader.cpp. ◆ SeekBegin() [1/2]
Find specified begin label. This function searches for the section on this level and any descending level. It does not read the specified section tag, but stops just one token before (and in this regard matches the behaviour of ExistsBegin()). Technical note: Former versions of libFAUDES also read the actual begin token and required a matching call of SeekEnd(). As of version 2.18a, this is not supported anymore. The previous behaviour was rarely needed and can be mimiqued by an ordinary ReadEnd() with a subsequent Recover(level).
Definition at line 207 of file cfl_tokenreader.cpp. ◆ SeekBegin() [2/2]
Find specified begin label. This version SeekBegin(const std::string&) will return the actual begin tag in its second argument.
Definition at line 213 of file cfl_tokenreader.cpp. ◆ SourceMode()
Access stream mode. Returns mode from construction, i.e. file, string or console.
Definition at line 136 of file cfl_tokenreader.h. ◆ Streamp()
Access C++ stream. This method provides direc access to the underlying C++ stream. After any such access, the TokenReader must be Rewind() to reset its internal state.
Definition at line 94 of file cfl_tokenreader.cpp. Member Data Documentation◆ mFaudesComments
flag to ignore faudes comments marked by '' Definition at line 542 of file cfl_tokenreader.h. ◆ mFileName
Filename. Definition at line 533 of file cfl_tokenreader.h. ◆ mFilePos
file position Definition at line 539 of file cfl_tokenreader.h. ◆ mFStream
actual stream object, file input Definition at line 527 of file cfl_tokenreader.h. ◆ mLevel
Level (of nested sections) Definition at line 545 of file cfl_tokenreader.h. ◆ mLevelState
Definition at line 555 of file cfl_tokenreader.h. ◆ mLineCount
Line counter. Definition at line 536 of file cfl_tokenreader.h. ◆ mMode
input mode Definition at line 521 of file cfl_tokenreader.h. ◆ mPeekToken
peek buffer Definition at line 558 of file cfl_tokenreader.h. ◆ mpSStream
actual stream object on heap, string input Definition at line 530 of file cfl_tokenreader.h. ◆ mpStream
istream object pointer Definition at line 524 of file cfl_tokenreader.h. The documentation for this class was generated from the following files: libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen |