diff options
author | Manoj Srivastava <srivasta@debian.org> | 2020-05-23 00:33:19 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2020-05-23 00:33:19 -0700 |
commit | d6b913d3ca2e84b75f3675fd6e9f5246c100cf27 (patch) | |
tree | 5fc28b7efc737bf2c79dc7d799e0a6013957fe11 /vendor/jsoncons-0.99.2/jsoncons_ext/boost | |
parent | c42f029316c0c004a795ca170bdb50644a800534 (diff) | |
parent | 73a0259be1d44fdb2ab34266ae0ff63f0d8f0b60 (diff) |
Merge branch 'master' into dgit/siddebian/2.4.0-ah-1archive/debian/2.4.0-ah-1
Diffstat (limited to 'vendor/jsoncons-0.99.2/jsoncons_ext/boost')
-rw-r--r-- | vendor/jsoncons-0.99.2/jsoncons_ext/boost/type_extensions.hpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/vendor/jsoncons-0.99.2/jsoncons_ext/boost/type_extensions.hpp b/vendor/jsoncons-0.99.2/jsoncons_ext/boost/type_extensions.hpp new file mode 100644 index 00000000..59936cd7 --- /dev/null +++ b/vendor/jsoncons-0.99.2/jsoncons_ext/boost/type_extensions.hpp @@ -0,0 +1,59 @@ +// Copyright 2013 Daniel Parker +// Distributed under the Boost license, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See https://github.com/danielaparker/jsoncons for latest version + +#ifndef JSONCONS_EXT_TYPE_EXTENSIONS_HPP +#define JSONCONS_EXT_TYPE_EXTENSIONS_HPP + +#include "jsoncons/json.hpp" +#include "boost/date_time/gregorian/gregorian.hpp" + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" +#endif + +namespace jsoncons +{ + template <typename JsonT> + class json_type_traits<JsonT,boost::gregorian::date> + { + public: + static bool is(const JsonT& val) JSONCONS_NOEXCEPT + { + if (!val.is_string()) + { + return false; + } + std::string s = val.template as<std::string>(); + try + { + boost::gregorian::date_from_iso_string(s); + return true; + } + catch (...) + { + return false; + } + } + + static boost::gregorian::date as(const JsonT& val) + { + std::string s = val.template as<std::string>(); + return boost::gregorian::from_simple_string(s); + } + + static void assign(JsonT& lhs, boost::gregorian::date val) + { + lhs = to_iso_extended_string(val); + } + }; +} + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +#endif |