Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template string_parse_tree

boost::date_time::string_parse_tree — Recursive data structure to allow efficient parsing of various strings.

Synopsis

// In header: <boost/date_time/string_parse_tree.hpp>

template<typename charT> 
struct string_parse_tree {
  // types
  typedef charT, string_parse_tree< charT > > ;             
  typedef charT, string_parse_tree >          ;             
  typedef                              ;             
  typedef                                ;               
  typedef                          ;         
  typedef charT >                         ;            
  typedef charT > >          ;        
  typedef parse_match_result< charT >                        ;

  // construct/copy/destruct
  (, unsigned int = );
  (short = );

  // public member functions
  void (const , unsigned short);
  short (charT > &, 
              charT > &, parse_match_result_type &, 
              unsigned int &) ;
  parse_match_result_type 
  (charT > &, 
        charT > &) ;
  void (, int &);
  void ();
  void (, charT);

  // public data members
   m_next_chars;
  short m_value;
};

Description

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.

string_parse_tree public construct/copy/destruct

  1. ( names, unsigned int starting_point = );

    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

  2. (short value = );

string_parse_tree public member functions

  1. void (const  s, unsigned short value);
  2. short (charT > & sitr, 
                charT > & stream_end, 
                parse_match_result_type & result, unsigned int & level) ;
    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.

  3. parse_match_result_type 
    (charT > & sitr, 
          charT > & stream_end) ;

    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).

  4. void ( os, int & level);
  5. void ( os);
  6. void ( os, charT c);

PrevUpHomeNext