Răsfoiți Sursa

Renamed JsonHashTable into JsonObject

Benoit Blanchon 11 ani în urmă
părinte
comite
b75d32e980

+ 1 - 1
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"

+ 3 - 3
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];
 }
 
 /*

+ 2 - 2
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)
             {

+ 0 - 2
JsonParser/JsonArrayIterator.h

@@ -12,8 +12,6 @@ namespace ArduinoJson
 {
     namespace Parser
     {
-        class JsonHashTable;
-
         class JsonArrayIterator
         {
         public:

+ 3 - 3
JsonParser/JsonHashTable.cpp → JsonParser/JsonObject.cpp

@@ -4,14 +4,14 @@
 */
 
 #include <string.h> // 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())

+ 13 - 13
JsonParser/JsonHashTable.h → 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;
     }
 }

+ 4 - 4
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:

+ 5 - 5
JsonParser/JsonValue.cpp

@@ -5,7 +5,7 @@
 
 #include <stdlib.h> // 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();
 }

+ 2 - 2
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);
 

+ 0 - 0
JsonParserTests/JsonHashTableTests.cpp → JsonParserTests/JsonObjectTests.cpp


+ 3 - 3
JsonParserTests/JsonParserTests.vcxproj

@@ -87,20 +87,20 @@
   <ItemGroup>
     <ClCompile Include="..\JsonParser\jsmn.cpp" />
     <ClCompile Include="..\JsonParser\JsonArray.cpp" />
-    <ClCompile Include="..\JsonParser\JsonHashTable.cpp" />
+    <ClCompile Include="..\JsonParser\JsonObject.cpp" />
     <ClCompile Include="..\JsonParser\JsonParserBase.cpp" />
     <ClCompile Include="..\JsonParser\JsonToken.cpp" />
     <ClCompile Include="..\JsonParser\JsonValue.cpp" />
     <ClCompile Include="JsonArrayIteratorTests.cpp" />
     <ClCompile Include="JsonArrayTests.cpp" />
-    <ClCompile Include="JsonHashTableTests.cpp" />
+    <ClCompile Include="JsonObjectTests.cpp" />
     <ClCompile Include="GbathreeBug.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\JsonParser\jsmn.h" />
     <ClInclude Include="..\JsonParser\JsonArray.h" />
     <ClInclude Include="..\JsonParser\JsonArrayIterator.h" />
-    <ClInclude Include="..\JsonParser\JsonHashTable.h" />
+    <ClInclude Include="..\JsonParser\JsonObject.h" />
     <ClInclude Include="..\JsonParser\JsonParser.h" />
     <ClInclude Include="..\JsonParser\JsonParserBase.h" />
     <ClInclude Include="..\JsonParser\JsonToken.h" />

+ 9 - 9
JsonParserTests/JsonParserTests.vcxproj.filters

@@ -21,18 +21,12 @@
     <ClCompile Include="..\JsonParser\JsonArray.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\JsonParser\JsonHashTable.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="JsonArrayTests.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="GbathreeBug.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="JsonHashTableTests.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\JsonParser\JsonParserBase.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -45,6 +39,12 @@
     <ClCompile Include="..\JsonParser\JsonToken.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\JsonParser\JsonObject.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="JsonObjectTests.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\JsonParser\jsmn.h">
@@ -53,9 +53,6 @@
     <ClInclude Include="..\JsonParser\JsonArray.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\JsonParser\JsonHashTable.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\JsonParser\JsonParser.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -71,5 +68,8 @@
     <ClInclude Include="..\JsonParser\JsonToken.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\JsonParser\JsonObject.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>