File indexing completed on 2025-01-18 09:30:35
0001 #ifndef GREGORIAN_PARSERS_HPP___
0002 #define GREGORIAN_PARSERS_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <boost/date_time/gregorian/gregorian_types.hpp>
0013 #include <boost/date_time/date_parsing.hpp>
0014 #include <boost/date_time/compiler_config.hpp>
0015 #include <boost/date_time/parse_format_base.hpp>
0016 #include <boost/date_time/special_defs.hpp>
0017 #include <boost/date_time/find_match.hpp>
0018 #include <string>
0019 #include <iterator>
0020
0021 namespace boost {
0022 namespace gregorian {
0023
0024
0025
0026
0027
0028 inline
0029 date_time::special_values
0030 special_value_from_string(const std::string& s) {
0031 static const char* const special_value_names[date_time::NumSpecialValues]
0032 = {"not-a-date-time","-infinity","+infinity","min_date_time",
0033 "max_date_time","not_special"};
0034
0035 short i = date_time::find_match(special_value_names,
0036 special_value_names,
0037 date_time::NumSpecialValues,
0038 s);
0039 if(i >= date_time::NumSpecialValues) {
0040 return date_time::not_special;
0041 }
0042 else {
0043 return static_cast<date_time::special_values>(i);
0044 }
0045 }
0046
0047
0048 inline date from_string(const std::string& s) {
0049 return date_time::parse_date<date>(s);
0050 }
0051
0052
0053 inline date from_simple_string(const std::string& s) {
0054 return date_time::parse_date<date>(s, date_time::ymd_order_iso);
0055 }
0056
0057
0058 inline date from_us_string(const std::string& s) {
0059 return date_time::parse_date<date>(s, date_time::ymd_order_us);
0060 }
0061
0062
0063 inline date from_uk_string(const std::string& s) {
0064 return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
0065 }
0066
0067
0068 inline date from_undelimited_string(const std::string& s) {
0069 return date_time::parse_undelimited_date<date>(s);
0070 }
0071
0072
0073 inline date date_from_iso_string(const std::string& s) {
0074 return date_time::parse_undelimited_date<date>(s);
0075 }
0076
0077 #if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
0078
0079
0080
0081
0082 template<class iterator_type>
0083 inline date from_stream(iterator_type beg, iterator_type end) {
0084 if(beg == end)
0085 {
0086 return date(not_a_date_time);
0087 }
0088 typedef typename std::iterator_traits<iterator_type>::value_type value_type;
0089 return date_time::from_stream_type<date>(beg, end, value_type());
0090 }
0091 #endif
0092
0093 #if (defined(_MSC_VER) && (_MSC_VER < 1300))
0094
0095 #else
0096
0097 inline date_period date_period_from_string(const std::string& s){
0098 return date_time::from_simple_string_type<date,char>(s);
0099 }
0100 # if !defined(BOOST_NO_STD_WSTRING)
0101
0102 inline date_period date_period_from_wstring(const std::wstring& s){
0103 return date_time::from_simple_string_type<date,wchar_t>(s);
0104 }
0105 # endif
0106 #endif
0107
0108 } }
0109
0110 #endif