Fixed namespaces

This commit is contained in:
Benoit Blanchon
2014-10-18 23:05:54 +02:00
parent 1abb8ac6ae
commit 074c39ca5b
31 changed files with 638 additions and 554 deletions

View File

@ -2,6 +2,10 @@
#include "ArduinoJson/Internals/JsonWriter.h"
namespace ArduinoJson
{
namespace Internals
{
class CompactJsonWriter : public JsonWriter
{
public:
@ -40,4 +44,5 @@ public:
_length += _sink->write('}');
}
};
}
}

View File

@ -9,7 +9,7 @@
namespace ArduinoJson
{
namespace Generator
namespace Internals
{
// Decorator on top of Print to allow indented output.
// This class is used by JsonPrintable::prettyPrintTo() but can also be used

View File

@ -1,6 +1,11 @@
#pragma once
namespace ArduinoJson
{
class JsonBuffer;
namespace Internals
{
class JsonWriter;
class JsonNodeIterator;
@ -179,3 +184,5 @@ private:
content.asProxy.target = target;
}
};
}
}

View File

@ -2,6 +2,10 @@
#include "JsonNode.h"
namespace ArduinoJson
{
namespace Internals
{
class JsonNodeIterator
{
public:
@ -34,4 +38,5 @@ public:
private:
JsonNode* node;
};
}
}

View File

@ -1,8 +1,13 @@
#pragma once
#include "JsonNode.h"
namespace ArduinoJson
{
class JsonValue ;
namespace Internals
{
class JsonNodeWrapper
{
friend class JsonValue;
@ -34,4 +39,5 @@ protected:
JsonNode* _node;
};
}
}

View File

@ -1,10 +1,15 @@
#include "JsonNode.h"
#pragma once
class JsonNode;
#include "JsonNode.h"
namespace ArduinoJson
{
class JsonBuffer;
namespace Internals
{
class JsonNode;
class JsonParser
{
public:
@ -41,3 +46,5 @@ private:
JsonNode *parseDouble();
};
}
}

View File

@ -2,6 +2,10 @@
#include "../Arduino/Print.h"
namespace ArduinoJson
{
namespace Internals
{
class JsonWriter
{
public:
@ -46,4 +50,5 @@ protected:
Print* _sink;
size_t _length;
};
}
}

View File

@ -3,8 +3,10 @@
#include "JsonWriter.h"
#include "IndentedPrint.h"
using namespace ArduinoJson::Generator;
namespace ArduinoJson
{
namespace Internals
{
class PrettyJsonWriter : public JsonWriter
{
public:
@ -63,3 +65,5 @@ private:
_indenter->unindent();
}
};
}
}

View File

@ -2,6 +2,8 @@
#include "JsonContainer.h"
namespace ArduinoJson
{
class JsonArray : public JsonContainer
{
public:
@ -9,7 +11,7 @@ public:
{
}
explicit JsonArray(JsonNode* node)
explicit JsonArray(Internals::JsonNode* node)
: JsonContainer(node)
{
}
@ -31,4 +33,4 @@ public:
return _node && _node->isArray();
}
};
}

View File

@ -3,13 +3,18 @@
#include "JsonArray.h"
#include "JsonObject.h"
namespace ArduinoJson
{
namespace Internals
{
class JsonParser;
}
class JsonBuffer
{
friend class JsonContainer;
friend class JsonNode;
friend class JsonParser;
friend class Internals::JsonNode;
friend class Internals::JsonParser;
public:
virtual ~JsonBuffer() {};
@ -34,12 +39,13 @@ protected:
virtual void* allocateNode() = 0;
private:
JsonNode* createNode();
Internals::JsonNode* createNode();
JsonNode* createArrayNode();
JsonNode* createBoolNode(bool value);
JsonNode* createDoubleNode(double value, int decimals);
JsonNode* createLongNode(long value);
JsonNode* createObjectNode();
JsonNode* createStringNode(const char* value);
Internals::JsonNode* createArrayNode();
Internals::JsonNode* createBoolNode(bool value);
Internals::JsonNode* createDoubleNode(double value, int decimals);
Internals::JsonNode* createLongNode(long value);
Internals::JsonNode* createObjectNode();
Internals::JsonNode* createStringNode(const char* value);
};
}

View File

@ -1,26 +1,25 @@
#pragma once
#include "ArduinoJson/Arduino/Printable.h"
#include "ArduinoJson/Internals/JsonNodeIterator.h"
#include "ArduinoJson/Internals/JsonNode.h"
#include "ArduinoJson/Internals/IndentedPrint.h"
#include "ArduinoJson/Internals/JsonNodeWrapper.h"
#include "Arduino/Printable.h"
#include "Internals/JsonNodeIterator.h"
#include "Internals/JsonNode.h"
#include "Internals/IndentedPrint.h"
#include "Internals/JsonNodeWrapper.h"
namespace ArduinoJson
{
class JsonArray;
class JsonObject;
class JsonValue;
class JsonContainer : public Printable, public JsonNodeWrapper
class JsonContainer : public Printable, public Internals::JsonNodeWrapper
{
// friend JsonValue;
friend class JsonArray;
public:
JsonContainer() {}
explicit JsonContainer(JsonNode* node)
explicit JsonContainer(Internals::JsonNode* node)
: JsonNodeWrapper(node)
{
}
@ -33,23 +32,23 @@ public:
virtual size_t printTo(Print& print) const;
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
size_t prettyPrintTo(ArduinoJson::Generator::IndentedPrint& print) const;
size_t prettyPrintTo(ArduinoJson::Internals::IndentedPrint& print) const;
size_t prettyPrintTo(Print& print) const;
protected:
JsonNodeIterator beginChildren() const
Internals::JsonNodeIterator beginChildren() const
{
return JsonNodeIterator(_node ? _node->getContainerChild() : 0);
return Internals::JsonNodeIterator(_node ? _node->getContainerChild() : 0);
}
JsonNodeIterator endChildren() const
Internals::JsonNodeIterator endChildren() const
{
return JsonNodeIterator(0);
return Internals::JsonNodeIterator(0);
}
void addChild(JsonNode*);
void removeChild(JsonNode*);
JsonNode* createNode();
void addChild(Internals::JsonNode*);
void removeChild(Internals::JsonNode*);
Internals::JsonNode* createNode();
};
}

View File

@ -2,6 +2,8 @@
#include "JsonContainer.h"
namespace ArduinoJson
{
class JsonObject : public JsonContainer
{
public:
@ -10,7 +12,7 @@ public:
{
}
explicit JsonObject(JsonNode* node)
explicit JsonObject(Internals::JsonNode* node)
: JsonContainer(node)
{
}
@ -22,5 +24,6 @@ public:
JsonObject createNestedObject(const char* key);
private:
JsonNode* getOrCreateNodeAt(const char* key);
Internals::JsonNode* getOrCreateNodeAt(const char* key);
};
}

View File

@ -2,17 +2,19 @@
#include "Internals/JsonNodeWrapper.h"
namespace ArduinoJson
{
class JsonArray;
class JsonContainer;
class JsonObject;
class JsonValue : public JsonNodeWrapper
class JsonValue : public Internals::JsonNodeWrapper
{
public:
JsonValue() {}
explicit JsonValue(JsonNode* node)
explicit JsonValue(Internals::JsonNode* node)
: JsonNodeWrapper(node)
{
}
@ -22,7 +24,7 @@ public:
void operator=(double x) { set(x, 2); }
void operator=(int);
void operator=(const JsonValue& value) { duplicate(value); }
void operator=(const JsonNodeWrapper& object) { duplicate(object); }
void operator=(const Internals::JsonNodeWrapper& object) { duplicate(object); }
operator bool() const;
operator const char*() const;
@ -34,3 +36,4 @@ public:
void set(double value, int decimals);
};
}

View File

@ -3,6 +3,8 @@
#include "JsonBuffer.h"
#include "JsonObject.h"
namespace ArduinoJson
{
template<int CAPACITY>
class StaticJsonBuffer : public JsonBuffer
{
@ -36,7 +38,7 @@ protected:
}
private:
JsonNode _buffer[CAPACITY];
Internals::JsonNode _buffer[CAPACITY];
int _size;
};
}

View File

@ -1,6 +1,6 @@
#include "ArduinoJson/Internals/IndentedPrint.h"
using namespace ArduinoJson::Generator;
using namespace ArduinoJson::Internals;
void IndentedPrint::indent()
{

View File

@ -5,6 +5,8 @@
#include "ArduinoJson/JsonObject.h"
#include "ArduinoJson/JsonBuffer.h"
using namespace ArduinoJson::Internals;
void JsonNode::writeTo(JsonWriter& writer)
{
switch (type)

View File

@ -2,6 +2,9 @@
#include "ArduinoJson/JsonObject.h"
#include "ArduinoJson/JsonValue.h"
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
JsonValue JsonArray::operator[](int index) const
{
for (JsonNodeIterator it = beginChildren(); it != endChildren(); ++it)

View File

@ -6,6 +6,9 @@
#include "ArduinoJson/Internals/JsonParser.h"
#include "ArduinoJson/Internals/JsonNode.h"
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
JsonValue JsonBuffer::createValue()
{
return JsonValue(createNode());

View File

@ -5,6 +5,7 @@
#include "ArduinoJson/Internals/CompactJsonWriter.h"
#include "ArduinoJson/Internals/PrettyJsonWriter.h"
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
size_t JsonContainer::printTo(char* buffer, size_t bufferSize) const

View File

@ -7,6 +7,7 @@
#include "ArduinoJson/Internals/JsonNode.h"
#include "ArduinoJson/Internals/StringBuilder.h"
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
JsonValue JsonObject::operator[](char const* key)

View File

@ -4,6 +4,8 @@
#include "ArduinoJson/JsonObject.h"
#include "ArduinoJson/Internals/JsonNode.h"
using namespace ArduinoJson;
void JsonValue::operator=(bool value)
{
if (_node)

View File

@ -4,7 +4,7 @@
#include <ArduinoJson/JsonValue.h>
#include <ArduinoJson/StaticJsonBuffer.h>
using namespace ArduinoJson::Generator;
using namespace ArduinoJson;
struct Person
{

View File

@ -2,6 +2,8 @@
#include <ArduinoJson/StaticJsonBuffer.h>
#include <ArduinoJson/JsonValue.h>
using namespace ArduinoJson;
class JsonArray_Container_Tests : public ::testing::Test
{
protected:

View File

@ -9,6 +9,8 @@
#include <ArduinoJson/JsonValue.h>
#include <ArduinoJson/StaticJsonBuffer.h>
using namespace ArduinoJson;
class JsonArray_PrettyPrintTo_Tests : public testing::Test
{
protected:

View File

@ -8,6 +8,8 @@
#include <ArduinoJson/JsonObject.h>
#include <ArduinoJson/StaticJsonBuffer.h>
using namespace ArduinoJson;
class JsonArray_PrintTo_Tests : public testing::Test
{
protected:

View File

@ -2,6 +2,8 @@
#include <ArduinoJson/StaticJsonBuffer.h>
#include <ArduinoJson/JsonValue.h>
using namespace ArduinoJson;
class JsonObject_Container_Tests : public ::testing::Test
{
protected:

View File

@ -8,6 +8,8 @@
#include <ArduinoJson/JsonValue.h>
#include <ArduinoJson/StaticJsonBuffer.h>
using namespace ArduinoJson;
class JsonObject_PrettyPrintTo_Tests : public testing::Test
{
protected:

View File

@ -4,6 +4,8 @@
#include <ArduinoJson/JsonValue.h>
#include <ArduinoJson/StaticJsonBuffer.h>
using namespace ArduinoJson;
class JsonObject_Serialization_Tests : public testing::Test
{
protected:

View File

@ -2,6 +2,8 @@
#include <ArduinoJson/StaticJsonBuffer.h>
#include <ArduinoJson/JsonValue.h>
using namespace ArduinoJson;
class JsonParser_Array_Tests : public testing::Test
{
protected:

View File

@ -2,6 +2,8 @@
#include <ArduinoJson/StaticJsonBuffer.h>
#include <ArduinoJson/JsonValue.h>
using namespace ArduinoJson;
class JsonValueTests : public ::testing::Test
{
protected:

View File

@ -2,6 +2,8 @@
#include <ArduinoJson/StaticJsonBuffer.h>
#include <ArduinoJson/JsonValue.h>
using namespace ArduinoJson;
TEST(StaticJsonBuffer, CapacityMatchTemplateParameter)
{
StaticJsonBuffer<42> json;