// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2018 // MIT License #pragma once #include "../JsonBuffer.hpp" #include "../JsonVariant.hpp" #include "../StringTraits/StringTraits.hpp" #include "../TypeTraits/EnableIf.hpp" namespace ArduinoJson { namespace Internals { template struct ValueSaver { template static bool save(JsonBuffer*, Destination& destination, Source source) { destination = source; return true; } }; template struct ValueSaver< Source, typename EnableIf::should_duplicate>::type> { template static bool save(JsonBuffer* buffer, Destination& dest, Source source) { if (!StringTraits::is_null(source)) { typename StringTraits::duplicate_t dup = StringTraits::duplicate(source, buffer); if (!dup) return false; dest = dup; } else { dest = reinterpret_cast(0); } return true; } }; // const char*, const signed char*, const unsigned char* template struct ValueSaver< Char*, typename EnableIf::should_duplicate>::type> { template static bool save(JsonBuffer*, Destination& dest, Char* source) { dest = reinterpret_cast(source); return true; } }; } }