OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
tokenizer for the BES request command string More...
#include <BESTokenizer.h>
Public Member Functions | |
BESTokenizer () | |
virtual void | dump (ostream &strm) const |
dumps information about this object More... | |
void | dump_tokens () |
dump the tokens that have been tokenized in the order in which they are parsed. More... | |
string & | get_current_token () |
returns the current token from the token list More... | |
string & | get_first_token () |
returns the first token from the token list More... | |
string & | get_next_token () |
returns the next token from the token list More... | |
string | parse_container_name (const string &s, unsigned int &type) |
parses a container name for constraint and attributes More... | |
void | parse_error (const string &s="") |
throws an exception giving the tokens up to the point of the problem More... | |
string | remove_quotes (const string &s) |
removes quotes from a quoted token More... | |
void | tokenize (const char *p) |
tokenize the BES request/command string More... | |
~BESTokenizer () | |
tokenizer for the BES request command string
BESTokenizer tokenizes an BES request command string, such as a get request, a define command, a set command, etc... Tokens are separated by the following characters:
'"' ' ' '
' 0x0D 0x0A
When the tokenizer sees a double quote it then finds the next double quote and includes all test between the quotes, and including the quotes, as a single token.
If there is any problem in the syntax of the request or command then you can use the method parse_error, which will display all of the tokens up to the point of the error.
If the user of the tokenizer attempts to access the next token before the first token is accessed, a BESExcpetion is thrown.
If the user of the tokenizer attempts to access more tokens than were read in, an exception is thrown.
Definition at line 70 of file BESTokenizer.h.
BESTokenizer::BESTokenizer | ( | ) |
Definition at line 42 of file BESTokenizer.cc.
BESTokenizer::~BESTokenizer | ( | ) |
Definition at line 45 of file BESTokenizer.cc.
|
virtual |
dumps information about this object
Displays the pointer value of this instance
strm | C++ i/o stream to dump the information to |
Implements BESObj.
Definition at line 325 of file BESTokenizer.cc.
References BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
void BESTokenizer::dump_tokens | ( | ) |
dump the tokens that have been tokenized in the order in which they are parsed.
Dumps to standard out the tokens that were parsed from the request/command string. If the tokens were quoted, the quotes are kept in. The tokens are all displayed with double quotes around them to show if there are any spaces or special characters in the token.
Definition at line 310 of file BESTokenizer.cc.
string & BESTokenizer::get_current_token | ( | ) |
returns the current token from the token list
Returns the current token from the token list and returns it to the caller.
BESError | if the first token has not yet been retrieved or if the caller is attempting to access more tokens than are available. |
Definition at line 98 of file BESTokenizer.cc.
References parse_error().
string & BESTokenizer::get_first_token | ( | ) |
returns the first token from the token list
This method will return the first token from the token list. Whether the caller has accessed tokens already or not, the caller is returned to the beginning of the list.
Definition at line 83 of file BESTokenizer.cc.
Referenced by CmdTranslation::translate().
string & BESTokenizer::get_next_token | ( | ) |
returns the next token from the token list
Returns the next token from the token list and returns it to the caller.
BESError | if the first token has not yet been retrieved or if the caller is attempting to access more tokens than are available. |
Definition at line 120 of file BESTokenizer.cc.
References parse_error().
string BESTokenizer::parse_container_name | ( | const string & | s, |
unsigned int & | type | ||
) |
parses a container name for constraint and attributes
This method parses a string that contains either a constraint for a container or attributes for a container. If it is a constraint then the type is set to 1, if it is attributes for the container then type is set to 2. The syntax should look like the following.
<container_name>.constraint= or <container_name>.attributes=
The equal sign must be present.
s | the string to be parsed to determine if constraint or attributes |
type | set to 1 if constraint or 2 if attributes |
BESError | if the syntax is incorrect |
Definition at line 257 of file BESTokenizer.cc.
References parse_error().
void BESTokenizer::parse_error | ( | const string & | s = "" ) |
throws an exception giving the tokens up to the point of the problem
Throws an excpetion using the passed error string, and adding to it the tokens that have been read leading up to the point that this method is called.
s | error string passed by caller to be display with list of tokens |
BESSyntaxUserError | with the passed error string as well as all tokens leading up to the error. |
Definition at line 60 of file BESTokenizer.cc.
Referenced by get_current_token(), get_next_token(), parse_container_name(), remove_quotes(), and tokenize().
string BESTokenizer::remove_quotes | ( | const string & | s) |
removes quotes from a quoted token
Removes quotes from a quoted token. The passed string must begin with a double quote and must end with a double quote.
s | string where the double quotes are removed. |
BESError | if the string does not begin and end with a double quote |
Definition at line 294 of file BESTokenizer.cc.
References parse_error().
void BESTokenizer::tokenize | ( | const char * | p) |
tokenize the BES request/command string
BESTokenizer tokenizes a BES request command string, such as a get request, a define command, a set command, etc... Tokens are separated by the following characters:
'"' ' ' '
' 0x0D 0x0A
When the tokenizer sees a double quote it then finds the next double quote and includes all test between the quotes, and including the quotes, as a single token.
When a "\" is character is encountered it is treated as an escape character. The "\" is removed from the token and the character following it is added to the token - even if it's a double qoute.
p | request command string |
BESError | if quoted text is missing an end quote, if the request string is not terminated by a semiclon, if the number of tokens is less than 2. |
Definition at line 159 of file BESTokenizer.cc.
References parse_error().
Referenced by CmdTranslation::translate().