bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESTokenizer Class Reference

tokenizer for the BES request command string More...

#include <BESTokenizer.h>

Inheritance diagram for BESTokenizer:
Inheritance graph
Collaboration diagram for BESTokenizer:
Collaboration graph

Public Member Functions

virtual void dump (std::ostream &strm) const
 dumps information about this object
 
void dump_tokens ()
 dump the tokens that have been tokenized in the order in which they are parsed.
 
std::string & get_current_token ()
 returns the current token from the token list
 
std::string & get_first_token ()
 returns the first token from the token list
 
std::string & get_next_token ()
 returns the next token from the token list
 
std::string parse_container_name (const std::string &s, unsigned int &type)
 parses a container name for constraint and attributes
 
void parse_error (const std::string &s="")
 throws an exception giving the tokens up to the point of the problem
 
std::string remove_quotes (const std::string &s)
 removes quotes from a quoted token
 
void tokenize (const char *p)
 tokenize the BES request/command string
 

Detailed Description

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 67 of file BESTokenizer.h.

Constructor & Destructor Documentation

◆ BESTokenizer()

BESTokenizer::BESTokenizer ( )

Definition at line 44 of file BESTokenizer.cc.

◆ ~BESTokenizer()

BESTokenizer::~BESTokenizer ( )

Definition at line 49 of file BESTokenizer.cc.

Member Function Documentation

◆ dump()

void BESTokenizer::dump ( std::ostream & strm) const
virtual

dumps information about this object

Displays the pointer value of this instance

Parameters
strmC++ i/o stream to dump the information to

Implements BESObj.

Definition at line 321 of file BESTokenizer.cc.

◆ dump_tokens()

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 306 of file BESTokenizer.cc.

◆ get_current_token()

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.

Returns
current token
Exceptions
BESErrorif the first token has not yet been retrieved or if the caller is attempting to access more tokens than are available.
See also
BESError

Definition at line 104 of file BESTokenizer.cc.

◆ get_first_token()

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.

Returns
the first token in the token list

Definition at line 88 of file BESTokenizer.cc.

◆ get_next_token()

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.

Returns
next token
Exceptions
BESErrorif the first token has not yet been retrieved or if the caller is attempting to access more tokens than are available.
See also
BESError

Definition at line 123 of file BESTokenizer.cc.

◆ parse_container_name()

string BESTokenizer::parse_container_name ( const std::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.

Parameters
sthe string to be parsed to determine if constraint or attributes
typeset to 1 if constraint or 2 if attributes
Returns
the container name
Exceptions
BESErrorif the syntax is incorrect
See also
BESError

Definition at line 255 of file BESTokenizer.cc.

◆ parse_error()

void BESTokenizer::parse_error ( const std::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.

Parameters
serror string passed by caller to be display with list of tokens
Exceptions
BESSyntaxUserErrorwith the passed error string as well as all tokens leading up to the error.

Definition at line 65 of file BESTokenizer.cc.

◆ remove_quotes()

string BESTokenizer::remove_quotes ( const std::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.

Parameters
sstring where the double quotes are removed.
Returns
the unquoted token
Exceptions
BESErrorif the string does not begin and end with a double quote
See also
BESError

Definition at line 290 of file BESTokenizer.cc.

◆ tokenize()

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.

Parameters
prequest command string
Exceptions
BESErrorif 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.
See also
BESError

Definition at line 162 of file BESTokenizer.cc.


The documentation for this class was generated from the following files: