]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/date_time/gregorian/parsers.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / date_time / gregorian / parsers.hpp
CommitLineData
7c673cae
FG
1#ifndef GREGORIAN_PARSERS_HPP___
2#define GREGORIAN_PARSERS_HPP___
3
4/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
5 * Use, modification and distribution is subject to the
6 * Boost Software License, Version 1.0. (See accompanying
7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8 * Author: Jeff Garland, Bart Garst
9 * $Date$
10 */
11
f67539c2
TL
12#include <boost/date_time/gregorian/gregorian_types.hpp>
13#include <boost/date_time/date_parsing.hpp>
14#include <boost/date_time/compiler_config.hpp>
15#include <boost/date_time/parse_format_base.hpp>
16#include <boost/date_time/special_defs.hpp>
17#include <boost/date_time/find_match.hpp>
7c673cae 18#include <string>
f67539c2 19#include <iterator>
7c673cae
FG
20
21namespace boost {
22namespace gregorian {
23
24 //! Return special_value from string argument
f67539c2
TL
25 /*! Return special_value from string argument. If argument is
26 * not one of the special value names (defined in names.hpp),
7c673cae 27 * return 'not_special' */
f67539c2
TL
28 inline
29 date_time::special_values
30 special_value_from_string(const std::string& s) {
31 static const char* const special_value_names[date_time::NumSpecialValues]
32 = {"not-a-date-time","-infinity","+infinity","min_date_time",
33 "max_date_time","not_special"};
34
35 short i = date_time::find_match(special_value_names,
36 special_value_names,
37 date_time::NumSpecialValues,
38 s);
39 if(i >= date_time::NumSpecialValues) { // match not found
40 return date_time::not_special;
41 }
42 else {
43 return static_cast<date_time::special_values>(i);
44 }
45 }
7c673cae
FG
46
47 //! Deprecated: Use from_simple_string
f67539c2 48 inline date from_string(const std::string& s) {
7c673cae
FG
49 return date_time::parse_date<date>(s);
50 }
51
52 //! From delimited date string where with order year-month-day eg: 2002-1-25 or 2003-Jan-25 (full month name is also accepted)
f67539c2 53 inline date from_simple_string(const std::string& s) {
7c673cae
FG
54 return date_time::parse_date<date>(s, date_time::ymd_order_iso);
55 }
56
57 //! From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted)
f67539c2 58 inline date from_us_string(const std::string& s) {
7c673cae
FG
59 return date_time::parse_date<date>(s, date_time::ymd_order_us);
60 }
61
62 //! From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted)
f67539c2 63 inline date from_uk_string(const std::string& s) {
7c673cae
FG
64 return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
65 }
66
67 //! From iso type date string where with order year-month-day eg: 20020125
f67539c2 68 inline date from_undelimited_string(const std::string& s) {
7c673cae
FG
69 return date_time::parse_undelimited_date<date>(s);
70 }
71
72 //! From iso type date string where with order year-month-day eg: 20020125
73 inline date date_from_iso_string(const std::string& s) {
74 return date_time::parse_undelimited_date<date>(s);
75 }
76
77#if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
78 //! Stream should hold a date in the form of: 2002-1-25. Month number, abbrev, or name are accepted
79 /* Arguments passed in by-value for convertability of char[]
80 * to iterator_type. Calls to from_stream_type are by-reference
81 * since conversion is already done */
82 template<class iterator_type>
83 inline date from_stream(iterator_type beg, iterator_type end) {
84 if(beg == end)
85 {
86 return date(not_a_date_time);
87 }
88 typedef typename std::iterator_traits<iterator_type>::value_type value_type;
89 return date_time::from_stream_type<date>(beg, end, value_type());
90 }
91#endif //BOOST_NO_STD_ITERATOR_TRAITS
92
93#if (defined(_MSC_VER) && (_MSC_VER < 1300))
94 // This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
95#else
96 //! Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25])
97 inline date_period date_period_from_string(const std::string& s){
98 return date_time::from_simple_string_type<date,char>(s);
99 }
100# if !defined(BOOST_NO_STD_WSTRING)
101 //! Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25])
102 inline date_period date_period_from_wstring(const std::wstring& s){
103 return date_time::from_simple_string_type<date,wchar_t>(s);
104 }
105# endif // BOOST_NO_STD_WSTRING
106#endif
107
108} } //namespace gregorian
109
110#endif