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

@ -9,42 +9,40 @@ using namespace ArduinoJson::Internals;
void JsonNode::writeTo(JsonWriter &writer) {
switch (type) {
case JSON_PROXY:
content.asProxy.target->writeTo(writer);
break;
case JSON_PROXY:
content.asProxy.target->writeTo(writer);
break;
case JSON_ARRAY:
writeArrayTo(writer);
break;
case JSON_ARRAY:
writeArrayTo(writer);
break;
case JSON_OBJECT:
writeObjectTo(writer);
break;
case JSON_OBJECT:
writeObjectTo(writer);
break;
case JSON_STRING:
writer.writeString(content.asString);
break;
case JSON_STRING:
writer.writeString(content.asString);
break;
case JSON_LONG:
writer.writeInteger(content.asInteger);
break;
case JSON_LONG:
writer.writeInteger(content.asInteger);
break;
case JSON_BOOLEAN:
writer.writeBoolean(content.asBoolean);
break;
case JSON_BOOLEAN:
writer.writeBoolean(content.asBoolean);
break;
default: // >= JSON_DOUBLE_0_DECIMALS
writer.writeDouble(content.asDouble, type - JSON_DOUBLE_0_DECIMALS);
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_PROXY) return content.asProxy.target->addChild(childToAdd);
if (type != JSON_ARRAY && type != JSON_OBJECT)
return;
if (type != JSON_ARRAY && type != JSON_OBJECT) return;
JsonNode *lastChild = content.asContainer.child;
@ -53,8 +51,7 @@ void JsonNode::addChild(JsonNode *childToAdd) {
return;
}
while (lastChild->next)
lastChild = lastChild->next;
while (lastChild->next) lastChild = lastChild->next;
lastChild->next = childToAdd;
}
@ -63,8 +60,7 @@ void JsonNode::removeChild(JsonNode *childToRemove) {
if (type == JSON_PROXY)
return content.asProxy.target->removeChild(childToRemove);
if (type != JSON_ARRAY && type != JSON_OBJECT)
return;
if (type != JSON_ARRAY && type != JSON_OBJECT) return;
if (content.asContainer.child == childToRemove) {
content.asContainer.child = childToRemove->next;
@ -73,8 +69,7 @@ void JsonNode::removeChild(JsonNode *childToRemove) {
for (JsonNode *child = content.asContainer.child; child;
child = child->next) {
if (child->next == childToRemove)
child->next = childToRemove->next;
if (child->next == childToRemove) child->next = childToRemove->next;
}
}
@ -88,8 +83,7 @@ void JsonNode::writeArrayTo(JsonWriter &writer) {
child->writeTo(writer);
child = child->next;
if (!child)
break;
if (!child) break;
writer.writeComma();
}
@ -112,8 +106,7 @@ void JsonNode::writeObjectTo(JsonWriter &writer) {
child->content.asKeyValue.value->writeTo(writer);
child = child->next;
if (!child)
break;
if (!child) break;
writer.writeComma();
}
@ -126,12 +119,10 @@ void JsonNode::writeObjectTo(JsonWriter &writer) {
void JsonNode::setAsProxyOfSelf() {
JsonBuffer *buffer = content.asContainer.buffer;
if (!buffer)
return;
if (!buffer) return;
JsonNode *newNode = buffer->createNode();
if (!newNode)
return;
if (!newNode) return;
*newNode = *this;