1 #ifndef REFLECTIVE_RAPIDJSON_JSON_REFLECTOR_CHRONO_UTILITIES_H
2 #define REFLECTIVE_RAPIDJSON_JSON_REFLECTOR_CHRONO_UTILITIES_H
13 #include <c++utilities/chrono/datetime.h>
14 #include <c++utilities/chrono/timespan.h>
15 #include <c++utilities/conversion/conversionexception.h>
18 namespace JsonReflector {
23 inline void push<CppUtilities::DateTime>(
24 const CppUtilities::DateTime &reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
26 const std::string str(reflectable.toIsoString());
27 value.SetString(str.data(),
rapidJsonSize(str.size()), allocator);
31 inline void push<CppUtilities::TimeSpan>(
32 const CppUtilities::TimeSpan &reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
34 const std::string str(reflectable.toString());
35 value.SetString(str.data(),
rapidJsonSize(str.size()), allocator);
41 inline void pull<CppUtilities::DateTime>(CppUtilities::DateTime &reflectable,
45 pull(str, value, errors);
47 reflectable = CppUtilities::DateTime::fromIsoStringGmt(str.data());
48 }
catch (
const CppUtilities::ConversionException &) {
56 inline void pull<CppUtilities::TimeSpan>(CppUtilities::TimeSpan &reflectable,
60 pull(str, value, errors);
62 reflectable = CppUtilities::TimeSpan::fromString(str.data());
63 }
catch (
const CppUtilities::ConversionException &) {
73 #endif // REFLECTIVE_RAPIDJSON_JSON_REFLECTOR_CHRONO_UTILITIES_H