Explorar o código

Renamed srcs/ into src/

Benoit Blanchon %!s(int64=11) %!d(string=hai) anos
pai
achega
58d2c4a62f

+ 1 - 1
CMakeLists.txt

@@ -3,5 +3,5 @@ project(ArduinoJson)
 
 enable_testing()
 
-add_subdirectory(srcs)
+add_subdirectory(src)
 add_subdirectory(test)

+ 39 - 39
srcs/Arduino/Print.cpp → src/Arduino/Print.cpp

@@ -1,40 +1,40 @@
-/*
- * Arduino JSON library
- * Benoit Blanchon 2014 - MIT License
- */
-
-#ifndef ARDUINO
-
-#include "ArduinoJson/Arduino/Print.h"
-#include <cstdio>
-
-size_t Print::print(const char s[])
-{
-    size_t n = 0;
-    while (*s)
-    {
-        n += write(*s++);
-    }
-    return n;
-}
-
-size_t Print::print(double value, int digits)
-{
-    char tmp[32];
-    sprintf(tmp, "%.*lg", digits+1, value);
-    return print(tmp);
-}
-
-size_t Print::print(long value)
-{
-    char tmp[32];
-    sprintf(tmp, "%ld", value);
-    return print(tmp);
-}
-
-size_t Print::println()
-{
-    return write('\r') + write('\n');
-}
-
+/*
+ * Arduino JSON library
+ * Benoit Blanchon 2014 - MIT License
+ */
+
+#ifndef ARDUINO
+
+#include "ArduinoJson/Arduino/Print.h"
+#include <cstdio>
+
+size_t Print::print(const char s[])
+{
+    size_t n = 0;
+    while (*s)
+    {
+        n += write(*s++);
+    }
+    return n;
+}
+
+size_t Print::print(double value, int digits)
+{
+    char tmp[32];
+    sprintf(tmp, "%.*lg", digits+1, value);
+    return print(tmp);
+}
+
+size_t Print::print(long value)
+{
+    char tmp[32];
+    sprintf(tmp, "%ld", value);
+    return print(tmp);
+}
+
+size_t Print::println()
+{
+    return write('\r') + write('\n');
+}
+
 #endif

+ 5 - 5
srcs/CMakeLists.txt → src/CMakeLists.txt

@@ -1,6 +1,6 @@
-file(GLOB_RECURSE INC_FILES ../include/*.h)
-file(GLOB_RECURSE SRC_FILES *.cpp)
-
-include_directories(../include)
-
+file(GLOB_RECURSE INC_FILES ../include/*.h)
+file(GLOB_RECURSE SRC_FILES *.cpp)
+
+include_directories(../include)
+
 add_library(ArduinoJson ${SRC_FILES} ${INC_FILES})

+ 1 - 1
srcs/Internals/CompactJsonWriter.cpp → src/Internals/CompactJsonWriter.cpp

@@ -1 +1 @@
-#include "ArduinoJson/Internals/CompactJsonWriter.h"
+#include "ArduinoJson/Internals/CompactJsonWriter.h"

+ 44 - 44
srcs/Internals/EscapedString.cpp → src/Internals/EscapedString.cpp

@@ -1,45 +1,45 @@
-/*
- * Arduino JSON library
- * Benoit Blanchon 2014 - MIT License
- */
-
-#include "ArduinoJson/Internals/EscapedString.h"
-
-using namespace ArduinoJson::Internals;
-
-static inline char getSpecialChar(char c)
-{
-    // Optimized for code size on a 8-bit AVR
-
-    const char* p = "\"\"\\\\\bb\ff\nn\rr\tt\0";
-
-    while (p[0] && p[0] != c)
-    {
-        p += 2;
-    }
-
-    return p[1];
-}
-
-static inline size_t printCharTo(char c, Print* p)
-{
-    char specialChar = getSpecialChar(c);
-
-    return specialChar != 0
-        ? p->write('\\') + p->write(specialChar)
-        : p->write(c);
-}
-
-size_t EscapedString::printTo(const char* s, Print* p)
-{
-    if (!s) return p->print("null");
-    
-    size_t n = p->write('\"');
-
-    while (*s)
-    {
-        n += printCharTo(*s++, p);
-    }
-
-    return n + p->write('\"');
+/*
+ * Arduino JSON library
+ * Benoit Blanchon 2014 - MIT License
+ */
+
+#include "ArduinoJson/Internals/EscapedString.h"
+
+using namespace ArduinoJson::Internals;
+
+static inline char getSpecialChar(char c)
+{
+    // Optimized for code size on a 8-bit AVR
+
+    const char* p = "\"\"\\\\\bb\ff\nn\rr\tt\0";
+
+    while (p[0] && p[0] != c)
+    {
+        p += 2;
+    }
+
+    return p[1];
+}
+
+static inline size_t printCharTo(char c, Print* p)
+{
+    char specialChar = getSpecialChar(c);
+
+    return specialChar != 0
+        ? p->write('\\') + p->write(specialChar)
+        : p->write(c);
+}
+
+size_t EscapedString::printTo(const char* s, Print* p)
+{
+    if (!s) return p->print("null");
+    
+    size_t n = p->write('\"');
+
+    while (*s)
+    {
+        n += printCharTo(*s++, p);
+    }
+
+    return n + p->write('\"');
 }

+ 44 - 44
srcs/Internals/IndentedPrint.cpp → src/Internals/IndentedPrint.cpp

@@ -1,45 +1,45 @@
-#include "ArduinoJson/Internals/IndentedPrint.h"
-
-using namespace ArduinoJson::Generator;
-
-void IndentedPrint::indent()
-{
-    if (level < MAX_LEVEL)
-        level++;
-}
-
-void IndentedPrint::unindent()
-{
-    if (level > 0)
-        level--;
-}
-
-void IndentedPrint::setTabSize(uint8_t n)
-{
-    if (n < MAX_TAB_SIZE)
-        tabSize = n;
-}
-
-size_t IndentedPrint::write(uint8_t c)
-{
-    size_t n = 0;
-
-    if (isNewLine)
-        n += writeTabs();
-
-    n += sink->write(c);
-
-    isNewLine = c == '\n';
-
-    return n;
-}
-
-inline size_t IndentedPrint::writeTabs()
-{
-    size_t n = 0;
-
-    for (int i = 0; i < level*tabSize; i++)
-        n += sink->write(' ');
-
-    return n;
+#include "ArduinoJson/Internals/IndentedPrint.h"
+
+using namespace ArduinoJson::Generator;
+
+void IndentedPrint::indent()
+{
+    if (level < MAX_LEVEL)
+        level++;
+}
+
+void IndentedPrint::unindent()
+{
+    if (level > 0)
+        level--;
+}
+
+void IndentedPrint::setTabSize(uint8_t n)
+{
+    if (n < MAX_TAB_SIZE)
+        tabSize = n;
+}
+
+size_t IndentedPrint::write(uint8_t c)
+{
+    size_t n = 0;
+
+    if (isNewLine)
+        n += writeTabs();
+
+    n += sink->write(c);
+
+    isNewLine = c == '\n';
+
+    return n;
+}
+
+inline size_t IndentedPrint::writeTabs()
+{
+    size_t n = 0;
+
+    for (int i = 0; i < level*tabSize; i++)
+        n += sink->write(' ');
+
+    return n;
 }

+ 165 - 165
srcs/Internals/JsonNode.cpp → src/Internals/JsonNode.cpp

@@ -1,166 +1,166 @@
-#include "ArduinoJson/Internals/JsonNode.h"
-
-#include "ArduinoJson/Internals/JsonWriter.h"
-#include "ArduinoJson/JsonArray.h"
-#include "ArduinoJson/JsonObject.h"
-#include "ArduinoJson/JsonBuffer.h"
-
-void JsonNode::writeTo(JsonWriter& writer)
-{
-    switch (type)
-    {
-    case JSON_PROXY:
-        content.asProxy.target->writeTo(writer);
-        break;
-
-    case JSON_ARRAY:
-        writeArrayTo(writer);
-        break;
-
-    case JSON_OBJECT:
-        writeObjectTo(writer);
-        break;
-
-    case JSON_STRING:
-        writer.writeString(content.asString);
-        break;
-
-    case JSON_LONG:
-        writer.writeInteger(content.asInteger);
-        break;
-
-    case JSON_BOOLEAN:
-        writer.writeBoolean(content.asBoolean);
-        break;
-
-    default: // >= JSON_DOUBLE_0_DECIMALS
-        writer.writeDouble(content.asDouble, type - JSON_DOUBLE_0_DECIMALS);
-        break;
-    }
-}
-
-void JsonNode::addChild(JsonNode* childToAdd)
-{
-    if (type == JSON_PROXY) 
-        return content.asProxy.target->addChild(childToAdd);
-
-    if (type != JSON_ARRAY && type != JSON_OBJECT) 
-        return;
-
-    JsonNode* lastChild = content.asContainer.child;
-
-    if (!lastChild)
-    {
-        content.asContainer.child = childToAdd;
-        return;
-    }
-
-    while (lastChild->next)
-        lastChild = lastChild->next;
-
-    lastChild->next = childToAdd;
-}
-
-void JsonNode::removeChild(JsonNode* childToRemove)
-{
-    if (type == JSON_PROXY)
-        return content.asProxy.target->removeChild(childToRemove);
-
-    if (type != JSON_ARRAY && type != JSON_OBJECT) return;
-
-    if (content.asContainer.child == childToRemove)
-    {
-        content.asContainer.child = childToRemove->next;
-        return;
-    }
-
-    for (JsonNode* child = content.asContainer.child; child; child = child->next)
-    {
-        if (child->next == childToRemove)
-            child->next = childToRemove->next;
-    }
-}
-
-void JsonNode::writeArrayTo(JsonWriter& writer)
-{
-    JsonNode* child = content.asContainer.child;
-
-    if (child)
-    {
-        writer.beginArray();
-
-        for (;;)
-        {
-            child->writeTo(writer);
-
-            child = child->next;
-            if (!child) break;
-            
-            writer.writeComma();
-        } 
-
-        writer.endArray();
-    }
-    else
-    {
-        writer.writeEmptyArray();
-    }
-}
-
-void JsonNode::writeObjectTo(JsonWriter& writer)
-{
-    JsonNode* child = content.asContainer.child;
-
-    if (child)
-    {
-        writer.beginObject();
-
-        for (;;)
-        {
-            writer.writeString(child->content.asKey.key);
-            writer.writeColon();
-            child->content.asKey.value->writeTo(writer);
-
-            child = child->next;
-            if (!child) break;
-
-            writer.writeComma();
-        }
-
-        writer.endObject();
-    }
-    else
-    {
-        writer.writeEmptyObject();
-    }
-}
-
-void JsonNode::setAsProxyOfSelf()
-{
-    JsonBuffer* buffer = content.asContainer.buffer;
-    if (!buffer) return;
-        
-    JsonNode* newNode = buffer->createNode(); 
-    if (!newNode) return;
-
-    *newNode = *this;
-
-    setAsProxyOf(newNode);
-}
-
-void JsonNode::duplicate(JsonNode* other)
-{
-    if (!other)
-    {
-        type = JSON_UNDEFINED;
-    }
-    else  if (other->type == JSON_ARRAY || other->type==JSON_OBJECT)
-    {
-        other->setAsProxyOfSelf();
-        setAsProxyOf(other->content.asProxy.target);
-    }
-    else
-    {
-        *this = *other;
-    }
+#include "ArduinoJson/Internals/JsonNode.h"
+
+#include "ArduinoJson/Internals/JsonWriter.h"
+#include "ArduinoJson/JsonArray.h"
+#include "ArduinoJson/JsonObject.h"
+#include "ArduinoJson/JsonBuffer.h"
+
+void JsonNode::writeTo(JsonWriter& writer)
+{
+    switch (type)
+    {
+    case JSON_PROXY:
+        content.asProxy.target->writeTo(writer);
+        break;
+
+    case JSON_ARRAY:
+        writeArrayTo(writer);
+        break;
+
+    case JSON_OBJECT:
+        writeObjectTo(writer);
+        break;
+
+    case JSON_STRING:
+        writer.writeString(content.asString);
+        break;
+
+    case JSON_LONG:
+        writer.writeInteger(content.asInteger);
+        break;
+
+    case JSON_BOOLEAN:
+        writer.writeBoolean(content.asBoolean);
+        break;
+
+    default: // >= JSON_DOUBLE_0_DECIMALS
+        writer.writeDouble(content.asDouble, type - JSON_DOUBLE_0_DECIMALS);
+        break;
+    }
+}
+
+void JsonNode::addChild(JsonNode* childToAdd)
+{
+    if (type == JSON_PROXY) 
+        return content.asProxy.target->addChild(childToAdd);
+
+    if (type != JSON_ARRAY && type != JSON_OBJECT) 
+        return;
+
+    JsonNode* lastChild = content.asContainer.child;
+
+    if (!lastChild)
+    {
+        content.asContainer.child = childToAdd;
+        return;
+    }
+
+    while (lastChild->next)
+        lastChild = lastChild->next;
+
+    lastChild->next = childToAdd;
+}
+
+void JsonNode::removeChild(JsonNode* childToRemove)
+{
+    if (type == JSON_PROXY)
+        return content.asProxy.target->removeChild(childToRemove);
+
+    if (type != JSON_ARRAY && type != JSON_OBJECT) return;
+
+    if (content.asContainer.child == childToRemove)
+    {
+        content.asContainer.child = childToRemove->next;
+        return;
+    }
+
+    for (JsonNode* child = content.asContainer.child; child; child = child->next)
+    {
+        if (child->next == childToRemove)
+            child->next = childToRemove->next;
+    }
+}
+
+void JsonNode::writeArrayTo(JsonWriter& writer)
+{
+    JsonNode* child = content.asContainer.child;
+
+    if (child)
+    {
+        writer.beginArray();
+
+        for (;;)
+        {
+            child->writeTo(writer);
+
+            child = child->next;
+            if (!child) break;
+            
+            writer.writeComma();
+        } 
+
+        writer.endArray();
+    }
+    else
+    {
+        writer.writeEmptyArray();
+    }
+}
+
+void JsonNode::writeObjectTo(JsonWriter& writer)
+{
+    JsonNode* child = content.asContainer.child;
+
+    if (child)
+    {
+        writer.beginObject();
+
+        for (;;)
+        {
+            writer.writeString(child->content.asKey.key);
+            writer.writeColon();
+            child->content.asKey.value->writeTo(writer);
+
+            child = child->next;
+            if (!child) break;
+
+            writer.writeComma();
+        }
+
+        writer.endObject();
+    }
+    else
+    {
+        writer.writeEmptyObject();
+    }
+}
+
+void JsonNode::setAsProxyOfSelf()
+{
+    JsonBuffer* buffer = content.asContainer.buffer;
+    if (!buffer) return;
+        
+    JsonNode* newNode = buffer->createNode(); 
+    if (!newNode) return;
+
+    *newNode = *this;
+
+    setAsProxyOf(newNode);
+}
+
+void JsonNode::duplicate(JsonNode* other)
+{
+    if (!other)
+    {
+        type = JSON_UNDEFINED;
+    }
+    else  if (other->type == JSON_ARRAY || other->type==JSON_OBJECT)
+    {
+        other->setAsProxyOfSelf();
+        setAsProxyOf(other->content.asProxy.target);
+    }
+    else
+    {
+        *this = *other;
+    }
 }

+ 0 - 0
srcs/Internals/JsonParser.cpp → src/Internals/JsonParser.cpp


+ 24 - 24
srcs/Internals/JsonWriter.cpp → src/Internals/JsonWriter.cpp

@@ -1,25 +1,25 @@
-#include "ArduinoJson/Internals/JsonWriter.h"
-#include "ArduinoJson/Internals/EscapedString.h"
-
-using namespace ArduinoJson::Internals;
-
-void JsonWriter::writeString(char const* value)
-{
-    _length += EscapedString::printTo(value, _sink);
-}
-
-void JsonWriter::writeInteger(long value)
-{
-
-    _length += _sink->print(value);
-}
-
-void JsonWriter::writeBoolean(bool value)
-{
-    _length += _sink->print(value ? "true" : "false");
-}
-
-void JsonWriter::writeDouble(double value, int decimals)
-{
-    _length += _sink->print(value, decimals);
+#include "ArduinoJson/Internals/JsonWriter.h"
+#include "ArduinoJson/Internals/EscapedString.h"
+
+using namespace ArduinoJson::Internals;
+
+void JsonWriter::writeString(char const* value)
+{
+    _length += EscapedString::printTo(value, _sink);
+}
+
+void JsonWriter::writeInteger(long value)
+{
+
+    _length += _sink->print(value);
+}
+
+void JsonWriter::writeBoolean(bool value)
+{
+    _length += _sink->print(value ? "true" : "false");
+}
+
+void JsonWriter::writeDouble(double value, int decimals)
+{
+    _length += _sink->print(value, decimals);
 }

+ 1 - 1
srcs/Internals/PrettyJsonWriter.cpp → src/Internals/PrettyJsonWriter.cpp

@@ -1 +1 @@
-#include "ArduinoJson/Internals/PrettyJsonWriter.h"
+#include "ArduinoJson/Internals/PrettyJsonWriter.h"

+ 16 - 16
srcs/Internals/StringBuilder.cpp → src/Internals/StringBuilder.cpp

@@ -1,17 +1,17 @@
-/*
- * Arduino JSON library
- * Benoit Blanchon 2014 - MIT License
- */
-
-#include "ArduinoJson/Internals/StringBuilder.h"
-
-using namespace ArduinoJson::Internals;
-
-size_t StringBuilder::write(uint8_t c)
-{
-    if (length >= capacity) return 0;
-
-    buffer[length++] = c;
-    buffer[length] = 0;
-    return 1;
+/*
+ * Arduino JSON library
+ * Benoit Blanchon 2014 - MIT License
+ */
+
+#include "ArduinoJson/Internals/StringBuilder.h"
+
+using namespace ArduinoJson::Internals;
+
+size_t StringBuilder::write(uint8_t c)
+{
+    if (length >= capacity) return 0;
+
+    buffer[length++] = c;
+    buffer[length] = 0;
+    return 1;
 }

+ 85 - 85
srcs/JsonArray.cpp → src/JsonArray.cpp

@@ -1,86 +1,86 @@
-#include "ArduinoJson/JsonArray.h"
-#include "ArduinoJson/JsonObject.h"
-#include "ArduinoJson/JsonValue.h"
-
-JsonValue JsonArray::operator[](int index) const
-{
-    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
-    {
-        if (!index) return JsonValue(*it);
-        index--;
-    }
-
-    return JsonValue();
-}
-
-void JsonArray::add(bool value)
-{
-    JsonNode* node = createNode();
-    if (!node) return;
-
-    node->setAsBoolean(value);
-    addChild(node);
-}
-
-void JsonArray::add(char const* value)
-{
-    JsonNode* node = createNode();
-    if (!node) return;
-
-    node->setAsString(value);
-    addChild(node);
-}
-
-void JsonArray::add(double value, int decimals)
-{
-    JsonNode* node = createNode();
-    if (!node) return;
-
-    node->setAsDouble(value, decimals);
-    addChild(node);
-}
-
-void JsonArray::add(long value)
-{
-    JsonNode* node = createNode();
-    if (!node) return;
-
-    node->setAsLong(value);
-    addChild(node);
-}
-
-// TODO: we should have the same issue as in JsonValue
-void JsonArray::add(JsonContainer nestedContainer)
-{
-    JsonNode* node = createNode();
-    if (!node) return;
-
-    node->duplicate(nestedContainer._node);
-    addChild(node);
-}
-
-JsonArray JsonArray::createNestedArray()
-{
-    JsonNode* node = createNode();
-    
-    if (node)
-    {
-        node->setAsArray(_node->getContainerBuffer());
-        addChild(node);
-    }
-    
-    return JsonArray(node);
-}
-
-JsonObject JsonArray::createNestedObject()
-{
-    JsonNode* node = createNode();
-    
-    if (node)
-    {
-        node->setAsObject(_node->getContainerBuffer());
-        addChild(node);
-    }
-    
-    return JsonObject(node);
+#include "ArduinoJson/JsonArray.h"
+#include "ArduinoJson/JsonObject.h"
+#include "ArduinoJson/JsonValue.h"
+
+JsonValue JsonArray::operator[](int index) const
+{
+    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
+    {
+        if (!index) return JsonValue(*it);
+        index--;
+    }
+
+    return JsonValue();
+}
+
+void JsonArray::add(bool value)
+{
+    JsonNode* node = createNode();
+    if (!node) return;
+
+    node->setAsBoolean(value);
+    addChild(node);
+}
+
+void JsonArray::add(char const* value)
+{
+    JsonNode* node = createNode();
+    if (!node) return;
+
+    node->setAsString(value);
+    addChild(node);
+}
+
+void JsonArray::add(double value, int decimals)
+{
+    JsonNode* node = createNode();
+    if (!node) return;
+
+    node->setAsDouble(value, decimals);
+    addChild(node);
+}
+
+void JsonArray::add(long value)
+{
+    JsonNode* node = createNode();
+    if (!node) return;
+
+    node->setAsLong(value);
+    addChild(node);
+}
+
+// TODO: we should have the same issue as in JsonValue
+void JsonArray::add(JsonContainer nestedContainer)
+{
+    JsonNode* node = createNode();
+    if (!node) return;
+
+    node->duplicate(nestedContainer._node);
+    addChild(node);
+}
+
+JsonArray JsonArray::createNestedArray()
+{
+    JsonNode* node = createNode();
+    
+    if (node)
+    {
+        node->setAsArray(_node->getContainerBuffer());
+        addChild(node);
+    }
+    
+    return JsonArray(node);
+}
+
+JsonObject JsonArray::createNestedObject()
+{
+    JsonNode* node = createNode();
+    
+    if (node)
+    {
+        node->setAsObject(_node->getContainerBuffer());
+        addChild(node);
+    }
+    
+    return JsonObject(node);
 }

+ 85 - 85
srcs/JsonBuffer.cpp → src/JsonBuffer.cpp

@@ -1,86 +1,86 @@
-#include "ArduinoJson/JsonBuffer.h"
-
-#include <new>
-
-#include "ArduinoJson/JsonValue.h"
-#include "ArduinoJson/Internals/JsonParser.h"
-#include "ArduinoJson/Internals/JsonNode.h"
-
-JsonValue JsonBuffer::createValue()
-{
-    return JsonValue(createNode());
-}
-
-JsonNode* JsonBuffer::createNode()
-{
-    void* node = allocateNode();
-    if (!node) return 0;
-        
-    return new (node) JsonNode();
-}
-
-JsonArray JsonBuffer::parseArray(char* json)
-{
-    JsonParser parser(this, json);
-    return JsonArray(parser.parseAnything());
-}
-
-JsonNode* JsonBuffer::createArrayNode()
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsArray(this);
-
-    return node;
-}
-
-JsonNode* JsonBuffer::createBoolNode(bool value)
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsBoolean(value);
-
-    return node;
-}
-
-JsonNode* JsonBuffer::createDoubleNode(double value, int decimals)
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsDouble(value, decimals);
-
-    return node;
-}
-
-JsonNode* JsonBuffer::createLongNode(long value)
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsLong(value);
-
-    return node;
-}
-
-JsonNode* JsonBuffer::createObjectNode()
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsObject(this);
-
-    return node;
-}
-
-JsonNode* JsonBuffer::createStringNode(const char* value)
-{
-    JsonNode* node = createNode();
-
-    if (node)
-        node->setAsString(value);
-
-    return node;
+#include "ArduinoJson/JsonBuffer.h"
+
+#include <new>
+
+#include "ArduinoJson/JsonValue.h"
+#include "ArduinoJson/Internals/JsonParser.h"
+#include "ArduinoJson/Internals/JsonNode.h"
+
+JsonValue JsonBuffer::createValue()
+{
+    return JsonValue(createNode());
+}
+
+JsonNode* JsonBuffer::createNode()
+{
+    void* node = allocateNode();
+    if (!node) return 0;
+        
+    return new (node) JsonNode();
+}
+
+JsonArray JsonBuffer::parseArray(char* json)
+{
+    JsonParser parser(this, json);
+    return JsonArray(parser.parseAnything());
+}
+
+JsonNode* JsonBuffer::createArrayNode()
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsArray(this);
+
+    return node;
+}
+
+JsonNode* JsonBuffer::createBoolNode(bool value)
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsBoolean(value);
+
+    return node;
+}
+
+JsonNode* JsonBuffer::createDoubleNode(double value, int decimals)
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsDouble(value, decimals);
+
+    return node;
+}
+
+JsonNode* JsonBuffer::createLongNode(long value)
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsLong(value);
+
+    return node;
+}
+
+JsonNode* JsonBuffer::createObjectNode()
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsObject(this);
+
+    return node;
+}
+
+JsonNode* JsonBuffer::createStringNode(const char* value)
+{
+    JsonNode* node = createNode();
+
+    if (node)
+        node->setAsString(value);
+
+    return node;
 }

+ 82 - 82
srcs/JsonContainer.cpp → src/JsonContainer.cpp

@@ -1,82 +1,82 @@
-#include "ArduinoJson/JsonContainer.h"
-
-#include "ArduinoJson/JsonBuffer.h"
-#include "ArduinoJson/Internals/StringBuilder.h"
-#include "ArduinoJson/Internals/CompactJsonWriter.h"
-#include "ArduinoJson/Internals/PrettyJsonWriter.h"
-
-using namespace ArduinoJson::Internals;
-
-size_t JsonContainer::printTo(char* buffer, size_t bufferSize) const
-{
-    StringBuilder sb(buffer, bufferSize);
-    return printTo(sb);
-}
-
-size_t JsonContainer::printTo(Print& p) const
-{
-    CompactJsonWriter writer(&p);
-    _node->writeTo(writer);
-    return writer.bytesWritten();
-}
-
-size_t JsonContainer::prettyPrintTo(char* buffer, size_t bufferSize) const
-{
-    StringBuilder sb(buffer, bufferSize);
-    return prettyPrintTo(sb);
-}
-
-size_t JsonContainer::prettyPrintTo(IndentedPrint& p) const
-{
-    PrettyJsonWriter writer(&p);
-    _node->writeTo(writer);
-    return writer.bytesWritten();
-}
-
-size_t JsonContainer::prettyPrintTo(Print& print) const
-{
-    IndentedPrint indentedPrint = IndentedPrint(print);
-    return prettyPrintTo(indentedPrint);
-}
-
-JsonNode* JsonContainer::createNode()
-{
-    if (!_node) return 0;
-
-    JsonBuffer* buffer = _node->getContainerBuffer();
-    if (!buffer) return 0;
-
-    return buffer->createNode();
-}
-
-bool JsonContainer::operator==(const JsonContainer & other) const
-{
-    if (_node == other._node) return true;
-    if (!_node || !other._node) return false;
-    return _node->getProxyTarget() == other._node->getProxyTarget();
-}
-
-void JsonContainer::addChild(JsonNode* childToAdd)
-{
-    if (_node)
-        _node->addChild(childToAdd);
-}
-
-void JsonContainer::removeChild(JsonNode* childToRemove)
-{
-    if (_node)
-        _node->removeChild(childToRemove);
-}
-
-size_t JsonContainer::size() const
-{
-    int size = 0;
-
-    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
-    {
-        size++;
-    }
-
-    return size;
-}
-
+#include "ArduinoJson/JsonContainer.h"
+
+#include "ArduinoJson/JsonBuffer.h"
+#include "ArduinoJson/Internals/StringBuilder.h"
+#include "ArduinoJson/Internals/CompactJsonWriter.h"
+#include "ArduinoJson/Internals/PrettyJsonWriter.h"
+
+using namespace ArduinoJson::Internals;
+
+size_t JsonContainer::printTo(char* buffer, size_t bufferSize) const
+{
+    StringBuilder sb(buffer, bufferSize);
+    return printTo(sb);
+}
+
+size_t JsonContainer::printTo(Print& p) const
+{
+    CompactJsonWriter writer(&p);
+    _node->writeTo(writer);
+    return writer.bytesWritten();
+}
+
+size_t JsonContainer::prettyPrintTo(char* buffer, size_t bufferSize) const
+{
+    StringBuilder sb(buffer, bufferSize);
+    return prettyPrintTo(sb);
+}
+
+size_t JsonContainer::prettyPrintTo(IndentedPrint& p) const
+{
+    PrettyJsonWriter writer(&p);
+    _node->writeTo(writer);
+    return writer.bytesWritten();
+}
+
+size_t JsonContainer::prettyPrintTo(Print& print) const
+{
+    IndentedPrint indentedPrint = IndentedPrint(print);
+    return prettyPrintTo(indentedPrint);
+}
+
+JsonNode* JsonContainer::createNode()
+{
+    if (!_node) return 0;
+
+    JsonBuffer* buffer = _node->getContainerBuffer();
+    if (!buffer) return 0;
+
+    return buffer->createNode();
+}
+
+bool JsonContainer::operator==(const JsonContainer & other) const
+{
+    if (_node == other._node) return true;
+    if (!_node || !other._node) return false;
+    return _node->getProxyTarget() == other._node->getProxyTarget();
+}
+
+void JsonContainer::addChild(JsonNode* childToAdd)
+{
+    if (_node)
+        _node->addChild(childToAdd);
+}
+
+void JsonContainer::removeChild(JsonNode* childToRemove)
+{
+    if (_node)
+        _node->removeChild(childToRemove);
+}
+
+size_t JsonContainer::size() const
+{
+    int size = 0;
+
+    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
+    {
+        size++;
+    }
+
+    return size;
+}
+

+ 72 - 72
srcs/JsonObject.cpp → src/JsonObject.cpp

@@ -1,73 +1,73 @@
-#include "ArduinoJson/JsonObject.h"
-
-#include <string.h> // for strcmp
-
-#include "ArduinoJson/JsonBuffer.h"
-#include "ArduinoJson/JsonValue.h"
-#include "ArduinoJson/Internals/EscapedString.h"
-#include "ArduinoJson/Internals/JsonNode.h"
-#include "ArduinoJson/Internals/StringBuilder.h"
-
-using namespace ArduinoJson::Internals;
-
-JsonValue JsonObject::operator[](char const* key)
-{
-    JsonNode* node = getOrCreateNodeAt(key);
-    return JsonValue(node);
-}
-
-void JsonObject::remove(char const* key)
-{
-    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
-    {
-        const char* childKey = it->getAsObjectKey();
-
-        if (!strcmp(childKey, key))
-        {
-            removeChild(*it);
-        }
-    }
-}
-
-JsonArray JsonObject::createNestedArray(char const* key)
-{
-    JsonNode* node = getOrCreateNodeAt(key);
-
-    if (node)
-        node->setAsArray(_node->getContainerBuffer());
-
-    return JsonArray(node);
-}
-
-JsonObject JsonObject::createNestedObject(char const* key)
-{
-    JsonNode* node = getOrCreateNodeAt(key);
-    
-    if (node)
-        node->setAsObject(_node->getContainerBuffer());
-
-    return JsonObject(node);
-}
-
-JsonNode* JsonObject::getOrCreateNodeAt(const char* key)
-{
-    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
-    {
-        const char* childKey = it->getAsObjectKey();
-
-        if (!strcmp(childKey, key))
-            return it->getAsObjectValue();
-    }
-      
-    JsonNode* newValueNode = createNode();
-    if (!newValueNode) return 0;
-    
-    JsonNode* newKeyNode = createNode();
-    if (!newKeyNode) return 0;
-
-    newKeyNode->setAsObjectKeyValue(key, newValueNode);
-
-    addChild(newKeyNode);
-
-    return newValueNode;
+#include "ArduinoJson/JsonObject.h"
+
+#include <string.h> // for strcmp
+
+#include "ArduinoJson/JsonBuffer.h"
+#include "ArduinoJson/JsonValue.h"
+#include "ArduinoJson/Internals/EscapedString.h"
+#include "ArduinoJson/Internals/JsonNode.h"
+#include "ArduinoJson/Internals/StringBuilder.h"
+
+using namespace ArduinoJson::Internals;
+
+JsonValue JsonObject::operator[](char const* key)
+{
+    JsonNode* node = getOrCreateNodeAt(key);
+    return JsonValue(node);
+}
+
+void JsonObject::remove(char const* key)
+{
+    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
+    {
+        const char* childKey = it->getAsObjectKey();
+
+        if (!strcmp(childKey, key))
+        {
+            removeChild(*it);
+        }
+    }
+}
+
+JsonArray JsonObject::createNestedArray(char const* key)
+{
+    JsonNode* node = getOrCreateNodeAt(key);
+
+    if (node)
+        node->setAsArray(_node->getContainerBuffer());
+
+    return JsonArray(node);
+}
+
+JsonObject JsonObject::createNestedObject(char const* key)
+{
+    JsonNode* node = getOrCreateNodeAt(key);
+    
+    if (node)
+        node->setAsObject(_node->getContainerBuffer());
+
+    return JsonObject(node);
+}
+
+JsonNode* JsonObject::getOrCreateNodeAt(const char* key)
+{
+    for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)
+    {
+        const char* childKey = it->getAsObjectKey();
+
+        if (!strcmp(childKey, key))
+            return it->getAsObjectValue();
+    }
+      
+    JsonNode* newValueNode = createNode();
+    if (!newValueNode) return 0;
+    
+    JsonNode* newKeyNode = createNode();
+    if (!newKeyNode) return 0;
+
+    newKeyNode->setAsObjectKeyValue(key, newValueNode);
+
+    addChild(newKeyNode);
+
+    return newValueNode;
 }

+ 58 - 58
srcs/JsonValue.cpp → src/JsonValue.cpp

@@ -1,59 +1,59 @@
-#include "ArduinoJson/JsonValue.h"
-
-#include "ArduinoJson/JsonArray.h"
-#include "ArduinoJson/JsonObject.h"
-#include "ArduinoJson/Internals/JsonNode.h"
-
-void JsonValue::operator=(bool value)
-{
-    if (_node)
-        _node->setAsBoolean(value);
-}
-
-void JsonValue::operator=(char const* value)
-{
-    if (_node)
-        _node->setAsString(value);
-}
-
-void JsonValue::set(double value, int decimals)
-{
-    if (_node)
-        _node->setAsDouble(value, decimals);
-}
-
-void JsonValue::operator=(int value)
-{
-    if (_node)
-        _node->setAsLong(value);
-}
-
-JsonValue::operator bool() const
-{
-    return _node ? _node->getAsBoolean() : false;
-}
-
-JsonValue::operator char const*() const
-{
-    return _node ? _node->getAsString() : 0;
-}
-
-JsonValue::operator double() const
-{
-    return _node ? _node->getAsDouble() : 0;
-}
-
-JsonValue::operator long() const
-{
-    return _node ? _node->getAsInteger() : 0;
-}
-
-JsonValue::operator JsonArray() const
-{
-    return JsonArray(_node);
-}
-
-JsonValue::operator JsonObject() const
-{
-    return JsonObject(_node);
+#include "ArduinoJson/JsonValue.h"
+
+#include "ArduinoJson/JsonArray.h"
+#include "ArduinoJson/JsonObject.h"
+#include "ArduinoJson/Internals/JsonNode.h"
+
+void JsonValue::operator=(bool value)
+{
+    if (_node)
+        _node->setAsBoolean(value);
+}
+
+void JsonValue::operator=(char const* value)
+{
+    if (_node)
+        _node->setAsString(value);
+}
+
+void JsonValue::set(double value, int decimals)
+{
+    if (_node)
+        _node->setAsDouble(value, decimals);
+}
+
+void JsonValue::operator=(int value)
+{
+    if (_node)
+        _node->setAsLong(value);
+}
+
+JsonValue::operator bool() const
+{
+    return _node ? _node->getAsBoolean() : false;
+}
+
+JsonValue::operator char const*() const
+{
+    return _node ? _node->getAsString() : 0;
+}
+
+JsonValue::operator double() const
+{
+    return _node ? _node->getAsDouble() : 0;
+}
+
+JsonValue::operator long() const
+{
+    return _node ? _node->getAsInteger() : 0;
+}
+
+JsonValue::operator JsonArray() const
+{
+    return JsonArray(_node);
+}
+
+JsonValue::operator JsonObject() const
+{
+    return JsonObject(_node);
 }