diff options
author | Jamey Hicks <jamey.hicks@nokia.com> | 2011-12-02 16:39:33 -0500 |
---|---|---|
committer | Knoll Lars <lars.knoll@nokia.com> | 2011-12-05 10:13:50 +0100 |
commit | d9854500a7725f2bd40418c02c09bc9e3b70f76c (patch) | |
tree | 849fb5b3937aca677d997b1c2503048d5c0df072 | |
parent | 0ca39f93362663d064fea0c00fa2213b6a8adfa2 (diff) |
Added JsonArray::contains()
Change-Id: I76463e3df25476d5bbb8cb84505b25cb87e016af
Reviewed-by: Knoll Lars <lars.knoll@nokia.com>
-rw-r--r-- | src/qbinaryjsonarray.cpp | 9 | ||||
-rw-r--r-- | src/qbinaryjsonarray.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/qbinaryjsonarray.cpp b/src/qbinaryjsonarray.cpp index 1f36bfc..3e711f8 100644 --- a/src/qbinaryjsonarray.cpp +++ b/src/qbinaryjsonarray.cpp @@ -154,6 +154,15 @@ void JsonArray::insert(int i, const JsonValue &value) } } +bool JsonArray::contains(const JsonValue &element) const +{ + for (int i = 0; i < size(); i++) { + if (at(i) == element) + return true; + } + return false; +} + //JsonValue &JsonArray::operator[](int i) //{ // Q_ASSERT(i >= 0 && i < a->length); diff --git a/src/qbinaryjsonarray.h b/src/qbinaryjsonarray.h index 6b36d22..23a8407 100644 --- a/src/qbinaryjsonarray.h +++ b/src/qbinaryjsonarray.h @@ -32,6 +32,7 @@ public: void insert(int i, const JsonValue &value); + bool contains(const JsonValue &element) const; // JsonValue &operator[](int i); JsonValue operator[](int i) const; |