forked from bblanchon/ArduinoJson
All tests passed!
This commit is contained in:
@ -18,9 +18,6 @@ class JsonObjectNode {
|
||||
|
||||
JsonPair pair;
|
||||
JsonObjectNode* next;
|
||||
|
||||
// warning C4512: assignment operator could not be generated
|
||||
#pragma warning( suppress : 4512 )
|
||||
};
|
||||
}
|
||||
}
|
||||
|
25
include/ArduinoJson/Internals/NonCopyable.hpp
Normal file
25
include/ArduinoJson/Internals/NonCopyable.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright Benoit Blanchon 2014
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
|
||||
// A class that is not meant to be copied
|
||||
class NonCopyable {
|
||||
protected:
|
||||
NonCopyable() {}
|
||||
|
||||
private:
|
||||
// copy constructor is private
|
||||
NonCopyable(const NonCopyable&);
|
||||
|
||||
// copy operator is private
|
||||
NonCopyable& operator=(const NonCopyable&);
|
||||
};
|
||||
}
|
||||
}
|
@ -11,10 +11,14 @@
|
||||
#include "JsonArrayConstIterator.hpp"
|
||||
#include "JsonPrintable.hpp"
|
||||
#include "JsonObject.hpp"
|
||||
#include "Internals/NonCopyable.hpp"
|
||||
|
||||
#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
(sizeof(JsonArray) + (NUMBER_OF_ELEMENTS) * sizeof(Internals::JsonArrayNode))
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
class JsonArray : public JsonPrintable {
|
||||
class JsonArray : public JsonPrintable, Internals::NonCopyable {
|
||||
friend class JsonBuffer;
|
||||
|
||||
public:
|
||||
@ -56,10 +60,6 @@ class JsonArray : public JsonPrintable {
|
||||
// constructor is private: instance must be created via a JsonBuffer
|
||||
JsonArray(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {}
|
||||
|
||||
// copy is forbidden, use a reference instead
|
||||
JsonArray(const JsonArray &);
|
||||
JsonArray &operator=(const JsonArray &);
|
||||
|
||||
Internals::JsonArrayNode *createNode();
|
||||
inline void addNode(Internals::JsonArrayNode *node);
|
||||
|
||||
|
@ -6,15 +6,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Internals/JsonObjectNode.hpp"
|
||||
#include "Internals/NonCopyable.hpp"
|
||||
#include "JsonArray.hpp"
|
||||
#include "JsonObjectConstIterator.hpp"
|
||||
#include "JsonObjectIterator.hpp"
|
||||
#include "JsonPrintable.hpp"
|
||||
#include "Internals/JsonObjectNode.hpp"
|
||||
#include "JsonArray.hpp"
|
||||
|
||||
#define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
(sizeof(JsonObject) + \
|
||||
(NUMBER_OF_ELEMENTS) * sizeof(Internals::JsonObjectNode))
|
||||
|
||||
namespace ArduinoJson {
|
||||
|
||||
class JsonObject : public JsonPrintable {
|
||||
class JsonObject : public JsonPrintable, Internals::NonCopyable {
|
||||
friend class JsonBuffer;
|
||||
|
||||
public:
|
||||
@ -55,10 +60,6 @@ class JsonObject : public JsonPrintable {
|
||||
// constructor is private, instance must be created via JsonBuffer
|
||||
JsonObject(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {}
|
||||
|
||||
JsonObject(const JsonObject &); // copy is forbidden, use a reference instead
|
||||
JsonObject &operator=(
|
||||
const JsonObject &); // copy is forbidden, use a reference instead
|
||||
|
||||
JsonValue &add(key_type key) { return (*this)[key]; }
|
||||
Internals::JsonObjectNode *createNode(key_type key);
|
||||
void addNode(Internals::JsonObjectNode *nodeToAdd);
|
||||
|
@ -14,10 +14,7 @@ namespace ArduinoJson {
|
||||
struct JsonPair {
|
||||
JsonPair(const char* k) : key(k) {}
|
||||
|
||||
const char* const key;
|
||||
const char* key;
|
||||
JsonValue value;
|
||||
|
||||
// warning C4512: assignment operator could not be generated
|
||||
#pragma warning( suppress : 4512 )
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user