mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 11:36:36 +02:00
Moved .h files to include/
This commit is contained in:
@ -2,29 +2,29 @@
|
|||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef ARDUINO
|
#ifndef ARDUINO
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// This class reproduces Arduino's Print
|
// This class reproduces Arduino's Print
|
||||||
class Print
|
class Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual size_t write(uint8_t) = 0;
|
virtual size_t write(uint8_t) = 0;
|
||||||
|
|
||||||
size_t print(const char[]);
|
size_t print(const char[]);
|
||||||
size_t print(double, int = 2);
|
size_t print(double, int = 2);
|
||||||
size_t print(long);
|
size_t print(long);
|
||||||
size_t println();
|
size_t println();
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <Print.h>
|
#include <Print.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,26 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef ARDUINO
|
#ifndef ARDUINO
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
class Print;
|
class Print;
|
||||||
|
|
||||||
class Printable
|
class Printable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual size_t printTo(Print& p) const = 0;
|
virtual size_t printTo(Print& p) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <Printable.h>
|
#include <Printable.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,43 +1,43 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Internals/JsonWriter.h"
|
#include "ArduinoJson/Internals/JsonWriter.h"
|
||||||
|
|
||||||
class CompactJsonWriter : public JsonWriter
|
class CompactJsonWriter : public JsonWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CompactJsonWriter(Print* sink)
|
explicit CompactJsonWriter(Print* sink)
|
||||||
: JsonWriter(sink)
|
: JsonWriter(sink)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void beginArray()
|
virtual void beginArray()
|
||||||
{
|
{
|
||||||
_length += _sink->write('[');
|
_length += _sink->write('[');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void endArray()
|
virtual void endArray()
|
||||||
{
|
{
|
||||||
_length += _sink->write(']');
|
_length += _sink->write(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeColon()
|
virtual void writeColon()
|
||||||
{
|
{
|
||||||
_length += _sink->write(':');
|
_length += _sink->write(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeComma()
|
virtual void writeComma()
|
||||||
{
|
{
|
||||||
_length += _sink->write(',');
|
_length += _sink->write(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void beginObject()
|
virtual void beginObject()
|
||||||
{
|
{
|
||||||
_length += _sink->write('{');
|
_length += _sink->write('{');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void endObject()
|
virtual void endObject()
|
||||||
{
|
{
|
||||||
_length += _sink->write('}');
|
_length += _sink->write('}');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Arduino/Print.h"
|
#include "../Arduino/Print.h"
|
||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
namespace Internals
|
namespace Internals
|
||||||
{
|
{
|
||||||
class EscapedString
|
class EscapedString
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static size_t printTo(const char*, Print*);
|
static size_t printTo(const char*, Print*);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,53 +1,53 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Arduino/Print.h"
|
#include "../Arduino/Print.h"
|
||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
namespace Generator
|
namespace Generator
|
||||||
{
|
{
|
||||||
// Decorator on top of Print to allow indented output.
|
// Decorator on top of Print to allow indented output.
|
||||||
// This class is used by JsonPrintable::prettyPrintTo() but can also be used
|
// This class is used by JsonPrintable::prettyPrintTo() but can also be used
|
||||||
// for your own purpose, like logging.
|
// for your own purpose, like logging.
|
||||||
class IndentedPrint : public Print
|
class IndentedPrint : public Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
IndentedPrint(Print& p)
|
IndentedPrint(Print& p)
|
||||||
: sink(&p)
|
: sink(&p)
|
||||||
{
|
{
|
||||||
level = 0;
|
level = 0;
|
||||||
tabSize = 2;
|
tabSize = 2;
|
||||||
isNewLine = true;
|
isNewLine = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
|
|
||||||
// Adds one level of indentation
|
// Adds one level of indentation
|
||||||
void indent();
|
void indent();
|
||||||
|
|
||||||
// Removes one level of indentation
|
// Removes one level of indentation
|
||||||
void unindent();
|
void unindent();
|
||||||
|
|
||||||
// Set the number of space printed for each level of indentation
|
// Set the number of space printed for each level of indentation
|
||||||
void setTabSize(uint8_t n);
|
void setTabSize(uint8_t n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Print* sink;
|
Print* sink;
|
||||||
uint8_t level : 4;
|
uint8_t level : 4;
|
||||||
uint8_t tabSize : 3;
|
uint8_t tabSize : 3;
|
||||||
bool isNewLine : 1;
|
bool isNewLine : 1;
|
||||||
|
|
||||||
size_t writeTabs();
|
size_t writeTabs();
|
||||||
|
|
||||||
static const int MAX_LEVEL = 15; // because it's only 4 bits
|
static const int MAX_LEVEL = 15; // because it's only 4 bits
|
||||||
static const int MAX_TAB_SIZE = 7; // because it's only 3 bits
|
static const int MAX_TAB_SIZE = 7; // because it's only 3 bits
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,181 +1,181 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class JsonBuffer;
|
class JsonBuffer;
|
||||||
class JsonWriter;
|
class JsonWriter;
|
||||||
class JsonNodeIterator;
|
class JsonNodeIterator;
|
||||||
|
|
||||||
class JsonNode
|
class JsonNode
|
||||||
{
|
{
|
||||||
friend class JsonNodeIterator;
|
friend class JsonNodeIterator;
|
||||||
|
|
||||||
enum JsonNodeType
|
enum JsonNodeType
|
||||||
{
|
{
|
||||||
JSON_UNDEFINED,
|
JSON_UNDEFINED,
|
||||||
JSON_NULL,
|
JSON_NULL,
|
||||||
JSON_ARRAY,
|
JSON_ARRAY,
|
||||||
JSON_OBJECT,
|
JSON_OBJECT,
|
||||||
JSON_KEY_VALUE,
|
JSON_KEY_VALUE,
|
||||||
JSON_BOOLEAN,
|
JSON_BOOLEAN,
|
||||||
JSON_STRING,
|
JSON_STRING,
|
||||||
JSON_LONG,
|
JSON_LONG,
|
||||||
JSON_PROXY,
|
JSON_PROXY,
|
||||||
JSON_DOUBLE_0_DECIMALS,
|
JSON_DOUBLE_0_DECIMALS,
|
||||||
JSON_DOUBLE_1_DECIMAL,
|
JSON_DOUBLE_1_DECIMAL,
|
||||||
JSON_DOUBLE_2_DECIMALS,
|
JSON_DOUBLE_2_DECIMALS,
|
||||||
// etc.
|
// etc.
|
||||||
};
|
};
|
||||||
|
|
||||||
union JsonNodeContent
|
union JsonNodeContent
|
||||||
{
|
{
|
||||||
bool asBoolean;
|
bool asBoolean;
|
||||||
double asDouble;
|
double asDouble;
|
||||||
long asInteger;
|
long asInteger;
|
||||||
const char* asString;
|
const char* asString;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
const char* key;
|
const char* key;
|
||||||
JsonNode* value;
|
JsonNode* value;
|
||||||
} asKey;
|
} asKey;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
JsonNode* child;
|
JsonNode* child;
|
||||||
JsonBuffer* buffer;
|
JsonBuffer* buffer;
|
||||||
} asContainer;
|
} asContainer;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
JsonNode* target;
|
JsonNode* target;
|
||||||
} asProxy;
|
} asProxy;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JsonNode()
|
JsonNode()
|
||||||
: type(JSON_UNDEFINED), next(0)
|
: type(JSON_UNDEFINED), next(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeTo(JsonWriter&); // TODO: <- move in JsonNodeSerializer
|
void writeTo(JsonWriter&); // TODO: <- move in JsonNodeSerializer
|
||||||
|
|
||||||
void setAsArray(JsonBuffer* buffer)
|
void setAsArray(JsonBuffer* buffer)
|
||||||
{
|
{
|
||||||
type = JSON_ARRAY;
|
type = JSON_ARRAY;
|
||||||
content.asContainer.child = 0;
|
content.asContainer.child = 0;
|
||||||
content.asContainer.buffer = buffer;
|
content.asContainer.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsBoolean(bool value)
|
void setAsBoolean(bool value)
|
||||||
{
|
{
|
||||||
type = JSON_BOOLEAN;
|
type = JSON_BOOLEAN;
|
||||||
content.asBoolean = value;
|
content.asBoolean = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsLong(int value)
|
void setAsLong(int value)
|
||||||
{
|
{
|
||||||
type = JSON_LONG;
|
type = JSON_LONG;
|
||||||
content.asInteger = value;
|
content.asInteger = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsString(char const* value)
|
void setAsString(char const* value)
|
||||||
{
|
{
|
||||||
type = JSON_STRING;
|
type = JSON_STRING;
|
||||||
content.asString = value;
|
content.asString = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsDouble(double value, int decimals)
|
void setAsDouble(double value, int decimals)
|
||||||
{
|
{
|
||||||
type = static_cast<JsonNodeType>(JSON_DOUBLE_0_DECIMALS + decimals);
|
type = static_cast<JsonNodeType>(JSON_DOUBLE_0_DECIMALS + decimals);
|
||||||
content.asDouble = value;
|
content.asDouble = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsObject(JsonBuffer* buffer)
|
void setAsObject(JsonBuffer* buffer)
|
||||||
{
|
{
|
||||||
type = JSON_OBJECT;
|
type = JSON_OBJECT;
|
||||||
content.asContainer.child = 0;
|
content.asContainer.child = 0;
|
||||||
content.asContainer.buffer = buffer;
|
content.asContainer.buffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAsObjectKeyValue(const char* key, JsonNode* value)
|
void setAsObjectKeyValue(const char* key, JsonNode* value)
|
||||||
{
|
{
|
||||||
type = JSON_KEY_VALUE;
|
type = JSON_KEY_VALUE;
|
||||||
content.asKey.key = key;
|
content.asKey.key = key;
|
||||||
content.asKey.value = value;
|
content.asKey.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getAsBoolean()
|
bool getAsBoolean()
|
||||||
{
|
{
|
||||||
return type == JSON_BOOLEAN ? content.asBoolean : false;
|
return type == JSON_BOOLEAN ? content.asBoolean : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getAsDouble()
|
double getAsDouble()
|
||||||
{
|
{
|
||||||
return type >= JSON_DOUBLE_0_DECIMALS ? content.asDouble : 0;
|
return type >= JSON_DOUBLE_0_DECIMALS ? content.asDouble : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long getAsInteger()
|
long getAsInteger()
|
||||||
{
|
{
|
||||||
return type == JSON_LONG ? content.asInteger : 0;
|
return type == JSON_LONG ? content.asInteger : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getAsString()
|
const char* getAsString()
|
||||||
{
|
{
|
||||||
return type == JSON_STRING ? content.asString : 0;
|
return type == JSON_STRING ? content.asString : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonBuffer* getContainerBuffer()
|
JsonBuffer* getContainerBuffer()
|
||||||
{
|
{
|
||||||
if (type == JSON_PROXY) return content.asProxy.target->getContainerBuffer();
|
if (type == JSON_PROXY) return content.asProxy.target->getContainerBuffer();
|
||||||
return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.buffer : 0;
|
return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.buffer : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* getContainerChild()
|
JsonNode* getContainerChild()
|
||||||
{
|
{
|
||||||
if (type == JSON_PROXY) return content.asProxy.target->getContainerChild();
|
if (type == JSON_PROXY) return content.asProxy.target->getContainerChild();
|
||||||
return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.child : 0;
|
return type == JSON_ARRAY || type == JSON_OBJECT ? content.asContainer.child : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* getAsObjectKey()
|
const char* getAsObjectKey()
|
||||||
{
|
{
|
||||||
return type == JSON_KEY_VALUE ? content.asKey.key : 0;
|
return type == JSON_KEY_VALUE ? content.asKey.key : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* getAsObjectValue()
|
JsonNode* getAsObjectValue()
|
||||||
{
|
{
|
||||||
return type == JSON_KEY_VALUE ? content.asKey.value : 0;
|
return type == JSON_KEY_VALUE ? content.asKey.value : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* getProxyTarget()
|
JsonNode* getProxyTarget()
|
||||||
{
|
{
|
||||||
return type == JSON_PROXY ? content.asProxy.target : this;
|
return type == JSON_PROXY ? content.asProxy.target : this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isArray()
|
bool isArray()
|
||||||
{
|
{
|
||||||
return type == JSON_ARRAY;
|
return type == JSON_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addChild(JsonNode* childToAdd);
|
void addChild(JsonNode* childToAdd);
|
||||||
|
|
||||||
void removeChild(JsonNode* childToRemove);
|
void removeChild(JsonNode* childToRemove);
|
||||||
|
|
||||||
void duplicate(JsonNode* other);
|
void duplicate(JsonNode* other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode* next;
|
JsonNode* next;
|
||||||
JsonNodeContent content;
|
JsonNodeContent content;
|
||||||
JsonNodeType type;
|
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
|
||||||
|
|
||||||
void setAsProxyOfSelf();
|
void setAsProxyOfSelf();
|
||||||
|
|
||||||
void setAsProxyOf(JsonNode* target)
|
void setAsProxyOf(JsonNode* target)
|
||||||
{
|
{
|
||||||
type = JSON_PROXY;
|
type = JSON_PROXY;
|
||||||
content.asProxy.target = target;
|
content.asProxy.target = target;
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,37 +1,37 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonNode.h"
|
#include "JsonNode.h"
|
||||||
|
|
||||||
class JsonNodeIterator
|
class JsonNodeIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit JsonNodeIterator(JsonNode* node)
|
explicit JsonNodeIterator(JsonNode* node)
|
||||||
: node(node)
|
: node(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!= (const JsonNodeIterator& other) const
|
bool operator!= (const JsonNodeIterator& other) const
|
||||||
{
|
{
|
||||||
return node != other.node;
|
return node != other.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator++()
|
void operator++()
|
||||||
{
|
{
|
||||||
node = node->next;
|
node = node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* operator*() const
|
JsonNode* operator*() const
|
||||||
{
|
{
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* operator->() const
|
JsonNode* operator->() const
|
||||||
{
|
{
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode* node;
|
JsonNode* node;
|
||||||
};
|
};
|
||||||
|
|
@ -1,37 +1,37 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonNode.h"
|
#include "JsonNode.h"
|
||||||
class JsonValue;
|
class JsonValue;
|
||||||
|
|
||||||
class JsonNodeWrapper
|
class JsonNodeWrapper
|
||||||
{
|
{
|
||||||
friend JsonValue;
|
friend JsonValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JsonNodeWrapper()
|
JsonNodeWrapper()
|
||||||
: _node(0)
|
: _node(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit JsonNodeWrapper(JsonNode* node)
|
explicit JsonNodeWrapper(JsonNode* node)
|
||||||
: _node(node)
|
: _node(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void duplicate(const JsonNodeWrapper& other)
|
void duplicate(const JsonNodeWrapper& other)
|
||||||
{
|
{
|
||||||
if (!_node)
|
if (!_node)
|
||||||
{
|
{
|
||||||
_node = other._node;
|
_node = other._node;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_node->duplicate(other._node);
|
_node->duplicate(other._node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonNode* _node;
|
JsonNode* _node;
|
||||||
};
|
};
|
||||||
|
|
@ -1,49 +1,49 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Arduino/Print.h"
|
#include "../Arduino/Print.h"
|
||||||
|
|
||||||
class JsonWriter
|
class JsonWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit JsonWriter(Print* sink)
|
explicit JsonWriter(Print* sink)
|
||||||
: _sink(sink), _length(0)
|
: _sink(sink), _length(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bytesWritten()
|
size_t bytesWritten()
|
||||||
{
|
{
|
||||||
return _length;
|
return _length;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void beginArray() = 0;
|
virtual void beginArray() = 0;
|
||||||
|
|
||||||
virtual void endArray() = 0;
|
virtual void endArray() = 0;
|
||||||
|
|
||||||
virtual void beginObject() = 0;
|
virtual void beginObject() = 0;
|
||||||
|
|
||||||
virtual void endObject() = 0;
|
virtual void endObject() = 0;
|
||||||
|
|
||||||
void writeString(const char* value);
|
void writeString(const char* value);
|
||||||
void writeInteger(long value);
|
void writeInteger(long value);
|
||||||
void writeBoolean(bool value);
|
void writeBoolean(bool value);
|
||||||
void writeDouble(double value, int decimals);
|
void writeDouble(double value, int decimals);
|
||||||
|
|
||||||
virtual void writeColon() = 0;
|
virtual void writeColon() = 0;
|
||||||
|
|
||||||
virtual void writeComma() = 0;
|
virtual void writeComma() = 0;
|
||||||
|
|
||||||
void writeEmptyArray()
|
void writeEmptyArray()
|
||||||
{
|
{
|
||||||
_length += _sink->print("[]");
|
_length += _sink->print("[]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeEmptyObject()
|
void writeEmptyObject()
|
||||||
{
|
{
|
||||||
_length += _sink->print("{}");
|
_length += _sink->print("{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Print* _sink;
|
Print* _sink;
|
||||||
size_t _length;
|
size_t _length;
|
||||||
};
|
};
|
||||||
|
|
@ -1,65 +1,65 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonWriter.h"
|
#include "JsonWriter.h"
|
||||||
#include "IndentedPrint.h"
|
#include "IndentedPrint.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Generator;
|
using namespace ArduinoJson::Generator;
|
||||||
|
|
||||||
class PrettyJsonWriter : public JsonWriter
|
class PrettyJsonWriter : public JsonWriter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PrettyJsonWriter(IndentedPrint* sink)
|
explicit PrettyJsonWriter(IndentedPrint* sink)
|
||||||
: JsonWriter(sink), _indenter(sink)
|
: JsonWriter(sink), _indenter(sink)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void beginArray()
|
virtual void beginArray()
|
||||||
{
|
{
|
||||||
_length += _sink->write('[');
|
_length += _sink->write('[');
|
||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void endArray()
|
virtual void endArray()
|
||||||
{
|
{
|
||||||
unindent();
|
unindent();
|
||||||
_length += _sink->write(']');
|
_length += _sink->write(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeColon()
|
virtual void writeColon()
|
||||||
{
|
{
|
||||||
_length += _sink->print(": ");
|
_length += _sink->print(": ");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void writeComma()
|
virtual void writeComma()
|
||||||
{
|
{
|
||||||
_length += _sink->write(',');
|
_length += _sink->write(',');
|
||||||
_length += _indenter->println();
|
_length += _indenter->println();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void beginObject()
|
virtual void beginObject()
|
||||||
{
|
{
|
||||||
_length += _sink->write('{');
|
_length += _sink->write('{');
|
||||||
indent();
|
indent();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void endObject()
|
virtual void endObject()
|
||||||
{
|
{
|
||||||
unindent();
|
unindent();
|
||||||
_length += _sink->write('}');
|
_length += _sink->write('}');
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IndentedPrint* _indenter;
|
IndentedPrint* _indenter;
|
||||||
|
|
||||||
void indent()
|
void indent()
|
||||||
{
|
{
|
||||||
_indenter->indent();
|
_indenter->indent();
|
||||||
_length += _indenter->println();
|
_length += _indenter->println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unindent()
|
void unindent()
|
||||||
{
|
{
|
||||||
_length += _indenter->println();
|
_length += _indenter->println();
|
||||||
_indenter->unindent();
|
_indenter->unindent();
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -1,31 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../Arduino/Print.h"
|
#include "../Arduino/Print.h"
|
||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
namespace Internals
|
namespace Internals
|
||||||
{
|
{
|
||||||
class StringBuilder : public Print
|
class StringBuilder : public Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StringBuilder(char* buf, int size)
|
StringBuilder(char* buf, int size)
|
||||||
: buffer(buf), capacity(size - 1), length(0)
|
: buffer(buf), capacity(size - 1), length(0)
|
||||||
{
|
{
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t write(uint8_t c);
|
virtual size_t write(uint8_t c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* buffer;
|
char* buffer;
|
||||||
int capacity;
|
int capacity;
|
||||||
int length;
|
int length;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,34 +1,34 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonContainer.h"
|
#include "JsonContainer.h"
|
||||||
|
|
||||||
class JsonArray : public JsonContainer
|
class JsonArray : public JsonContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JsonArray()
|
JsonArray()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit JsonArray(JsonNode* node)
|
explicit JsonArray(JsonNode* node)
|
||||||
: JsonContainer(node)
|
: JsonContainer(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonValue operator[](int index) const;
|
JsonValue operator[](int index) const;
|
||||||
|
|
||||||
void add(bool value);
|
void add(bool value);
|
||||||
void add(const char* value);
|
void add(const char* value);
|
||||||
void add(double value, int decimals=2);
|
void add(double value, int decimals=2);
|
||||||
void add(int value) { add((long) value); }
|
void add(int value) { add((long) value); }
|
||||||
void add(long value);
|
void add(long value);
|
||||||
void add(JsonContainer nestedArray); // TODO: should allow JsonValue too
|
void add(JsonContainer nestedArray); // TODO: should allow JsonValue too
|
||||||
|
|
||||||
JsonArray createNestedArray();
|
JsonArray createNestedArray();
|
||||||
JsonObject createNestedObject();
|
JsonObject createNestedObject();
|
||||||
|
|
||||||
bool success()
|
bool success()
|
||||||
{
|
{
|
||||||
return _node && _node->isArray();
|
return _node && _node->isArray();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1,44 +1,44 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonArray.h"
|
#include "JsonArray.h"
|
||||||
#include "JsonObject.h"
|
#include "JsonObject.h"
|
||||||
|
|
||||||
class JsonParser;
|
class JsonParser;
|
||||||
|
|
||||||
class JsonBuffer
|
class JsonBuffer
|
||||||
{
|
{
|
||||||
friend class JsonContainer;
|
friend class JsonContainer;
|
||||||
friend class JsonNode;
|
friend class JsonNode;
|
||||||
friend class JsonParser;
|
friend class JsonParser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~JsonBuffer() {};
|
virtual ~JsonBuffer() {};
|
||||||
|
|
||||||
JsonArray createArray()
|
JsonArray createArray()
|
||||||
{
|
{
|
||||||
return JsonArray(createArrayNode());
|
return JsonArray(createArrayNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject createObject()
|
JsonObject createObject()
|
||||||
{
|
{
|
||||||
return JsonObject(createObjectNode());
|
return JsonObject(createObjectNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonValue createValue();
|
JsonValue createValue();
|
||||||
|
|
||||||
JsonArray parseArray(char* string);
|
JsonArray parseArray(char* string);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void* allocateNode() = 0;
|
virtual void* allocateNode() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode* createNode();
|
JsonNode* createNode();
|
||||||
|
|
||||||
JsonNode* createArrayNode();
|
JsonNode* createArrayNode();
|
||||||
JsonNode* createBoolNode(bool value);
|
JsonNode* createBoolNode(bool value);
|
||||||
JsonNode* createDoubleNode(double value, int decimals);
|
JsonNode* createDoubleNode(double value, int decimals);
|
||||||
JsonNode* createLongNode(long value);
|
JsonNode* createLongNode(long value);
|
||||||
JsonNode* createObjectNode();
|
JsonNode* createObjectNode();
|
||||||
JsonNode* createStringNode(const char* value);
|
JsonNode* createStringNode(const char* value);
|
||||||
};
|
};
|
||||||
|
|
@ -1,54 +1,55 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Arduino/Printable.h"
|
#include "ArduinoJson/Arduino/Printable.h"
|
||||||
#include "Internals/JsonNodeIterator.h"
|
#include "ArduinoJson/Internals/JsonNodeIterator.h"
|
||||||
#include "Internals/JsonNode.h"
|
#include "ArduinoJson/Internals/JsonNode.h"
|
||||||
#include "Internals/IndentedPrint.h"
|
#include "ArduinoJson/Internals/IndentedPrint.h"
|
||||||
#include "Internals/JsonNodeWrapper.h"
|
#include "ArduinoJson/Internals/JsonNodeWrapper.h"
|
||||||
class JsonArray;
|
|
||||||
class JsonObject;
|
class JsonArray;
|
||||||
class JsonValue;
|
class JsonObject;
|
||||||
|
class JsonValue;
|
||||||
class JsonContainer : public Printable, public JsonNodeWrapper
|
|
||||||
{
|
class JsonContainer : public Printable, public JsonNodeWrapper
|
||||||
// friend JsonValue;
|
{
|
||||||
friend JsonArray;
|
// friend JsonValue;
|
||||||
|
friend JsonArray;
|
||||||
public:
|
|
||||||
|
public:
|
||||||
|
|
||||||
JsonContainer() {}
|
|
||||||
|
JsonContainer() {}
|
||||||
explicit JsonContainer(JsonNode* node)
|
|
||||||
: JsonNodeWrapper(node)
|
explicit JsonContainer(JsonNode* node)
|
||||||
{
|
: JsonNodeWrapper(node)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
size_t size() const;
|
|
||||||
|
size_t size() const;
|
||||||
bool operator==(JsonContainer const& other) const;
|
|
||||||
|
bool operator==(JsonContainer const& other) const;
|
||||||
size_t printTo(char* buffer, size_t bufferSize) const;
|
|
||||||
virtual size_t printTo(Print& print) const;
|
size_t printTo(char* buffer, size_t bufferSize) const;
|
||||||
|
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(char* buffer, size_t bufferSize) const;
|
||||||
size_t prettyPrintTo(Print& print) const;
|
size_t prettyPrintTo(ArduinoJson::Generator::IndentedPrint& print) const;
|
||||||
|
size_t prettyPrintTo(Print& print) const;
|
||||||
protected:
|
|
||||||
|
protected:
|
||||||
JsonNodeIterator beginChildren() const
|
|
||||||
{
|
JsonNodeIterator beginChildren() const
|
||||||
return JsonNodeIterator(_node ? _node->getContainerChild() : 0);
|
{
|
||||||
}
|
return JsonNodeIterator(_node ? _node->getContainerChild() : 0);
|
||||||
|
}
|
||||||
JsonNodeIterator endChildren() const
|
|
||||||
{
|
JsonNodeIterator endChildren() const
|
||||||
return JsonNodeIterator(0);
|
{
|
||||||
}
|
return JsonNodeIterator(0);
|
||||||
|
}
|
||||||
void addChild(JsonNode*);
|
|
||||||
void removeChild(JsonNode*);
|
void addChild(JsonNode*);
|
||||||
JsonNode* createNode();
|
void removeChild(JsonNode*);
|
||||||
};
|
JsonNode* createNode();
|
||||||
|
};
|
||||||
|
|
@ -1,26 +1,26 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonContainer.h"
|
#include "JsonContainer.h"
|
||||||
|
|
||||||
class JsonObject : public JsonContainer
|
class JsonObject : public JsonContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
JsonObject()
|
JsonObject()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit JsonObject(JsonNode* node)
|
explicit JsonObject(JsonNode* node)
|
||||||
: JsonContainer(node)
|
: JsonContainer(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonValue operator[](const char* key);
|
JsonValue operator[](const char* key);
|
||||||
void remove(const char* key);
|
void remove(const char* key);
|
||||||
|
|
||||||
JsonArray createNestedArray(const char* key);
|
JsonArray createNestedArray(const char* key);
|
||||||
JsonObject createNestedObject(const char* key);
|
JsonObject createNestedObject(const char* key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode* getOrCreateNodeAt(const char* key);
|
JsonNode* getOrCreateNodeAt(const char* key);
|
||||||
};
|
};
|
@ -1,36 +1,36 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Internals/JsonNodeWrapper.h"
|
#include "Internals/JsonNodeWrapper.h"
|
||||||
|
|
||||||
class JsonArray;
|
class JsonArray;
|
||||||
class JsonContainer;
|
class JsonContainer;
|
||||||
class JsonObject;
|
class JsonObject;
|
||||||
|
|
||||||
class JsonValue : public JsonNodeWrapper
|
class JsonValue : public JsonNodeWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
JsonValue() {}
|
JsonValue() {}
|
||||||
|
|
||||||
explicit JsonValue(JsonNode* node)
|
explicit JsonValue(JsonNode* node)
|
||||||
: JsonNodeWrapper(node)
|
: JsonNodeWrapper(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator=(bool);
|
void operator=(bool);
|
||||||
void operator=(const char*);
|
void operator=(const char*);
|
||||||
void operator=(double x) { set(x, 2); }
|
void operator=(double x) { set(x, 2); }
|
||||||
void operator=(int);
|
void operator=(int);
|
||||||
void operator=(const JsonValue& value) { duplicate(value); }
|
void operator=(const JsonValue& value) { duplicate(value); }
|
||||||
void operator=(const JsonNodeWrapper& object) { duplicate(object); }
|
void operator=(const JsonNodeWrapper& object) { duplicate(object); }
|
||||||
|
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
operator const char*() const;
|
operator const char*() const;
|
||||||
operator double() const;
|
operator double() const;
|
||||||
operator long() const;
|
operator long() const;
|
||||||
operator int() const { return operator long(); }
|
operator int() const { return operator long(); }
|
||||||
operator JsonArray() const;
|
operator JsonArray() const;
|
||||||
operator JsonObject() const;
|
operator JsonObject() const;
|
||||||
|
|
||||||
void set(double value, int decimals);
|
void set(double value, int decimals);
|
||||||
};
|
};
|
@ -1,42 +1,42 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "JsonBuffer.h"
|
#include "JsonBuffer.h"
|
||||||
#include "JsonObject.h"
|
#include "JsonObject.h"
|
||||||
|
|
||||||
template<int CAPACITY>
|
template<int CAPACITY>
|
||||||
class StaticJsonBuffer : public JsonBuffer
|
class StaticJsonBuffer : public JsonBuffer
|
||||||
{
|
{
|
||||||
friend JsonObject;
|
friend JsonObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit StaticJsonBuffer()
|
explicit StaticJsonBuffer()
|
||||||
: _size(0)
|
: _size(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~StaticJsonBuffer() {}
|
virtual ~StaticJsonBuffer() {}
|
||||||
|
|
||||||
int capacity()
|
int capacity()
|
||||||
{
|
{
|
||||||
return CAPACITY;
|
return CAPACITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int size()
|
int size()
|
||||||
{
|
{
|
||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void* allocateNode()
|
virtual void* allocateNode()
|
||||||
{
|
{
|
||||||
if (_size >= CAPACITY) return 0;
|
if (_size >= CAPACITY) return 0;
|
||||||
|
|
||||||
return &_buffer[_size++];
|
return &_buffer[_size++];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonNode _buffer[CAPACITY];
|
JsonNode _buffer[CAPACITY];
|
||||||
int _size;
|
int _size;
|
||||||
};
|
};
|
||||||
|
|
@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ARDUINO
|
#ifndef ARDUINO
|
||||||
|
|
||||||
#include "Print.h"
|
#include "ArduinoJson/Arduino/Print.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
size_t Print::print(const char s[])
|
size_t Print::print(const char s[])
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
file(GLOB_RECURSE SRCS_FILES *.cpp *.h)
|
file(GLOB_RECURSE INC_FILES ../include/*.h)
|
||||||
|
file(GLOB_RECURSE SRC_FILES *.cpp)
|
||||||
|
|
||||||
add_library(ArduinoJson ${SRCS_FILES})
|
include_directories(../include)
|
||||||
|
|
||||||
|
add_library(ArduinoJson ${SRC_FILES} ${INC_FILES})
|
@ -1 +1 @@
|
|||||||
#include "CompactJsonWriter.h"
|
#include "ArduinoJson/Internals/CompactJsonWriter.h"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EscapedString.h"
|
#include "ArduinoJson/Internals/EscapedString.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "IndentedPrint.h"
|
#include "ArduinoJson/Internals/IndentedPrint.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Generator;
|
using namespace ArduinoJson::Generator;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "JsonNode.h"
|
#include "ArduinoJson/Internals/JsonNode.h"
|
||||||
|
|
||||||
#include "JsonWriter.h"
|
#include "ArduinoJson/Internals/JsonWriter.h"
|
||||||
#include "../JsonArray.h"
|
#include "ArduinoJson/JsonArray.h"
|
||||||
#include "../JsonObject.h"
|
#include "ArduinoJson/JsonObject.h"
|
||||||
#include "../JsonBuffer.h"
|
#include "ArduinoJson/JsonBuffer.h"
|
||||||
|
|
||||||
void JsonNode::writeTo(JsonWriter& writer)
|
void JsonNode::writeTo(JsonWriter& writer)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "JsonParser.h"
|
#include "ArduinoJson/Internals/JsonParser.h"
|
||||||
#include "../JsonBuffer.h"
|
#include "ArduinoJson/JsonBuffer.h"
|
||||||
#include <stdlib.h> // for strtol, strtod
|
#include <stdlib.h> // for strtol, strtod
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "JsonWriter.h"
|
#include "ArduinoJson/Internals/JsonWriter.h"
|
||||||
#include "EscapedString.h"
|
#include "ArduinoJson/Internals/EscapedString.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
#include "PrettyJsonWriter.h"
|
#include "ArduinoJson/Internals/PrettyJsonWriter.h"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Arduino JSON library
|
* Arduino JSON library
|
||||||
* Benoit Blanchon 2014 - MIT License
|
* Benoit Blanchon 2014 - MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StringBuilder.h"
|
#include "ArduinoJson/Internals/StringBuilder.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "JsonArray.h"
|
#include "ArduinoJson/JsonArray.h"
|
||||||
|
#include "ArduinoJson/JsonObject.h"
|
||||||
#include "JsonObject.h"
|
#include "ArduinoJson/JsonValue.h"
|
||||||
#include "JsonValue.h"
|
|
||||||
|
|
||||||
JsonValue JsonArray::operator[](int index) const
|
JsonValue JsonArray::operator[](int index) const
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "JsonBuffer.h"
|
#include "ArduinoJson/JsonBuffer.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "JsonValue.h"
|
#include "ArduinoJson/JsonValue.h"
|
||||||
#include "Internals/JsonParser.h"
|
#include "ArduinoJson/Internals/JsonParser.h"
|
||||||
#include "Internals/JsonNode.h"
|
#include "ArduinoJson/Internals/JsonNode.h"
|
||||||
|
|
||||||
JsonValue JsonBuffer::createValue()
|
JsonValue JsonBuffer::createValue()
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#include "JsonContainer.h"
|
#include "ArduinoJson/JsonContainer.h"
|
||||||
|
|
||||||
#include "JsonBuffer.h"
|
#include "ArduinoJson/JsonBuffer.h"
|
||||||
#include "Internals/StringBuilder.h"
|
#include "ArduinoJson/Internals/StringBuilder.h"
|
||||||
#include "Internals/CompactJsonWriter.h"
|
#include "ArduinoJson/Internals/CompactJsonWriter.h"
|
||||||
#include "Internals/PrettyJsonWriter.h"
|
#include "ArduinoJson/Internals/PrettyJsonWriter.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "JsonObject.h"
|
#include "ArduinoJson/JsonObject.h"
|
||||||
|
|
||||||
#include <string.h> // for strcmp
|
#include <string.h> // for strcmp
|
||||||
|
|
||||||
#include "JsonBuffer.h"
|
#include "ArduinoJson/JsonBuffer.h"
|
||||||
#include "JsonValue.h"
|
#include "ArduinoJson/JsonValue.h"
|
||||||
#include "Internals/EscapedString.h"
|
#include "ArduinoJson/Internals/EscapedString.h"
|
||||||
#include "Internals/JsonNode.h"
|
#include "ArduinoJson/Internals/JsonNode.h"
|
||||||
#include "Internals/StringBuilder.h"
|
#include "ArduinoJson/Internals/StringBuilder.h"
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "JsonValue.h"
|
#include "ArduinoJson/JsonValue.h"
|
||||||
|
|
||||||
#include "JsonArray.h"
|
#include "ArduinoJson/JsonArray.h"
|
||||||
#include "JsonObject.h"
|
#include "ArduinoJson/JsonObject.h"
|
||||||
#include "Internals/JsonNode.h"
|
#include "ArduinoJson/Internals/JsonNode.h"
|
||||||
|
|
||||||
void JsonValue::operator=(bool value)
|
void JsonValue::operator=(bool value)
|
||||||
{
|
{
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
set(GTEST_DIR ../third-party/gtest-1.7.0)
|
set(GTEST_DIR ../third-party/gtest-1.7.0)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE INC_FILES ../include/*.h)
|
||||||
file(GLOB TESTS_FILES *.cpp)
|
file(GLOB TESTS_FILES *.cpp)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
../srcs
|
../include
|
||||||
${GTEST_DIR}
|
${GTEST_DIR}
|
||||||
${GTEST_DIR}/include)
|
${GTEST_DIR}/include)
|
||||||
|
|
||||||
add_executable(ArduinoJsonTests
|
add_executable(ArduinoJsonTests
|
||||||
${TESTS_FILES}
|
${TESTS_FILES}
|
||||||
|
${INC_FILES}
|
||||||
${GTEST_DIR}/src/gtest-all.cc
|
${GTEST_DIR}/src/gtest-all.cc
|
||||||
${GTEST_DIR}/src/gtest_main.cc)
|
${GTEST_DIR}/src/gtest_main.cc)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <Internals/EscapedString.h>
|
#include <ArduinoJson/Internals/EscapedString.h>
|
||||||
#include <Internals/StringBuilder.h>
|
#include <ArduinoJson/Internals/StringBuilder.h>
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <JsonArray.h>
|
#include <ArduinoJson/JsonArray.h>
|
||||||
#include <JsonObject.h>
|
#include <ArduinoJson/JsonObject.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
|
|
||||||
using namespace ArduinoJson::Generator;
|
using namespace ArduinoJson::Generator;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
|
|
||||||
class JsonArray_Container_Tests : public ::testing::Test
|
class JsonArray_Container_Tests : public ::testing::Test
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
|
|
||||||
class JsonArray_Parser_Tests : public testing::Test
|
class JsonArray_Parser_Tests : public testing::Test
|
||||||
{
|
{
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <JsonArray.h>
|
#include <ArduinoJson/JsonArray.h>
|
||||||
#include <JsonObject.h>
|
#include <ArduinoJson/JsonObject.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
|
|
||||||
class JsonArray_PrettyPrintTo_Tests : public testing::Test
|
class JsonArray_PrettyPrintTo_Tests : public testing::Test
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <JsonArray.h>
|
#include <ArduinoJson/JsonArray.h>
|
||||||
#include <JsonObject.h>
|
#include <ArduinoJson/JsonObject.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
|
|
||||||
class JsonArray_PrintTo_Tests : public testing::Test
|
class JsonArray_PrintTo_Tests : public testing::Test
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
|
|
||||||
class JsonObject_Container_Tests : public ::testing::Test
|
class JsonObject_Container_Tests : public ::testing::Test
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <JsonObject.h>
|
#include <ArduinoJson/JsonObject.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
|
|
||||||
class JsonObject_PrettyPrintTo_Tests : public testing::Test
|
class JsonObject_PrettyPrintTo_Tests : public testing::Test
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <JsonArray.h>
|
#include <ArduinoJson/JsonArray.h>
|
||||||
#include <JsonObject.h>
|
#include <ArduinoJson/JsonObject.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
|
|
||||||
class JsonObject_Serialization_Tests : public testing::Test
|
class JsonObject_Serialization_Tests : public testing::Test
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
|
|
||||||
class JsonValueTests : public ::testing::Test
|
class JsonValueTests : public ::testing::Test
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <StaticJsonBuffer.h>
|
#include <ArduinoJson/StaticJsonBuffer.h>
|
||||||
#include <JsonValue.h>
|
#include <ArduinoJson/JsonValue.h>
|
||||||
|
|
||||||
TEST(StaticJsonBuffer, CapacityMatchTemplateParameter)
|
TEST(StaticJsonBuffer, CapacityMatchTemplateParameter)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <Internals/StringBuilder.h>
|
#include <ArduinoJson/Internals/StringBuilder.h>
|
||||||
|
|
||||||
using namespace ArduinoJson::Internals;
|
using namespace ArduinoJson::Internals;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user