From f2ef338cb8949647cf91b177f0f81089880b0cff Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 12 Apr 2017 17:03:33 +0200 Subject: [PATCH] Renamed `JsonArray::removeAt()` into `remove()` --- CHANGELOG.md | 1 + include/ArduinoJson/Data/List.hpp | 2 ++ include/ArduinoJson/JsonArray.hpp | 9 ++++++++- test/JsonArray/CMakeLists.txt | 2 +- test/JsonArray/{removeAt.cpp => remove.cpp} | 6 +++--- test/Misc/deprecated.cpp | 6 ++++++ 6 files changed, 21 insertions(+), 5 deletions(-) rename test/JsonArray/{removeAt.cpp => remove.cpp} (95%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fade029..f1c8a58c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ HEAD * Added `JsonArray::remove(iterator)` (issue #479) * Added `JsonObject::remove(iterator)` +* Renamed `JsonArray::removeAt(size_t)` into `remove(size_t)` v5.8.4 ------ diff --git a/include/ArduinoJson/Data/List.hpp b/include/ArduinoJson/Data/List.hpp index 2eb732c3..8a24666e 100644 --- a/include/ArduinoJson/Data/List.hpp +++ b/include/ArduinoJson/Data/List.hpp @@ -89,6 +89,8 @@ class List { protected: JsonBuffer *_buffer; + + private: node_type *_firstNode; }; } diff --git a/include/ArduinoJson/JsonArray.hpp b/include/ArduinoJson/JsonArray.hpp index 6881520c..ec3b6497 100644 --- a/include/ArduinoJson/JsonArray.hpp +++ b/include/ArduinoJson/JsonArray.hpp @@ -131,7 +131,7 @@ class JsonArray : public Internals::JsonPrintable, JsonObject &createNestedObject(); // Removes element at specified index. - void removeAt(size_t index) { + void remove(size_t index) { remove(begin() += index); } using Internals::List::remove; @@ -197,6 +197,13 @@ class JsonArray : public Internals::JsonPrintable, } } +#if ARDUINOJSON_ENABLE_DEPRECATED + DEPRECATED("use remove() instead") + FORCE_INLINE void removeAt(size_t index) { + return remove(index); + } +#endif + private: template bool set_impl(size_t index, TValueRef value) { diff --git a/test/JsonArray/CMakeLists.txt b/test/JsonArray/CMakeLists.txt index 211ff576..3fd0e759 100644 --- a/test/JsonArray/CMakeLists.txt +++ b/test/JsonArray/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(JsonArrayTests iterator.cpp prettyPrintTo.cpp printTo.cpp - removeAt.cpp + remove.cpp set.cpp subscript.cpp ) diff --git a/test/JsonArray/removeAt.cpp b/test/JsonArray/remove.cpp similarity index 95% rename from test/JsonArray/removeAt.cpp rename to test/JsonArray/remove.cpp index c85f75e0..4dfca73e 100644 --- a/test/JsonArray/removeAt.cpp +++ b/test/JsonArray/remove.cpp @@ -23,7 +23,7 @@ class JsonArray_Remove_Tests : public ::testing::Test { #define TEST_(name) TEST_F(JsonArray_Remove_Tests, name) TEST_(RemoveFirstByIndex) { - _array.removeAt(0); + _array.remove(0); EXPECT_EQ(2, _array.size()); EXPECT_STREQ("two", _array[0]); @@ -31,7 +31,7 @@ TEST_(RemoveFirstByIndex) { } TEST_(RemoveMiddleByIndex) { - _array.removeAt(1); + _array.remove(1); EXPECT_EQ(2, _array.size()); EXPECT_STREQ("one", _array[0]); @@ -39,7 +39,7 @@ TEST_(RemoveMiddleByIndex) { } TEST_(RemoveLastByIndex) { - _array.removeAt(2); + _array.remove(2); EXPECT_EQ(2, _array.size()); EXPECT_STREQ("one", _array[0]); diff --git a/test/Misc/deprecated.cpp b/test/Misc/deprecated.cpp index 4ba636f4..bf891da2 100644 --- a/test/Misc/deprecated.cpp +++ b/test/Misc/deprecated.cpp @@ -34,3 +34,9 @@ TEST(Deprecated, asString) { JsonVariant variant = "hello"; ASSERT_STREQ("hello", variant.asString()); } + +TEST(Deprecated, removeAt) { + DynamicJsonBuffer jsonBuffer; + JsonArray& arr = jsonBuffer.createArray(); + arr.removeAt(0); +}