CxxUtils::ArrayScanner Class Reference

Helper class for converting strings to Array's. More...

#include <ArrayScanner.h>

List of all members.

Public Member Functions

 ArrayScanner (std::istream &is)
 Constructor.
bool at_open ()
 Read opening token.
bool at_close ()
 Read closing token.
bool at_end ()
 Test for end-of-stream.
template<class T >
bool at_num (T &elt)
 Read number.

Detailed Description

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.


Constructor & Destructor Documentation

CxxUtils::ArrayScanner::ArrayScanner ( std::istream &  is  ) 

Constructor.

Parameters:
is The stream from which to scan.

Builds a new scanner reading from stream is.


Member Function Documentation

bool CxxUtils::ArrayScanner::at_close (  ) 

Read closing token.

Returns:
True if successful.

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.

bool CxxUtils::ArrayScanner::at_end (  ) 

Test for end-of-stream.

Returns:
True if successful.

Consume any white space at the head of the stream. Return true if we're then at the end of the stream. Otherwise, return false.

template<class T >
bool CaloRec::ArrayScanner::at_num ( T elt  )  [inline]

Read number.

Parameters:
elt[out] The number read.
Returns:
True if successful.

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.

bool CxxUtils::ArrayScanner::at_open (  ) 

Read opening token.

Returns:
True if successful.

Consume any white space at the head of the stream. If we're then looking at `[', consume it and return true. Otherwise, return false.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1