Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Writer.hpp Source File

Writer.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Namespace.hpp>
00008 
00009 namespace ARDUINOJSON_NAMESPACE {
00010 
00011 // The default writer is a simple wrapper for Writers that are not copiable
00012 template <typename TDestination, typename Enable = void>
00013 class Writer {
00014  public:
00015   explicit Writer(TDestination& dest) : _dest(&dest) {}
00016 
00017   size_t write(uint8_t c) {
00018     return _dest->write(c);
00019   }
00020 
00021   size_t write(const uint8_t* s, size_t n) {
00022     return _dest->write(s, n);
00023   }
00024 
00025  private:
00026   TDestination* _dest;
00027 };
00028 
00029 }  // namespace ARDUINOJSON_NAMESPACE
00030 
00031 #include <ArduinoJson/Serialization/Writers/StaticStringWriter.hpp>
00032 
00033 #if ARDUINOJSON_ENABLE_STD_STRING
00034 #include <ArduinoJson/Serialization/Writers/StdStringWriter.hpp>
00035 #endif
00036 
00037 #if ARDUINOJSON_ENABLE_ARDUINO_STRING
00038 #include <ArduinoJson/Serialization/Writers/ArduinoStringWriter.hpp>
00039 #endif
00040 
00041 #if ARDUINOJSON_ENABLE_STD_STREAM
00042 #include <ArduinoJson/Serialization/Writers/StdStreamWriter.hpp>
00043 #endif
00044 
00045 #if ARDUINOJSON_ENABLE_ARDUINO_PRINT
00046 #include <ArduinoJson/Serialization/Writers/PrintWriter.hpp>
00047 #endif