Isis 3 Programmer Reference
|
Construct Token list from a stream. More...
#include <PvlTokenizer.h>
Public Member Functions | |
PvlTokenizer () | |
Constructs a Tokenizer with an empty token list. | |
~PvlTokenizer () | |
Destroys the Tokenizer object and token list. | |
void | Load (std::istream &stream, const QString &terminator="END") |
Loads the Token list from a stream. | |
void | Clear () |
Empties the token list. | |
std::vector< Isis::PvlToken > & | GetTokenList () |
Protected Member Functions | |
QString | ReadComment (std::istream &stream) |
Reads and returns a comment from the stream. | |
QString | ReadToken (std::istream &stream) |
Reads and returns a token from the stream. | |
bool | SkipWhiteSpace (std::istream &stream) |
Skips over whitespace so long as it is not inside quotes. | |
QString | ReadToSingleQuote (std::istream &stream) |
QString | ReadToDoubleQuote (std::istream &stream) |
QString | ReadToParen (std::istream &stream) |
QString | ReadToBrace (std::istream &stream) |
void | ParseCommaList (Isis::PvlToken &t, const QString &cl) |
This routine parses a QString containing a comma separated list. | |
void | ValidateCharacter (int c) |
Make sure a character is valid printable (non-control) character. | |
Protected Attributes | |
std::vector< Isis::PvlToken > | tokens |
The array of Tokens parse out of the stream. | |
Construct Token list from a stream.
This class tokenizes a stream. That is, it will take a stream, from a file or a string, and break the contents of the stream into keyword-value pairs. Examples of such are PDS labels, the standard Isis command line, and VICAR labels. Note that this does not validate the stream to ensure it is of PDS- or VICAR-type. It simply creates a list of keyword-value pairs which can be parsed by another object. The ruleset for tokenizing is straightforward. Consider SPACECRAFT=MARS_GLOBAL_SURVEYOR. The keyword would be SPACECRAFT and the value would be MARS_GLOBAL_SURVEYOR. Other valid examples include: LINES=5, FOCAL_LENGTH=12.4, INSTRUMENT="CAMERA_A", LIST=(0,1,5), and DOGS=("LAB","PUG","BULL"). The later examples, are considered arrays and therefore, will have multiple values associated with the keyword. Comments are allowed in the stream and are indicated by either "#" or "/ *" as the first character on the line.
Definition at line 76 of file PvlTokenizer.h.
Isis::PvlTokenizer::PvlTokenizer | ( | ) |
Constructs a Tokenizer with an empty token list.
Definition at line 22 of file PvlTokenizer.cpp.
References Clear().
Isis::PvlTokenizer::~PvlTokenizer | ( | ) |
Destroys the Tokenizer object and token list.
Definition at line 27 of file PvlTokenizer.cpp.
References Clear().
void Isis::PvlTokenizer::Clear | ( | ) |
Empties the token list.
Definition at line 32 of file PvlTokenizer.cpp.
References tokens.
Referenced by PvlTokenizer(), and ~PvlTokenizer().
vector< Isis::PvlToken > & Isis::PvlTokenizer::GetTokenList | ( | ) |
Definition at line 487 of file PvlTokenizer.cpp.
void Isis::PvlTokenizer::Load | ( | std::istream & | stream, |
const QString & | terminator = "END" ) |
Loads the Token list from a stream.
The loading will be terminated upon reaching either 1) end-of-stream, or 2) a programmer specified terminator QString
stream | The input stream to tokenize |
terminator | If the tokenizer see's this QString as a token in the input stream it will cease tokenizing. Defaults to "END" |
Isis::iException::Parse |
Definition at line 48 of file PvlTokenizer.cpp.
References Isis::Message::KeywordValueBad(), ParseCommaList(), ReadComment(), ReadToken(), SkipWhiteSpace(), tokens, Isis::IException::Unknown, and ValidateCharacter().
|
protected |
This routine parses a QString containing a comma separated list.
Each of the items in the list is stored as a value in the Token.
t | Token to load the comma separated list |
cl | QString containing comma separated list |
Definition at line 449 of file PvlTokenizer.cpp.
References SkipWhiteSpace().
Referenced by Load().
|
protected |
Reads and returns a comment from the stream.
stream | Input stream to read from |
Definition at line 205 of file PvlTokenizer.cpp.
References ValidateCharacter().
Referenced by Load().
|
protected |
Definition at line 397 of file PvlTokenizer.cpp.
|
protected |
Definition at line 277 of file PvlTokenizer.cpp.
|
protected |
Reads and returns a token from the stream.
A token is delimited by either whitespace or an equal sign. In the case of whitespace the token will be considered valueless. That is, there will be no value in the value side of the token (e.g., KEYWORD=).
stream | Input stream to read from |
Definition at line 233 of file PvlTokenizer.cpp.
References ValidateCharacter().
Referenced by Load().
|
protected |
Definition at line 353 of file PvlTokenizer.cpp.
|
protected |
Definition at line 315 of file PvlTokenizer.cpp.
|
protected |
Skips over whitespace so long as it is not inside quotes.
Whitespace is tabs, blanks, line feeds, carriage returns, and NULLs.
stream | Input stream to read from |
Definition at line 257 of file PvlTokenizer.cpp.
References ValidateCharacter().
Referenced by Load(), and ParseCommaList().
|
protected |
Make sure a character is valid printable (non-control) character.
c | Character to be validated |
Definition at line 496 of file PvlTokenizer.cpp.
References Isis::IException::Unknown.
Referenced by Load(), ReadComment(), ReadToken(), and SkipWhiteSpace().
|
protected |
The array of Tokens parse out of the stream.
Definition at line 79 of file PvlTokenizer.h.