Huge refactoring in progress...

This commit is contained in:
Benoit Blanchon
2014-10-30 10:49:02 +01:00
parent 5cf744dbac
commit c3001e9ea9
9 changed files with 119 additions and 103 deletions

View File

@ -14,14 +14,14 @@
namespace ArduinoJson {
class JsonObject : public JsonPrintable {
friend class JsonBuffer;
public:
typedef const char *key_type;
typedef JsonPair value_type;
typedef JsonObjectIterator iterator;
typedef JsonObjectConstIterator const_iterator;
JsonObject(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {}
int size() const;
JsonValue &operator[](key_type key);
@ -29,16 +29,11 @@ class JsonObject : public JsonPrintable {
template <typename T>
void add(key_type key, T value) {
(*this)[key] = value;
add(key).set(value);
}
void add(key_type key, JsonArray &nestedArray) {
(*this)[key] = nestedArray;
}
void add(key_type key, JsonObject &nestedObject) {
(*this)[key] = nestedObject;
}
void add(key_type key, JsonArray &array) { add(key).set(array); }
void add(key_type key, JsonObject &object) { add(key).set(object); }
JsonArray &createNestedArray(key_type key);
JsonObject &createNestedObject(key_type key);
@ -54,9 +49,14 @@ class JsonObject : public JsonPrintable {
virtual void writeTo(Internals::JsonWriter &writer) const;
private:
JsonObject(const JsonObject&); // copy is forbidden, use a reference instead
JsonObject& operator=(const JsonObject&); // copy is forbidden, use a reference instead
// 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]; }
void addNode(Internals::JsonObjectNode *nodeToAdd);
void removeNode(Internals::JsonObjectNode *nodeToRemove);