|
iash
v0.5
Library to provide a bash-like shell in an application
|
Represents a single unit of a command language. More...
#include <Token.h>
Public Member Functions | |
| Token (const std::string &rawToken, const char precedingDelim, const char followingDelim) | |
| Creates a Token with the given content and surrounding delimiters. More... | |
| const std::string & | getToken () const |
| Gets the content of the Token. More... | |
| const std::string & | finalize () |
| Removes any Tokenizer-specific formatting. More... | |
| const char | getPrecedingDelimiter () const |
| Gets the delimiter that came before this Token in the source string. More... | |
| const char | getFollowingDelimiter () const |
| Gets the delimiter that came after this Token in the source string. More... | |
| bool | isToken (const char delim) const |
| Checks if this Token instance is also a Token for the given delimiter. More... | |
| bool | operator== (const Token &other) const |
| Checks for equality between tokens. More... | |
Static Public Member Functions | |
| static bool | isToken (const std::string &candidate, const char delim) |
| Checks if the given candidate string is a Token for the given delimiter. More... | |
Represents a single unit of a command language.
Stores information about the delimiters on either side of the Token from its source in case the delimiters provide contextual information about the token.
There is usually no need to construct a Token directly, use a Tokenizer to get Tokens from an input string.
| Token::Token | ( | const std::string & | rawToken, |
| const char | precedingDelim, | ||
| const char | followingDelim | ||
| ) |
Creates a Token with the given content and surrounding delimiters.
If a Token does not have a delimiter on a side (possibly due to it being at the beginning or end of input), the null character (`'\0'`) should be passed in as appropriate.
| rawToken | the content of the Token |
| precedingDelim | the delimiter preceding the token, or `'\0'` if not applicable |
| followingDelim | the delimiter following the token, or `'\0'` if not applicable |
| const string & Token::finalize | ( | ) |
Removes any Tokenizer-specific formatting.
Specifically, this removes backslashes and leading/trailing whitespace.
| const char Token::getFollowingDelimiter | ( | ) | const |
Gets the delimiter that came after this Token in the source string.
| const char Token::getPrecedingDelimiter | ( | ) | const |
Gets the delimiter that came before this Token in the source string.
| const string & Token::getToken | ( | ) | const |
| bool Token::isToken | ( | const char | delim | ) | const |
|
static |
Checks if the given candidate string is a Token for the given delimiter.
| candidate | the candidate string to search through |
| delim | the delimiter to check for |
| bool Token::operator== | ( | const Token & | other | ) | const |
Checks for equality between tokens.
This does not account for the delimiters on either side of the token.
| other | the other token to check for equality |