ATLAS Offline Software
|
Helper class for converting strings to Array's. More...
#include <ArrayScanner.h>
Public Member Functions | |
ArrayScanner (std::istream &is) | |
Constructor. More... | |
bool | at_open () |
Read opening token. More... | |
bool | at_close () |
Read closing token. More... | |
bool | at_end () |
Test for end-of-stream. More... | |
template<class T > | |
bool | at_num (T &elt) |
Read number. More... | |
Private Member Functions | |
bool | at_char (char c) |
Read a character. More... | |
bool | at_num_common () |
The non-template part of reading a number. More... | |
Private Attributes | |
std::istream & | m_is |
The stream from which we're reading. More... | |
Helper class for converting strings to Array's.
This class is a simple lexical analyzer used in converting strings to multidimensional array representations. We get a stream as input. This stream can contain three types of tokens: an open bracket, a close bracket, or a floating-point number. We provide methods to test if either of these three items is at the head of the stream. If so, the item is consumed. (An optional comma may follow a close bracket or a number; it is consumed when the item in front of it is consumed.) We can also test to see if we're at the end.
Definition at line 39 of file ArrayScanner.h.
CxxUtils::ArrayScanner::ArrayScanner | ( | std::istream & | is | ) |
Constructor.
is | The stream from which to scan. |
Builds a new scanner reading from stream is.
Definition at line 26 of file ArrayScanner.cxx.
|
private |
Read a character.
c | The character to read. |
Consume any white space at the head of the stream. If we're then looking at c, consume it and return true. Otherwise, return false.
The | character to read. |
Consume any white space at the head of the stream. If we're then looking at c, consume it and return true. Otherwise, return false.
Definition at line 97 of file ArrayScanner.cxx.
bool CxxUtils::ArrayScanner::at_close | ( | ) |
Read closing token.
Consume any white space at the head of the stream. If we're then looking at ‘]’, consume it and return true. If there's a comma following it, consume that too. Otherwise, return false.
Definition at line 59 of file ArrayScanner.cxx.
bool CxxUtils::ArrayScanner::at_end | ( | ) |
bool CxxUtils::ArrayScanner::at_num | ( | T & | elt | ) |
Read number.
elt[out] | The number read. |
Consume any white space at the head of the stream. If we're then looking at a number that can be converted to type T
, read it and return true. The value is returned in elt. If there's a comma following it, consume that too. Otherwise, return false.
Definition at line 125 of file ArrayScanner.h.
|
private |
The non-template part of reading a number.
This is called after the attempt to read the number itself. This function checks that the read was in fact successful. If so, then it will also consume any following comma.
Definition at line 116 of file ArrayScanner.cxx.
bool CxxUtils::ArrayScanner::at_open | ( | ) |
Read opening token.
Consume any white space at the head of the stream. If we're then looking at ‘[’, consume it and return true. Otherwise, return false.
Definition at line 40 of file ArrayScanner.cxx.
|
private |
The stream from which we're reading.
Definition at line 120 of file ArrayScanner.h.