Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
JsonObjectStream.h
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/anakod/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * JsonObjectStream.h
8  *
9  ****/
10 
11 #ifndef _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_
12 #define _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_
13 
14 #include "MemoryDataStream.h"
15 #include "../Libraries/ArduinoJson/include/ArduinoJson.h"
16 
24 {
25 public:
28  JsonObjectStream() : rootNode(buffer.createObject())
29  {
30  }
31 
32  //Use base class documentation
33  StreamType getStreamType() const override
34  {
35  return eSST_JsonObject;
36  }
37 
41  JsonObject& getRoot()
42  {
43  return rootNode;
44  }
45 
46  //Use base class documentation
47  uint16_t readMemoryBlock(char* data, int bufSize) override;
48 
53  int available() override
54  {
55  return rootNode.success() ? rootNode.measureLength() : 0;
56  }
57 
58 private:
59  DynamicJsonBuffer buffer;
60  JsonObject& rootNode;
61  bool send = true;
62 };
63 
65 #endif /* _SMING_CORE_DATA_STREAM_JSON_OBJECT_STREAM_H_ */
uint16_t readMemoryBlock(char *data, int bufSize) override
Read a block of memory.
StreamType getStreamType() const override
Get the stream type.
Definition: JsonObjectStream.h:33
JsonObject stream class.
Definition: JsonObjectStream.h:23
JSON object data stream.
Definition: DataSourceStream.h:27
int available() override
Return the total length of the stream.
Definition: JsonObjectStream.h:53
StreamType
Data stream type.
Definition: DataSourceStream.h:22
JsonObjectStream()
Create a JSON object stream.
Definition: JsonObjectStream.h:28
JsonObject & getRoot()
Get the JSON root node.
Definition: JsonObjectStream.h:41
Definition: MemoryDataStream.h:29