From df72419f093615d247624c9c47ce659846a5f9b6 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 21 Jul 2014 15:20:02 +0200 Subject: [PATCH] Added comments --- JsonParser/JsonArray.h | 30 +++++++++++++++--------------- JsonParser/JsonArrayIterator.h | 10 +++++----- JsonParser/JsonObject.h | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/JsonParser/JsonArray.h b/JsonParser/JsonArray.h index 27af4bec..ba5bae55 100644 --- a/JsonParser/JsonArray.h +++ b/JsonParser/JsonArray.h @@ -14,86 +14,86 @@ namespace ArduinoJson { class JsonObject; - // A JSON array. + // A JSON array class JsonArray : JsonValue { public: - // Create an invalid array. + // Create an invalid array JsonArray() { } - // Convert a JsonValue into a JsonArray. + // Convert a JsonValue into a JsonArray JsonArray(JsonValue value) : JsonValue(value) { } - // Tell if the array is valid. + // Tell if the array is valid bool success() { return isArray(); } - // Get the JsonValue at specified index. + // Get the JsonValue at specified index JsonValue operator[](int index) { return JsonValue::operator[](index); } - // Get the size of the array. + // Get the size of the array int size() { return isArray() ? childrenCount() : 0; } - // Get an iterator pointing to the beginning of the array. + // Get an iterator pointing to the beginning of the array JsonArrayIterator begin() { return isArray() ? firstChild() : null(); } - // Gets an iterator pointing to the end of the array. + // Gets an iterator pointing to the end of the array JsonArrayIterator end() { return isArray() ? nextSibling() : null(); } - // Obsolete. Use size() instead. + // Obsolete: Use size() instead DEPRECATED int getLength() { return size(); } - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED JsonArray getArray(int index) { return operator[](index); } - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED bool getBool(int index) { return operator[](index); } - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED double getDouble(int index) { return operator[](index); } - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED JsonObject getHashTable(int index); - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED long getLong(int index) { return operator[](index); } - // Obsolete. Use operator[] instead. + // Obsolete: Use operator[] instead DEPRECATED char* getString(int index) { return operator[](index); diff --git a/JsonParser/JsonArrayIterator.h b/JsonParser/JsonArrayIterator.h index 1f662fbc..9eb0725e 100644 --- a/JsonParser/JsonArrayIterator.h +++ b/JsonParser/JsonArrayIterator.h @@ -12,31 +12,31 @@ namespace ArduinoJson { namespace Parser { - // An iterator for JsonArray. + // An iterator for JsonArray class JsonArrayIterator : JsonToken { public: - // Create an iterator pointing at the specified JsonToken. + // Create an iterator pointing at the specified JsonToken JsonArrayIterator(JsonToken token) : JsonToken(token) { } - // Move iterator forward. + // Move iterator forward void operator++() { *this = JsonArrayIterator(nextSibling()); } - // Get the value pointed by the iterator. + // Get the value pointed by the iterator JsonValue operator*() const { return JsonValue(*this); } - // Test iterator equality. + // Test iterator equality bool operator!= (const JsonArrayIterator& other) const { return JsonToken::operator!=(other); diff --git a/JsonParser/JsonObject.h b/JsonParser/JsonObject.h index e73f3d2f..4c1baab4 100644 --- a/JsonParser/JsonObject.h +++ b/JsonParser/JsonObject.h @@ -14,73 +14,89 @@ namespace ArduinoJson { class JsonArray; + // A JSON Object (ie hash-table/dictionary) class JsonObject : JsonValue { public: + + // Create an invalid JsonObject JsonObject() { } + // Convert a JsonValue into a JsonObject JsonObject(JsonValue value) : JsonValue(value) { } + // Tell if the object is valid bool success() { return isObject(); } + // Get the value associated with the specified key. JsonValue operator[](const char* key) { return JsonValue::operator[](key); } + // Tell if the specified key exists in the object. bool containsKey(const char* key) { return operator[](key).success(); } + // Get an iterator pointing at the beginning of the object JsonObjectIterator begin() { return isObject() ? firstChild() : null(); } + // Get an iterator pointing at the end of the object JsonObjectIterator end() { return isObject() ? nextSibling() : null(); } + // Obsolete: Use operator[] instead DEPRECATED JsonArray getArray(const char* key); + // Obsolete: Use operator[] instead DEPRECATED bool getBool(const char* key) { return operator[](key); } + // Obsolete: Use operator[] instead DEPRECATED double getDouble(const char* key) { return operator[](key); } + // Obsolete: Use operator[] instead DEPRECATED JsonObject getHashTable(const char* key) { return operator[](key); } + // Obsolete: Use operator[] instead DEPRECATED long getLong(const char* key) { return operator[](key); } + // Obsolete: Use operator[] instead DEPRECATED char* getString(const char* key) { return operator[](key); } }; + // Obsolete: Use JsonObject instead typedef JsonObject JsonHashTable; } } \ No newline at end of file