summaryrefslogtreecommitdiff
path: root/boost/date_time/time_parsing.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:12:59 +0900
commitb8cf34c691623e4ec329053cbbf68522a855882d (patch)
tree34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/date_time/time_parsing.hpp
parent3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff)
downloadboost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz
boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2
boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/date_time/time_parsing.hpp')
-rw-r--r--boost/date_time/time_parsing.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/boost/date_time/time_parsing.hpp b/boost/date_time/time_parsing.hpp
index 6de4b7dbde..5fa7e8d2c5 100644
--- a/boost/date_time/time_parsing.hpp
+++ b/boost/date_time/time_parsing.hpp
@@ -12,6 +12,7 @@
#include "boost/tokenizer.hpp"
#include "boost/lexical_cast.hpp"
#include "boost/date_time/date_parsing.hpp"
+#include "boost/date_time/special_values_parser.hpp"
#include "boost/cstdint.hpp"
#include <iostream>
@@ -302,6 +303,25 @@ namespace date_time {
{
typedef typename time_type::time_duration_type time_duration;
typedef typename time_type::date_type date_type;
+ typedef special_values_parser<date_type, std::string::value_type> svp_type;
+
+ // given to_iso_string can produce a special value string
+ // then from_iso_string should be able to read a special value string
+ // the special_values_parser is expensive to set up and not thread-safe
+ // so it cannot be static, so we need to be careful about when we use it
+ if (svp_type::likely(s)) {
+ typedef typename svp_type::stringstream_type ss_type;
+ typedef typename svp_type::stream_itr_type itr_type;
+ typedef typename svp_type::match_results mr_type;
+ svp_type p; // expensive
+ mr_type mr;
+ ss_type ss(s);
+ itr_type itr(ss);
+ itr_type end;
+ if (p.match(itr, end, mr)) {
+ return time_type(static_cast<special_values>(mr.current_match));
+ }
+ }
//split date/time on a unique delimiter char such as ' ' or 'T'
std::string date_string, tod_string;