mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 20:42:24 +02:00
Made JsonNodeType private
This commit is contained in:
@ -1,23 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class JsonBuffer;
|
class JsonBuffer;
|
||||||
|
|
||||||
enum JsonNodeType
|
|
||||||
{
|
|
||||||
JSON_UNDEFINED,
|
|
||||||
JSON_NULL,
|
|
||||||
JSON_ARRAY,
|
|
||||||
JSON_OBJECT,
|
|
||||||
JSON_KEY_VALUE,
|
|
||||||
JSON_BOOLEAN,
|
|
||||||
JSON_STRING,
|
|
||||||
JSON_LONG,
|
|
||||||
JSON_DOUBLE_0_DECIMALS,
|
|
||||||
JSON_DOUBLE_1_DECIMAL,
|
|
||||||
JSON_DOUBLE_2_DECIMALS,
|
|
||||||
// etc.
|
|
||||||
};
|
|
||||||
|
|
||||||
class JsonWriter;
|
class JsonWriter;
|
||||||
class JsonNodeIterator;
|
class JsonNodeIterator;
|
||||||
|
|
||||||
@ -25,6 +8,48 @@ class JsonNode
|
|||||||
{
|
{
|
||||||
friend class JsonNodeIterator;
|
friend class JsonNodeIterator;
|
||||||
|
|
||||||
|
enum JsonNodeType
|
||||||
|
{
|
||||||
|
JSON_UNDEFINED,
|
||||||
|
JSON_NULL,
|
||||||
|
JSON_ARRAY,
|
||||||
|
JSON_OBJECT,
|
||||||
|
JSON_KEY_VALUE,
|
||||||
|
JSON_BOOLEAN,
|
||||||
|
JSON_STRING,
|
||||||
|
JSON_LONG,
|
||||||
|
JSON_DOUBLE_0_DECIMALS,
|
||||||
|
JSON_DOUBLE_1_DECIMAL,
|
||||||
|
JSON_DOUBLE_2_DECIMALS,
|
||||||
|
// etc.
|
||||||
|
};
|
||||||
|
|
||||||
|
union JsonNodeContent
|
||||||
|
{
|
||||||
|
bool asBoolean;
|
||||||
|
double asDouble;
|
||||||
|
long asInteger;
|
||||||
|
const char* asString;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
const char* key;
|
||||||
|
JsonNode* value;
|
||||||
|
} asKey;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
JsonNode* child;
|
||||||
|
JsonBuffer* buffer;
|
||||||
|
} asContainer;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
JsonNode* target;
|
||||||
|
} asProxy;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JsonNode()
|
JsonNode()
|
||||||
: type(JSON_UNDEFINED), next(0)
|
: type(JSON_UNDEFINED), next(0)
|
||||||
@ -124,35 +149,10 @@ public:
|
|||||||
void removeChildFromContainer(JsonNode* childToRemove);
|
void removeChildFromContainer(JsonNode* childToRemove);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNodeType type; // <- TODO: hide
|
|
||||||
JsonNode* next;
|
JsonNode* next;
|
||||||
|
JsonNodeContent content;
|
||||||
|
JsonNodeType type;
|
||||||
|
|
||||||
inline void writeArrayTo(JsonWriter&);// TODO: <- move in JsonNodeSerializer
|
inline void writeArrayTo(JsonWriter&);// TODO: <- move in JsonNodeSerializer
|
||||||
inline void writeObjectTo(JsonWriter&);// TODO: <- move in JsonNodeSerializer
|
inline void writeObjectTo(JsonWriter&);// TODO: <- move in JsonNodeSerializer
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
bool asBoolean;
|
|
||||||
double asDouble;
|
|
||||||
long asInteger;
|
|
||||||
const char* asString;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
const char* key;
|
|
||||||
JsonNode* value;
|
|
||||||
} asKey;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
JsonNode* child;
|
|
||||||
JsonBuffer* buffer;
|
|
||||||
} asContainer;
|
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
JsonNode* target;
|
|
||||||
} asProxy;
|
|
||||||
|
|
||||||
} content;
|
|
||||||
};
|
};
|
@ -70,14 +70,4 @@ JsonNode* JsonObject::getOrCreateNodeAt(const char* key)
|
|||||||
addChild(newKeyNode);
|
addChild(newKeyNode);
|
||||||
|
|
||||||
return newValueNode;
|
return newValueNode;
|
||||||
}
|
|
||||||
|
|
||||||
JsonNode* JsonObject::createContainerNodeAt(char const* key, JsonNodeType type)
|
|
||||||
{
|
|
||||||
JsonNode* node = getOrCreateNodeAt(key);
|
|
||||||
if (!node) return 0;
|
|
||||||
|
|
||||||
node->setAsArray(_node->getContainerBuffer());
|
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
}
|
@ -23,5 +23,4 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode* getOrCreateNodeAt(const char* key);
|
JsonNode* getOrCreateNodeAt(const char* key);
|
||||||
JsonNode* createContainerNodeAt(const char* key, JsonNodeType type);
|
|
||||||
};
|
};
|
Reference in New Issue
Block a user