annotate DEPENDENCIES/generic/include/boost/date_time/gregorian/parsers.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef GREGORIAN_PARSERS_HPP___
Chris@16 2 #define GREGORIAN_PARSERS_HPP___
Chris@16 3
Chris@16 4 /* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
Chris@16 5 * Use, modification and distribution is subject to the
Chris@16 6 * Boost Software License, Version 1.0. (See accompanying
Chris@16 7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 * Author: Jeff Garland, Bart Garst
Chris@101 9 * $Date$
Chris@16 10 */
Chris@16 11
Chris@16 12 #include "boost/date_time/gregorian/gregorian_types.hpp"
Chris@16 13 #include "boost/date_time/date_parsing.hpp"
Chris@16 14 #include "boost/date_time/compiler_config.hpp"
Chris@16 15 #include "boost/date_time/parse_format_base.hpp"
Chris@16 16 #include <string>
Chris@16 17 #include <sstream>
Chris@16 18
Chris@16 19 namespace boost {
Chris@16 20 namespace gregorian {
Chris@16 21
Chris@16 22 //! Return special_value from string argument
Chris@16 23 /*! Return special_value from string argument. If argument is
Chris@16 24 * not one of the special value names (defined in src/gregorian/names.hpp),
Chris@16 25 * return 'not_special' */
Chris@16 26 BOOST_DATE_TIME_DECL special_values special_value_from_string(const std::string& s);
Chris@16 27
Chris@16 28 //! Deprecated: Use from_simple_string
Chris@16 29 inline date from_string(std::string s) {
Chris@16 30 return date_time::parse_date<date>(s);
Chris@16 31 }
Chris@16 32
Chris@16 33 //! From delimited date string where with order year-month-day eg: 2002-1-25 or 2003-Jan-25 (full month name is also accepted)
Chris@16 34 inline date from_simple_string(std::string s) {
Chris@16 35 return date_time::parse_date<date>(s, date_time::ymd_order_iso);
Chris@16 36 }
Chris@16 37
Chris@16 38 //! From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted)
Chris@16 39 inline date from_us_string(std::string s) {
Chris@16 40 return date_time::parse_date<date>(s, date_time::ymd_order_us);
Chris@16 41 }
Chris@16 42
Chris@16 43 //! From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted)
Chris@16 44 inline date from_uk_string(std::string s) {
Chris@16 45 return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
Chris@16 46 }
Chris@16 47
Chris@16 48 //! From iso type date string where with order year-month-day eg: 20020125
Chris@16 49 inline date from_undelimited_string(std::string s) {
Chris@16 50 return date_time::parse_undelimited_date<date>(s);
Chris@16 51 }
Chris@16 52
Chris@16 53 //! From iso type date string where with order year-month-day eg: 20020125
Chris@16 54 inline date date_from_iso_string(const std::string& s) {
Chris@16 55 return date_time::parse_undelimited_date<date>(s);
Chris@16 56 }
Chris@16 57
Chris@16 58 #if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
Chris@16 59 //! Stream should hold a date in the form of: 2002-1-25. Month number, abbrev, or name are accepted
Chris@16 60 /* Arguments passed in by-value for convertability of char[]
Chris@16 61 * to iterator_type. Calls to from_stream_type are by-reference
Chris@16 62 * since conversion is already done */
Chris@16 63 template<class iterator_type>
Chris@16 64 inline date from_stream(iterator_type beg, iterator_type end) {
Chris@16 65 if(beg == end)
Chris@16 66 {
Chris@16 67 return date(not_a_date_time);
Chris@16 68 }
Chris@16 69 typedef typename std::iterator_traits<iterator_type>::value_type value_type;
Chris@16 70 return date_time::from_stream_type<date>(beg, end, value_type());
Chris@16 71 }
Chris@16 72 #endif //BOOST_NO_STD_ITERATOR_TRAITS
Chris@16 73
Chris@16 74 #if (defined(_MSC_VER) && (_MSC_VER < 1300))
Chris@16 75 // This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
Chris@16 76 #else
Chris@16 77 //! Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25])
Chris@16 78 inline date_period date_period_from_string(const std::string& s){
Chris@16 79 return date_time::from_simple_string_type<date,char>(s);
Chris@16 80 }
Chris@16 81 # if !defined(BOOST_NO_STD_WSTRING)
Chris@16 82 //! Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25])
Chris@16 83 inline date_period date_period_from_wstring(const std::wstring& s){
Chris@16 84 return date_time::from_simple_string_type<date,wchar_t>(s);
Chris@16 85 }
Chris@16 86 # endif // BOOST_NO_STD_WSTRING
Chris@16 87 #endif
Chris@16 88
Chris@16 89 } } //namespace gregorian
Chris@16 90
Chris@16 91 #endif