mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 08:48:27 +01:00
Epic refactoring in progress...
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JsonBuffer.hpp"
|
||||
#include "../ForwardDeclarations.hpp"
|
||||
#include "JsonArrayIterator.hpp"
|
||||
#include "JsonArrayConstIterator.hpp"
|
||||
|
||||
@@ -20,13 +20,15 @@ class JsonArrayImpl {
|
||||
|
||||
JsonArrayImpl(JsonBuffer *buffer) : _buffer(buffer) {}
|
||||
|
||||
value_type *operator[](int index) const;
|
||||
value_type operator[](int index) const;
|
||||
|
||||
value_type *add();
|
||||
value_type add();
|
||||
|
||||
JsonArrayImpl *createNestedArray();
|
||||
JsonObjectImpl *createNestedObject();
|
||||
|
||||
void writeTo(JsonWriter &writer) const;
|
||||
|
||||
iterator begin() { return iterator(_firstChild); }
|
||||
iterator end() { return iterator(0); }
|
||||
|
||||
|
||||
45
include/ArduinoJson/Internals/JsonObjectImpl.hpp
Normal file
45
include/ArduinoJson/Internals/JsonObjectImpl.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright Benoit Blanchon 2014
|
||||
// MIT License
|
||||
//
|
||||
// Arduino JSON library
|
||||
// https://github.com/bblanchon/ArduinoJson
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JsonObjectConstIterator.hpp"
|
||||
#include "JsonObjectIterator.hpp"
|
||||
#include "JsonObjectNode.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
namespace Internals {
|
||||
class JsonObjectImpl {
|
||||
public:
|
||||
typedef const char *key_type;
|
||||
typedef JsonPair value_type;
|
||||
typedef JsonObjectIterator iterator;
|
||||
typedef JsonObjectConstIterator const_iterator;
|
||||
|
||||
JsonObjectImpl(JsonBuffer *buffer) : _buffer(buffer) {}
|
||||
|
||||
JsonValueImpl *operator[](const char *key) { return getOrCreateValueAt(key); }
|
||||
void remove(key_type key);
|
||||
|
||||
JsonArrayImpl *createNestedArray(key_type key);
|
||||
JsonObjectImpl *createNestedObject(key_type key);
|
||||
|
||||
iterator begin() { return iterator(_firstChild); }
|
||||
iterator end() { return iterator(0); }
|
||||
|
||||
const_iterator begin() const { return const_iterator(_firstChild); }
|
||||
const_iterator end() const { return const_iterator(0); }
|
||||
|
||||
private:
|
||||
JsonObjectNode *getNodeAt(key_type key);
|
||||
void removeNode(JsonObjectNode *nodeToRemove);
|
||||
JsonValueImpl *getOrCreateValueAt(key_type key);
|
||||
|
||||
JsonBuffer *_buffer;
|
||||
JsonObjectNode *_firstChild;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,14 @@ namespace Internals {
|
||||
|
||||
class JsonSerializer {
|
||||
public:
|
||||
static writeTo(JsonValue& value, JsonWriter&);
|
||||
JsonSerializer(JsonWriter &writer) : _writer(writer) {}
|
||||
|
||||
void serialize(JsonValueImpl *value);
|
||||
void serialize(JsonArrayImpl *value);
|
||||
void serialize(JsonObjectImpl *value);
|
||||
|
||||
private:
|
||||
inline void writeArrayTo(JsonValue& value, JsonWriter&);
|
||||
inline void writeObjectTo(JsonValue& value, JsonWriter&);
|
||||
JsonWriter &_writer;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,8 @@ class JsonValueImpl {
|
||||
return _type == JSON_OBJECT ? _content.asObject : NULL;
|
||||
}
|
||||
|
||||
void writeTo(JsonWriter &writer) const;
|
||||
|
||||
private:
|
||||
Internals::JsonValueType _type;
|
||||
Internals::JsonValueContent _content;
|
||||
|
||||
Reference in New Issue
Block a user