...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::date_time::special_values_parser — Class for special_value parsing.
// In header: <boost/date_time/special_values_parser.hpp> template<typename date_type, typename charT> class special_values_parser { public: // types typedef std::basic_string< charT > string_type; typedef std::basic_stringstream< charT > stringstream_type; typedef std::istreambuf_iterator< charT > stream_itr_type; typedef date_type::duration_type duration_type; typedef string_parse_tree< charT > parse_tree_type; typedef parse_tree_type::parse_match_result_type match_results; typedef std::vector< std::basic_string< charT > > collection_type; typedef charT char_type; // construct/copy/destruct special_values_parser(); special_values_parser(const string_type &, const string_type &, const string_type &, const string_type &, const string_type &); special_values_parser(typename collection_type::iterator, typename collection_type::iterator); special_values_parser(const special_values_parser< date_type, charT > &); // public member functions void sv_strings(const string_type &, const string_type &, const string_type &, const string_type &, const string_type &); bool match(stream_itr_type &, stream_itr_type &, match_results &) const; // public static functions static bool likely(const string_type &); // public data members static const char_type nadt_string; static const char_type neg_inf_string; static const char_type pos_inf_string; static const char_type min_date_time_string; static const char_type max_date_time_string; };
TODO: add doc-comments for which elements can be changed Parses input stream for strings representing special_values. Special values parsed are:
not_a_date_time
neg_infin
pod_infin
min_date_time
max_date_time
special_values_parser
public
construct/copy/destructspecial_values_parser();Creates a
special_values_parser
with the default set of "sv_strings". special_values_parser(const string_type & nadt_str, const string_type & neg_inf_str, const string_type & pos_inf_str, const string_type & min_dt_str, const string_type & max_dt_str);Creates a
special_values_parser
using a user defined set of element strings. special_values_parser(typename collection_type::iterator beg, typename collection_type::iterator end);
special_values_parser(const special_values_parser< date_type, charT > & svp);
special_values_parser
public member functionsvoid sv_strings(const string_type & nadt_str, const string_type & neg_inf_str, const string_type & pos_inf_str, const string_type & min_dt_str, const string_type & max_dt_str);Replace special value strings.
bool match(stream_itr_type & sitr, stream_itr_type & str_end, match_results & mr) const;
Given an input iterator, attempt to match it to a known special value
Parameters: |
|
||||||
Returns: |
whether something matched |
special_values_parser
public static functionsstatic bool likely(const string_type & str);
The parser is expensive to create, and not thread-safe so it cannot be static therefore given a string, determine if it is likely to be a special value. A negative response is a definite no, whereas a positive is only likely and match() should be called and return value checked.
Parameters: |
|
||
Returns: |
false if it is definitely not a special value |