Switched to Google coding style to match cpplint expectations

This commit is contained in:
Benoit Blanchon
2014-10-23 23:13:13 +02:00
parent 5c8283b3e4
commit b43da1e421
47 changed files with 262 additions and 308 deletions

View File

@@ -5,7 +5,7 @@
namespace ArduinoJson {
namespace Internals {
class CompactJsonWriter : public JsonWriter {
public:
public:
explicit CompactJsonWriter(Print *sink) : JsonWriter(sink) {}
virtual void beginArray() { _length += _sink->write('['); }

View File

@@ -13,7 +13,7 @@ namespace Internals {
// This class is used by JsonPrintable::prettyPrintTo() but can also be used
// for your own purpose, like logging.
class IndentedPrint : public Print {
public:
public:
IndentedPrint(Print &p) : sink(&p) {
level = 0;
tabSize = 2;
@@ -31,7 +31,7 @@ public:
// Set the number of space printed for each level of indentation
void setTabSize(uint8_t n);
private:
private:
Print *sink;
uint8_t level : 4;
uint8_t tabSize : 3;
@@ -39,8 +39,8 @@ private:
size_t writeTabs();
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_LEVEL = 15; // because it's only 4 bits
static const int MAX_TAB_SIZE = 7; // because it's only 3 bits
};
}
}

View File

@@ -44,12 +44,12 @@ class JsonNode {
} asProxy;
};
public:
public:
JsonNode() : next(0), type(JSON_UNDEFINED) {}
JsonNode *next;
void writeTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer
void writeTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer
void setAsArray(JsonBuffer *buffer) {
type = JSON_ARRAY;
@@ -104,16 +104,14 @@ public:
}
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;
}
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;
}
@@ -140,13 +138,14 @@ public:
void duplicate(JsonNode *other);
private:
private:
JsonNodeType type;
JsonNodeContent content;
inline void writeArrayTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer
inline void
writeObjectTo(JsonWriter &); // TODO: <- move in JsonNodeSerializer
inline void writeArrayTo(
JsonWriter &); // TODO: <- move in JsonNodeSerializer
inline void writeObjectTo(
JsonWriter &); // TODO: <- move in JsonNodeSerializer
void setAsProxyOfSelf();

View File

@@ -6,7 +6,7 @@ namespace ArduinoJson {
namespace Internals {
// TODO: replace by JsonArrayIterator and JsonObjectIterator
class JsonNodeIterator {
public:
public:
explicit JsonNodeIterator(JsonNode *node) : _node(node) {}
bool operator!=(const JsonNodeIterator &other) const {
@@ -19,7 +19,7 @@ public:
JsonNode *operator->() const { return _node; }
private:
private:
JsonNode *_node;
};
}

View File

@@ -9,12 +9,12 @@ namespace Internals {
class JsonNodeWrapper {
friend class JsonValue;
public:
public:
JsonNodeWrapper() : _node(0) {}
explicit JsonNodeWrapper(JsonNode *node) : _node(node) {}
protected:
protected:
void duplicate(const JsonNodeWrapper &other) {
if (!_node) {
_node = other._node;

View File

@@ -9,12 +9,12 @@ namespace Internals {
class JsonNode;
class JsonParser {
public:
public:
JsonParser(JsonBuffer *buffer, char *json) : _buffer(buffer), _ptr(json) {}
JsonNode *parseAnything();
private:
private:
JsonBuffer *_buffer;
char *_ptr;

View File

@@ -5,7 +5,7 @@
namespace ArduinoJson {
namespace Internals {
class JsonWriter {
public:
public:
explicit JsonWriter(Print *sink) : _sink(sink), _length(0) {}
size_t bytesWritten() { return _length; }
@@ -31,7 +31,7 @@ public:
void writeEmptyObject() { _length += _sink->print("{}"); }
protected:
protected:
Print *_sink;
size_t _length;
};

View File

@@ -6,7 +6,7 @@
namespace ArduinoJson {
namespace Internals {
class PrettyJsonWriter : public JsonWriter {
public:
public:
explicit PrettyJsonWriter(IndentedPrint *sink)
: JsonWriter(sink), _indenter(sink) {}
@@ -37,7 +37,7 @@ public:
_length += _sink->write('}');
}
private:
private:
IndentedPrint *_indenter;
void indent() {

View File

@@ -10,7 +10,7 @@
namespace ArduinoJson {
namespace Internals {
class QuotedString {
public:
public:
static size_t printTo(const char *, Print *);
static char *extractFrom(char *input, char **end);

View File

@@ -10,7 +10,7 @@
namespace ArduinoJson {
namespace Internals {
class StringBuilder : public Print {
public:
public:
StringBuilder(char *buf, int size)
: buffer(buf), capacity(size - 1), length(0) {
buffer[0] = 0;
@@ -18,7 +18,7 @@ public:
virtual size_t write(uint8_t c);
private:
private:
char *buffer;
int capacity;
int length;