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>
18namespace JsonReflector {
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);
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);
45 pull(str, value, errors);
47 reflectable = CppUtilities::DateTime::fromIsoStringGmt(str.data());
48 }
catch (
const CppUtilities::ConversionException &) {
60 pull(str, value, errors);
62 reflectable = CppUtilities::TimeSpan::fromString(str.data());
63 }
catch (
const CppUtilities::ConversionException &) {
Contains functions to (de)serialize basic types such as int, double, bool, std::string,...
void pull(Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue< RAPIDJSON_NAMESPACE::UTF8< char > >::ConstObject &value, JsonDeserializationErrors *errors)
Pulls the reflectable which has a custom type from the specified object.
void push< CppUtilities::TimeSpan >(const CppUtilities::TimeSpan &reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
void push< CppUtilities::DateTime >(const CppUtilities::DateTime &reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator)
void pull< CppUtilities::DateTime >(CppUtilities::DateTime &reflectable, const RAPIDJSON_NAMESPACE::GenericValue< RAPIDJSON_NAMESPACE::UTF8< char > > &value, JsonDeserializationErrors *errors)
constexpr RAPIDJSON_NAMESPACE::SizeType rapidJsonSize(std::size_t size)
Casts the specified size to the size type used by RapidJSON ensuring no overflow happens.
void pull< CppUtilities::TimeSpan >(CppUtilities::TimeSpan &reflectable, const RAPIDJSON_NAMESPACE::GenericValue< RAPIDJSON_NAMESPACE::UTF8< char > > &value, JsonDeserializationErrors *errors)
The JsonDeserializationErrors struct can be passed to fromJson() for error handling.
void reportConversionError(JsonType jsonType)
Reports a conversion error.