123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #ifndef GREGORIAN_PARSERS_HPP___
- #define GREGORIAN_PARSERS_HPP___
- #include <boost/date_time/gregorian/gregorian_types.hpp>
- #include <boost/date_time/date_parsing.hpp>
- #include <boost/date_time/compiler_config.hpp>
- #include <boost/date_time/parse_format_base.hpp>
- #include <boost/date_time/special_defs.hpp>
- #include <boost/date_time/find_match.hpp>
- #include <string>
- #include <iterator>
- namespace boost {
- namespace gregorian {
-
-
- inline
- date_time::special_values
- special_value_from_string(const std::string& s) {
- static const char* const special_value_names[date_time::NumSpecialValues]
- = {"not-a-date-time","-infinity","+infinity","min_date_time",
- "max_date_time","not_special"};
- short i = date_time::find_match(special_value_names,
- special_value_names,
- date_time::NumSpecialValues,
- s);
- if(i >= date_time::NumSpecialValues) {
- return date_time::not_special;
- }
- else {
- return static_cast<date_time::special_values>(i);
- }
- }
-
- inline date from_string(const std::string& s) {
- return date_time::parse_date<date>(s);
- }
-
- inline date from_simple_string(const std::string& s) {
- return date_time::parse_date<date>(s, date_time::ymd_order_iso);
- }
-
-
- inline date from_us_string(const std::string& s) {
- return date_time::parse_date<date>(s, date_time::ymd_order_us);
- }
-
-
- inline date from_uk_string(const std::string& s) {
- return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
- }
-
-
- inline date from_undelimited_string(const std::string& s) {
- return date_time::parse_undelimited_date<date>(s);
- }
-
- inline date date_from_iso_string(const std::string& s) {
- return date_time::parse_undelimited_date<date>(s);
- }
- #if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
-
-
- template<class iterator_type>
- inline date from_stream(iterator_type beg, iterator_type end) {
- if(beg == end)
- {
- return date(not_a_date_time);
- }
- typedef typename std::iterator_traits<iterator_type>::value_type value_type;
- return date_time::from_stream_type<date>(beg, end, value_type());
- }
- #endif
-
- #if (defined(_MSC_VER) && (_MSC_VER < 1300))
-
- #else
-
- inline date_period date_period_from_string(const std::string& s){
- return date_time::from_simple_string_type<date,char>(s);
- }
- # if !defined(BOOST_NO_STD_WSTRING)
-
- inline date_period date_period_from_wstring(const std::wstring& s){
- return date_time::from_simple_string_type<date,wchar_t>(s);
- }
- # endif
- #endif
- } }
- #endif
|