From b75d32e980aa985adab2b6b15adebf5dea9cf36d Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Fri, 18 Jul 2014 16:46:01 +0200 Subject: [PATCH] Renamed JsonHashTable into JsonObject --- JsonParser.cpp | 2 +- JsonParser/JsonArray.cpp | 6 ++--- JsonParser/JsonArray.h | 4 +-- JsonParser/JsonArrayIterator.h | 2 -- .../{JsonHashTable.cpp => JsonObject.cpp} | 6 ++--- JsonParser/{JsonHashTable.h => JsonObject.h} | 26 +++++++++---------- JsonParser/JsonParserBase.h | 8 +++--- JsonParser/JsonValue.cpp | 10 +++---- JsonParser/JsonValue.h | 4 +-- ...HashTableTests.cpp => JsonObjectTests.cpp} | 0 JsonParserTests/JsonParserTests.vcxproj | 6 ++--- .../JsonParserTests.vcxproj.filters | 18 ++++++------- 12 files changed, 45 insertions(+), 47 deletions(-) rename JsonParser/{JsonHashTable.cpp => JsonObject.cpp} (85%) rename JsonParser/{JsonHashTable.h => JsonObject.h} (79%) rename JsonParserTests/{JsonHashTableTests.cpp => JsonObjectTests.cpp} (100%) diff --git a/JsonParser.cpp b/JsonParser.cpp index 55efcc22..0fc7597e 100644 --- a/JsonParser.cpp +++ b/JsonParser.cpp @@ -6,7 +6,7 @@ // This file is here to help the Arduino IDE find the .cpp files #include "JsonParser/JsonArray.cpp" -#include "JsonParser/JsonHashTable.cpp" +#include "JsonParser/JsonObject.cpp" #include "JsonParser/JsonParserBase.cpp" #include "JsonParser/JsonValue.cpp" #include "JsonParser/JsonToken.cpp" diff --git a/JsonParser/JsonArray.cpp b/JsonParser/JsonArray.cpp index 054b8a9b..465f1c3f 100644 --- a/JsonParser/JsonArray.cpp +++ b/JsonParser/JsonArray.cpp @@ -4,14 +4,14 @@ */ #include "JsonArray.h" -#include "JsonHashTable.h" +#include "JsonObject.h" using namespace ArduinoJson::Parser; using namespace ArduinoJson::Internal; -DEPRECATED JsonHashTable JsonArray::getHashTable(int index) +DEPRECATED JsonObject JsonArray::getHashTable(int index) { - return (JsonHashTable) (*this)[index]; + return (JsonObject) (*this)[index]; } /* diff --git a/JsonParser/JsonArray.h b/JsonParser/JsonArray.h index 70cb0aea..dd2f1f35 100644 --- a/JsonParser/JsonArray.h +++ b/JsonParser/JsonArray.h @@ -13,7 +13,7 @@ namespace ArduinoJson { namespace Parser { - class JsonHashTable; + class JsonObject; class JsonArray { @@ -73,7 +73,7 @@ namespace ArduinoJson return (double) (*this)[index]; } - DEPRECATED JsonHashTable getHashTable(int index); + DEPRECATED JsonObject getHashTable(int index); DEPRECATED long getLong(int index) { diff --git a/JsonParser/JsonArrayIterator.h b/JsonParser/JsonArrayIterator.h index 87b85646..071af5d7 100644 --- a/JsonParser/JsonArrayIterator.h +++ b/JsonParser/JsonArrayIterator.h @@ -12,8 +12,6 @@ namespace ArduinoJson { namespace Parser { - class JsonHashTable; - class JsonArrayIterator { public: diff --git a/JsonParser/JsonHashTable.cpp b/JsonParser/JsonObject.cpp similarity index 85% rename from JsonParser/JsonHashTable.cpp rename to JsonParser/JsonObject.cpp index 464571ca..9368edf0 100644 --- a/JsonParser/JsonHashTable.cpp +++ b/JsonParser/JsonObject.cpp @@ -4,14 +4,14 @@ */ #include // for strcmp() -#include "JsonHashTable.h" #include "JsonArray.h" +#include "JsonObject.h" #include "JsonValue.h" using namespace ArduinoJson::Parser; using namespace ArduinoJson::Internal; -DEPRECATED JsonArray JsonHashTable::getArray(const char* key) +DEPRECATED JsonArray JsonObject::getArray(const char* key) { return (*this)[key]; } @@ -19,7 +19,7 @@ DEPRECATED JsonArray JsonHashTable::getArray(const char* key) /* * Returns the token for the value associated with the specified key */ -JsonValue JsonHashTable::getValue(const char* desiredKey) +JsonValue JsonObject::getValue(const char* desiredKey) { // sanity check if (desiredKey == 0 || !token.isObject()) diff --git a/JsonParser/JsonHashTable.h b/JsonParser/JsonObject.h similarity index 79% rename from JsonParser/JsonHashTable.h rename to JsonParser/JsonObject.h index 9d285304..1f546e1d 100644 --- a/JsonParser/JsonHashTable.h +++ b/JsonParser/JsonObject.h @@ -13,13 +13,17 @@ namespace ArduinoJson { class JsonArray; - class JsonHashTable + class JsonObject { - friend class JsonValue; - public: - JsonHashTable() + JsonObject(char* json, Internal::JsonToken token) + : json(json), token(token) + { + + } + + JsonObject() : token(Internal::JsonToken::null()) { } @@ -51,7 +55,7 @@ namespace ArduinoJson return getValue(key); } - DEPRECATED JsonHashTable getHashTable(const char* key) + DEPRECATED JsonObject getHashTable(const char* key) { return getValue(key); } @@ -66,23 +70,19 @@ namespace ArduinoJson return getValue(key); } - static JsonHashTable null() + static JsonObject null() { - return JsonHashTable(); + return JsonObject(); } private: - JsonHashTable(char* json, Internal::JsonToken token) - : json(json), token(token) - { - - } - char* json; Internal::JsonToken token; JsonValue getValue(const char* key); }; + + typedef JsonObject JsonHashTable; } } \ No newline at end of file diff --git a/JsonParser/JsonParserBase.h b/JsonParser/JsonParserBase.h index 569cde01..8f01f0a1 100644 --- a/JsonParser/JsonParserBase.h +++ b/JsonParser/JsonParserBase.h @@ -5,8 +5,8 @@ #pragma once -#include "JsonHashTable.h" #include "JsonArray.h" +#include "JsonObject.h" namespace ArduinoJson { @@ -31,7 +31,7 @@ namespace ArduinoJson */ DEPRECATED JsonArray parseArray(char* json) { - return (JsonArray)parse(json); + return parse(json); } /* @@ -40,9 +40,9 @@ namespace ArduinoJson * The content of the string may be altered to add '\0' at the * end of string tokens */ - DEPRECATED JsonHashTable parseHashTable(char* json) + DEPRECATED JsonObject parseHashTable(char* json) { - return (JsonHashTable)parse(json); + return parse(json); } private: diff --git a/JsonParser/JsonValue.cpp b/JsonParser/JsonValue.cpp index 221c10b2..7cc2d7b7 100644 --- a/JsonParser/JsonValue.cpp +++ b/JsonParser/JsonValue.cpp @@ -5,7 +5,7 @@ #include // for strtol, strtod #include "JsonArray.h" -#include "JsonHashTable.h" +#include "JsonObject.h" #include "JsonValue.h" using namespace ArduinoJson::Parser; @@ -18,7 +18,7 @@ JsonValue JsonValue::operator[](int index) JsonValue JsonValue::operator[](const char* key) { - return JsonHashTable(json, token)[key]; + return JsonObject(json, token)[key]; } JsonValue::operator bool() @@ -62,9 +62,9 @@ JsonValue::operator JsonArray() : JsonArray::null(); } -JsonValue::operator JsonHashTable() +JsonValue::operator JsonObject() { return token.isObject() - ? JsonHashTable(json, token) - : JsonHashTable::null(); + ? JsonObject(json, token) + : JsonObject::null(); } \ No newline at end of file diff --git a/JsonParser/JsonValue.h b/JsonParser/JsonValue.h index 900b5dbc..4c5f973b 100644 --- a/JsonParser/JsonValue.h +++ b/JsonParser/JsonValue.h @@ -22,7 +22,7 @@ namespace ArduinoJson namespace Parser { class JsonArray; - class JsonHashTable; + class JsonObject; class JsonValue { @@ -44,7 +44,7 @@ namespace ArduinoJson operator long(); operator char*(); operator JsonArray(); - operator JsonHashTable(); + operator JsonObject(); JsonValue operator[](int index); JsonValue operator[](const char*key); diff --git a/JsonParserTests/JsonHashTableTests.cpp b/JsonParserTests/JsonObjectTests.cpp similarity index 100% rename from JsonParserTests/JsonHashTableTests.cpp rename to JsonParserTests/JsonObjectTests.cpp diff --git a/JsonParserTests/JsonParserTests.vcxproj b/JsonParserTests/JsonParserTests.vcxproj index 156cfd01..7cab6d7d 100644 --- a/JsonParserTests/JsonParserTests.vcxproj +++ b/JsonParserTests/JsonParserTests.vcxproj @@ -87,20 +87,20 @@ - + - + - + diff --git a/JsonParserTests/JsonParserTests.vcxproj.filters b/JsonParserTests/JsonParserTests.vcxproj.filters index a88b7cb2..4774c593 100644 --- a/JsonParserTests/JsonParserTests.vcxproj.filters +++ b/JsonParserTests/JsonParserTests.vcxproj.filters @@ -21,18 +21,12 @@ Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files @@ -45,6 +39,12 @@ Source Files + + Source Files + + + Source Files + @@ -53,9 +53,6 @@ Header Files - - Header Files - Header Files @@ -71,5 +68,8 @@ Header Files + + Header Files + \ No newline at end of file