![]() |
cppassist
1.0.0.f4fab4f962ff
C++ sanctuary for small but powerful and frequently required, stand alone features.
|
Text parser tool that converts a text buffer into a stream of tokens. More...
#include <cppassist/include/cppassist/tokenizer/Tokenizer.h>
Classes | |
struct | Lookahead |
Token information from lookahead. More... | |
struct | Token |
Token More... | |
Public Types | |
enum | Option { OptionParseStrings = 1, OptionParseNumber = 2, OptionParseBoolean = 4, OptionParseNull = 8, OptionCStyleComments = 16, OptionCppStyleComments = 32, OptionShellStyleComments = 64, OptionIncludeComments = 128 } |
Parser options. More... | |
enum | TokenType { TokenEndOfStream, TokenWhitespace, TokenComment, TokenStandalone, TokenString, TokenNumber, TokenBoolean, TokenNull, TokenSingleChar, TokenWord } |
Token types. More... | |
Public Member Functions | |
Tokenizer () | |
Constructor. More... | |
~Tokenizer () | |
Destructor. More... | |
unsigned int | options () const |
Get parsing options. More... | |
void | setOptions (unsigned int options) |
Set parsing options. More... | |
bool | hasOption (Option option) const |
Check if a specific parsing option is set. More... | |
const std::string & | whitespace () const |
Get whitespace characters. More... | |
void | setWhitespace (const std::string &whitespace) |
Set whitespace characters. More... | |
const std::string & | quotationMarks () const |
Get quotation marks. More... | |
void | setQuotationMarks (const std::string "ationMarks) |
Set quotation marks. More... | |
const std::string & | singleCharacters () const |
Get single characters. More... | |
void | setSingleCharacters (const std::string &singleCharacters) |
Set single characters. More... | |
const std::vector< std::string > & | standalones () const |
Get standalone strings. More... | |
void | setStandalones (const std::vector< std::string > &standalones) |
Set standalone strings. More... | |
bool | loadDocument (const std::string &filename) |
Load text document to parse. More... | |
void | setDocument (const std::string &document) |
Set text document to parse. More... | |
void | setDocument (const char *beginDoc, const char *endDoc) |
Set text document to parse. More... | |
Token | parseToken () |
Parse and return the next token. More... | |
Text parser tool that converts a text buffer into a stream of tokens.
Parser options.
Enumerator | |
---|---|
OptionParseStrings | Parse strings (use setQuotationMarks to set string characters) |
OptionParseNumber | Parse numbers. |
OptionParseBoolean | Parse boolean values. |
OptionParseNull | Parse null value. |
OptionCStyleComments | Enable ' |
OptionCppStyleComments | Enable ' |
OptionShellStyleComments | Enable ' |
OptionIncludeComments | Include comments in the output of the tokenizer. |
Token types.
cppassist::Tokenizer::Tokenizer | ( | ) |
Constructor.
cppassist::Tokenizer::~Tokenizer | ( | ) |
Destructor.
unsigned int cppassist::Tokenizer::options | ( | ) | const |
Get parsing options.
void cppassist::Tokenizer::setOptions | ( | unsigned int | options | ) |
Set parsing options.
[in] | options | Parsing options |
bool cppassist::Tokenizer::hasOption | ( | Option | option | ) | const |
Check if a specific parsing option is set.
true
if option is set, else false
const std::string& cppassist::Tokenizer::whitespace | ( | ) | const |
Get whitespace characters.
void cppassist::Tokenizer::setWhitespace | ( | const std::string & | whitespace | ) |
Set whitespace characters.
[in] | whitespace | Characters that are considered whitespace |
const std::string& cppassist::Tokenizer::quotationMarks | ( | ) | const |
Get quotation marks.
void cppassist::Tokenizer::setQuotationMarks | ( | const std::string & | quotationMarks | ) |
Set quotation marks.
[in] | quotationMarks | Characters that can enclose a string |
const std::string& cppassist::Tokenizer::singleCharacters | ( | ) | const |
Get single characters.
void cppassist::Tokenizer::setSingleCharacters | ( | const std::string & | singleCharacters | ) |
Set single characters.
[in] | singleCharacters | Characters that stand on their own |
const std::vector<std::string>& cppassist::Tokenizer::standalones | ( | ) | const |
Get standalone strings.
void cppassist::Tokenizer::setStandalones | ( | const std::vector< std::string > & | standalones | ) |
Set standalone strings.
[in] | standalones | Strings that stand on their own |
bool cppassist::Tokenizer::loadDocument | ( | const std::string & | filename | ) |
Load text document to parse.
[in] | filename | Filename of text document |
true
if file could be loaded, else false
void cppassist::Tokenizer::setDocument | ( | const std::string & | document | ) |
Set text document to parse.
[in] | document | Text document |
void cppassist::Tokenizer::setDocument | ( | const char * | beginDoc, |
const char * | endDoc | ||
) |
Set text document to parse.
[in] | beginDoc | Pointer to the first character inside the document |
[in] | endDoc | Pointer to the first character outside of the document |
Token cppassist::Tokenizer::parseToken | ( | ) |
Parse and return the next token.