|
|
@@ -8,30 +8,28 @@
|
|
|
|
|
|
namespace ARDUINOJSON_NAMESPACE {
|
|
|
|
|
|
-template <template <typename> class TSerializer, typename TSource,
|
|
|
- typename TWriter>
|
|
|
-size_t doSerialize(const TSource &source, TWriter writer) {
|
|
|
+template <template <typename> class TSerializer, typename TWriter>
|
|
|
+size_t doSerialize(VariantConstRef source, TWriter writer) {
|
|
|
TSerializer<TWriter> serializer(writer);
|
|
|
return source.accept(serializer);
|
|
|
}
|
|
|
|
|
|
-template <template <typename> class TSerializer, typename TSource,
|
|
|
- typename TDestination>
|
|
|
-size_t serialize(const TSource &source, TDestination &destination) {
|
|
|
+template <template <typename> class TSerializer, typename TDestination>
|
|
|
+size_t serialize(VariantConstRef source, TDestination &destination) {
|
|
|
Writer<TDestination> writer(destination);
|
|
|
return doSerialize<TSerializer>(source, writer);
|
|
|
}
|
|
|
|
|
|
-template <template <typename> class TSerializer, typename TSource>
|
|
|
+template <template <typename> class TSerializer>
|
|
|
typename enable_if<!TSerializer<StaticStringWriter>::producesText, size_t>::type
|
|
|
-serialize(const TSource &source, void *buffer, size_t bufferSize) {
|
|
|
+serialize(VariantConstRef source, void *buffer, size_t bufferSize) {
|
|
|
StaticStringWriter writer(reinterpret_cast<char *>(buffer), bufferSize);
|
|
|
return doSerialize<TSerializer>(source, writer);
|
|
|
}
|
|
|
|
|
|
-template <template <typename> class TSerializer, typename TSource>
|
|
|
+template <template <typename> class TSerializer>
|
|
|
typename enable_if<TSerializer<StaticStringWriter>::producesText, size_t>::type
|
|
|
-serialize(const TSource &source, void *buffer, size_t bufferSize) {
|
|
|
+serialize(VariantConstRef source, void *buffer, size_t bufferSize) {
|
|
|
StaticStringWriter writer(reinterpret_cast<char *>(buffer), bufferSize);
|
|
|
size_t n = doSerialize<TSerializer>(source, writer);
|
|
|
// add null-terminator for text output (not counted in the size)
|
|
|
@@ -40,14 +38,13 @@ serialize(const TSource &source, void *buffer, size_t bufferSize) {
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
-template <template <typename> class TSerializer, typename TSource,
|
|
|
- typename TChar, size_t N>
|
|
|
+template <template <typename> class TSerializer, typename TChar, size_t N>
|
|
|
#if defined _MSC_VER && _MSC_VER < 1900
|
|
|
typename enable_if<sizeof(remove_reference<TChar>::type) == 1, size_t>::type
|
|
|
#else
|
|
|
typename enable_if<sizeof(TChar) == 1, size_t>::type
|
|
|
#endif
|
|
|
-serialize(const TSource &source, TChar (&buffer)[N]) {
|
|
|
+serialize(VariantConstRef source, TChar (&buffer)[N]) {
|
|
|
return serialize<TSerializer>(source, buffer, N);
|
|
|
}
|
|
|
|