libpniio
Public Types | Public Member Functions | Private Types | Private Attributes
pni::io::parser< T, ITERT > Class Template Reference

parser for primitive types More...

#include <parser.hpp>

Collaboration diagram for pni::io::parser< T, ITERT >:
Collaboration graph
[legend]

Public Types

typedef ITERT iterator_type
 iterator type More...
 
typedef T result_type
 result type of the parsing process More...
 
typedef
boost::spirit::qi::expectation_failure
< iterator_type
expectation_error
 parser exception type More...
 

Public Member Functions

result_type operator() (const pni::core::string &data) const
 parser primitive type More...
 

Private Types

typedef conversion_trait
< result_type
trait_type
 conversion trait type More...
 
typedef trait_type::read_type read_type
 type used for reading the data More...
 

Private Attributes

get_rule_type< iterator_type,
read_type >::type 
_rule
 rule which will be used to read the data More...
 

Detailed Description

template<typename T, typename ITERT = pni::core::string::const_iterator>
class pni::io::parser< T, ITERT >

This version of the parser structure provides a default parsing implementation for primitive types. The aim of this class is to hide all the complexity of the boost::spirit::qi parsers. In addition it catches all spirit exceptions and wraps them into a parser_error exception.

Use this parser to parse a single primitive value from a string. The input data must be trimmed - so no leading or trailing blanks are allowed. The string is supposed to end with the last character assembling the value to parse.

By default the output iterator is a const string iterator.

Template Parameters
Tprimitive data type
ITERTiterator type

Member Typedef Documentation

template<typename T, typename ITERT = pni::core::string::const_iterator>
typedef boost::spirit::qi::expectation_failure<iterator_type> pni::io::parser< T, ITERT >::expectation_error
template<typename T, typename ITERT = pni::core::string::const_iterator>
typedef ITERT pni::io::parser< T, ITERT >::iterator_type
template<typename T, typename ITERT = pni::core::string::const_iterator>
typedef trait_type::read_type pni::io::parser< T, ITERT >::read_type
private
template<typename T, typename ITERT = pni::core::string::const_iterator>
typedef T pni::io::parser< T, ITERT >::result_type
template<typename T, typename ITERT = pni::core::string::const_iterator>
typedef conversion_trait<result_type> pni::io::parser< T, ITERT >::trait_type
private

Member Function Documentation

template<typename T, typename ITERT = pni::core::string::const_iterator>
result_type pni::io::parser< T, ITERT >::operator() ( const pni::core::string &  data) const
inline

Parses the input string and returns an instance of a primitive type. In case of errors parser_error is thrown.

Exceptions
parser_errorin case of any problems
Parameters
datathe string with input data
Returns
instance of the primitive type

Field Documentation

template<typename T, typename ITERT = pni::core::string::const_iterator>
get_rule_type<iterator_type,read_type>::type pni::io::parser< T, ITERT >::_rule
private

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