Cleaning up...

This commit is contained in:
Benoit Blanchon
2014-10-31 12:02:15 +01:00
parent a5dbb397ca
commit 5443e90baf
11 changed files with 47 additions and 86 deletions

View File

@@ -16,16 +16,13 @@ class CompactJsonWriter : public JsonWriter {
explicit CompactJsonWriter(Print *sink) : JsonWriter(sink) {}
virtual void beginArray() { _length += _sink->write('['); }
virtual void endArray() { _length += _sink->write(']'); }
virtual void writeColon() { _length += _sink->write(':'); }
virtual void writeComma() { _length += _sink->write(','); }
virtual void beginObject() { _length += _sink->write('{'); }
virtual void endObject() { _length += _sink->write('}'); }
virtual void writeColon() { _length += _sink->write(':'); }
virtual void writeComma() { _length += _sink->write(','); }
};
}
}

View File

@@ -14,7 +14,7 @@ namespace Internals {
class JsonArrayNode {
public:
JsonArrayNode() : next(0) {}
JsonArrayNode() : next(NULL) {}
JsonArrayNode* next;
JsonValue value;

View File

@@ -20,7 +20,7 @@ class JsonParser {
JsonObject &parseObject();
private:
bool isEnd() { return *_ptr == 0; }
bool isEnd() { return *_ptr == '\0'; }
bool skip(char charToSkip);
void skipSpaces();

View File

@@ -1,26 +0,0 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
#include "../ForwardDeclarations.hpp"
namespace ArduinoJson {
namespace Internals {
class JsonSerializer {
public:
JsonSerializer(JsonWriter &writer) : _writer(writer) {}
void serialize(JsonValueImpl *value);
void serialize(JsonArrayImpl *value);
void serialize(JsonObjectImpl *value);
private:
JsonWriter &_writer;
};
}
}

View File

@@ -14,7 +14,7 @@ namespace Internals {
union JsonValueContent {
bool asBoolean;
double asDouble;
long asInteger;
long asLong;
const char* asString;
JsonArray* asArray;
JsonObject* asObject;

View File

@@ -18,12 +18,12 @@ class JsonWriter {
size_t bytesWritten() { return _length; }
virtual void beginArray() = 0;
virtual void endArray() = 0;
void writeEmptyArray() { _length += _sink->print("[]"); }
virtual void beginObject() = 0;
virtual void endObject() = 0;
void writeEmptyObject() { _length += _sink->print("{}"); }
void writeString(const char *value);
void writeInteger(long value);
@@ -31,13 +31,8 @@ class JsonWriter {
void writeDouble(double value, int decimals);
virtual void writeColon() = 0;
virtual void writeComma() = 0;
void writeEmptyArray() { _length += _sink->print("[]"); }
void writeEmptyObject() { _length += _sink->print("{}"); }
protected:
Print *_sink;
size_t _length;

View File

@@ -1,25 +0,0 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
namespace ArduinoJson {
namespace Internals {
// A class that is not meant to be copied
class NonCopyable {
protected:
NonCopyable() {}
private:
// copy constructor is private
NonCopyable(const NonCopyable&);
// copy operator is private
NonCopyable& operator=(const NonCopyable&);
};
}
}

View File

@@ -0,0 +1,32 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
namespace ArduinoJson {
namespace Internals {
// A type that is meant to be used by reference only (JsonArray and JsonObject)
class ReferenceType {
public:
bool operator==(const ReferenceType& other) const {
// two JsonArray are equal if they are the same instance
// (we don't compare the content)
return this == &other;
}
protected:
ReferenceType() {}
private:
// copy constructor is private
ReferenceType(const ReferenceType&);
// copy operator is private
ReferenceType& operator=(const ReferenceType&);
};
}
}