Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::date_time::string_parse_tree< charT > Struct Template Reference

Recursive data structure to allow efficient parsing of various strings. More...

#include <string_parse_tree.hpp>

Inheritance diagram for boost::date_time::string_parse_tree< charT >:
Collaboration diagram for boost::date_time::string_parse_tree< charT >:

Public Types

typedef std::multimap< charT,
string_parse_tree
ptree_coll
 
typedef ptree_coll::value_type value_type
 
typedef ptree_coll::iterator iterator
 
typedef ptree_coll::const_iterator const_iterator
 
typedef std::basic_string< charT > string_type
 
typedef std::vector
< std::basic_string< charT > > 
collection_type
 
typedef parse_match_result< charT > parse_match_result_type
 

Public Member Functions

 string_parse_tree (collection_type names, unsigned int starting_point=0)
 Parameter "starting_point" designates where the numbering begins. More...
 
 string_parse_tree (short value=-1)
 
void insert (const string_type &s, unsigned short value)
 
short match (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end, parse_match_result_type &result, unsigned int &level) const
 Recursive function that finds a matching string in the tree. More...
 
parse_match_result_type match (std::istreambuf_iterator< charT > &sitr, std::istreambuf_iterator< charT > &stream_end) const
 Must check match_results::has_remaining() after match() is called. More...
 
void printme (std::ostream &os, int &level)
 
void print (std::ostream &os)
 
void printmatch (std::ostream &os, charT c)
 

Public Attributes

ptree_coll m_next_chars
 
short m_value
 

Detailed Description

template<typename charT>
struct boost::date_time::string_parse_tree< charT >

Recursive data structure to allow efficient parsing of various strings.

This class provides a quick lookup by building what amounts to a tree data structure. It also features a match function which can can handle nasty input interators by caching values as it recurses the tree so that it can backtrack as needed.

Member Typedef Documentation

template<typename charT>
typedef std::vector<std::basic_string<charT> > boost::date_time::string_parse_tree< charT >::collection_type
template<typename charT>
typedef ptree_coll::const_iterator boost::date_time::string_parse_tree< charT >::const_iterator
template<typename charT>
typedef ptree_coll::iterator boost::date_time::string_parse_tree< charT >::iterator
template<typename charT>
typedef parse_match_result<charT> boost::date_time::string_parse_tree< charT >::parse_match_result_type
template<typename charT>
typedef std::multimap<charT, string_parse_tree > boost::date_time::string_parse_tree< charT >::ptree_coll
template<typename charT>
typedef std::basic_string<charT> boost::date_time::string_parse_tree< charT >::string_type
template<typename charT>
typedef ptree_coll::value_type boost::date_time::string_parse_tree< charT >::value_type

Constructor & Destructor Documentation

template<typename charT>
boost::date_time::string_parse_tree< charT >::string_parse_tree ( collection_type  names,
unsigned int  starting_point = 0 
)
inline

Parameter "starting_point" designates where the numbering begins.

A starting_point of zero will start the numbering at zero (Sun=0, Mon=1, ...) were a starting_point of one starts the numbering at one (Jan=1, Feb=2, ...). The default is zero, negative vaules are not allowed

template<typename charT>
boost::date_time::string_parse_tree< charT >::string_parse_tree ( short  value = -1)
inline

Member Function Documentation

template<typename charT>
void boost::date_time::string_parse_tree< charT >::insert ( const string_type s,
unsigned short  value 
)
inline
template<typename charT>
short boost::date_time::string_parse_tree< charT >::match ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end,
parse_match_result_type result,
unsigned int &  level 
) const
inline

Recursive function that finds a matching string in the tree.

Must check match_results::has_remaining() after match() is called. This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream).

A parse_match_result that has been returned from a failed match attempt can be sent in to the match function of a different string_parse_tree to attempt a match there. Use the iterators for the partially consumed stream, the parse_match_result object, and '0' for the level parameter.

Referenced by boost::date_time::date_generator_parser< time_type::date_type, CharT >::get_nth_kday_type(), boost::date_time::special_values_parser< time_type::date_type, CharT >::match(), boost::date_time::string_parse_tree< CharT >::match(), boost::date_time::format_date_parser< time_type::date_type, CharT >::parse_date(), boost::date_time::format_date_parser< time_type::date_type, CharT >::parse_month(), and boost::date_time::format_date_parser< time_type::date_type, CharT >::parse_weekday().

template<typename charT>
parse_match_result_type boost::date_time::string_parse_tree< charT >::match ( std::istreambuf_iterator< charT > &  sitr,
std::istreambuf_iterator< charT > &  stream_end 
) const
inline

Must check match_results::has_remaining() after match() is called.

This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream).

template<typename charT>
void boost::date_time::string_parse_tree< charT >::print ( std::ostream &  os)
inline
template<typename charT>
void boost::date_time::string_parse_tree< charT >::printmatch ( std::ostream &  os,
charT  c 
)
inline
template<typename charT>
void boost::date_time::string_parse_tree< charT >::printme ( std::ostream &  os,
int &  level 
)
inline

Member Data Documentation

template<typename charT>
ptree_coll boost::date_time::string_parse_tree< charT >::m_next_chars
template<typename charT>
short boost::date_time::string_parse_tree< charT >::m_value

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