-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for custom reader classes
- Loading branch information
Showing
17 changed files
with
261 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// ArduinoJson - arduinojson.org | ||
// Copyright Benoit Blanchon 2014-2019 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include <sstream> | ||
|
||
class CustomReader { | ||
std::stringstream _stream; | ||
|
||
public: | ||
CustomReader(const char* input) : _stream(input) {} | ||
|
||
int read() { | ||
return _stream.get(); | ||
} | ||
|
||
size_t readBytes(char* buffer, size_t length) { | ||
_stream.read(buffer, static_cast<std::streamsize>(length)); | ||
return static_cast<size_t>(_stream.gcount()); | ||
} | ||
|
||
private: | ||
CustomReader(const CustomReader&); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ArduinoJson - arduinojson.org | ||
// Copyright Benoit Blanchon 2014-2019 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include <ArduinoJson/Namespace.hpp> | ||
|
||
#include <stdlib.h> // for size_t | ||
|
||
namespace ARDUINOJSON_NAMESPACE { | ||
|
||
// The default reader is a simple wrapper for Readers that are not copiable | ||
template <typename TSource, typename Enable = void> | ||
struct Reader { | ||
public: | ||
Reader(TSource& source) : _source(&source) {} | ||
|
||
int read() { | ||
return _source->read(); | ||
} | ||
|
||
size_t readBytes(char* buffer, size_t length) { | ||
return _source->readBytes(buffer, length); | ||
} | ||
|
||
private: | ||
TSource* _source; | ||
}; | ||
|
||
template <typename TSource, typename Enable = void> | ||
struct BoundedReader { | ||
// no default implementation because we need to pass the size to the | ||
// constructor | ||
}; | ||
} // namespace ARDUINOJSON_NAMESPACE | ||
|
||
#include <ArduinoJson/Deserialization/Readers/IteratorReader.hpp> | ||
#include <ArduinoJson/Deserialization/Readers/RamReader.hpp> | ||
|
||
#if ARDUINOJSON_ENABLE_ARDUINO_STREAM | ||
#include <ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp> | ||
#endif | ||
|
||
#if ARDUINOJSON_ENABLE_ARDUINO_STRING | ||
#include <ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp> | ||
#endif | ||
|
||
#if ARDUINOJSON_ENABLE_PROGMEM | ||
#include <ArduinoJson/Deserialization/Readers/FlashReader.hpp> | ||
#endif | ||
|
||
#if ARDUINOJSON_ENABLE_STD_STREAM | ||
#include <ArduinoJson/Deserialization/Readers/StdStreamReader.hpp> | ||
#endif |
Oops, something went wrong.