From: Sangyoon Jang Date: Mon, 15 Jun 2020 06:25:19 +0000 (+0900) Subject: Add IsEmpty() method X-Git-Tag: submit/tizen/20200615.072255~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffa6c8af2798093c971137029b36632173d420ab;p=platform%2Fcore%2Fbase%2Fbundle.git Add IsEmpty() method Change-Id: Id7a36a8f2f7ac5079c731ce8fb46ae5d7e2529b1 Signed-off-by: Sangyoon Jang --- diff --git a/include/bundle_cpp.h b/include/bundle_cpp.h index d95a241..bcab268 100644 --- a/include/bundle_cpp.h +++ b/include/bundle_cpp.h @@ -191,6 +191,13 @@ class EXPORT_API Bundle final { */ Bundle& operator = (Bundle&& b) noexcept; + /** + * @brief Check the bundle is empty or not. + * @since_tizen 6.0 + * @return true if the bundle is empty + */ + bool IsEmpty() const noexcept; + /** * @brief Gets keys in bundle object. * @since_tizen 5.5 diff --git a/src/bundle_cpp.cc b/src/bundle_cpp.cc index 2d3233a..6d1163c 100644 --- a/src/bundle_cpp.cc +++ b/src/bundle_cpp.cc @@ -170,6 +170,10 @@ Bundle& Bundle::operator = (Bundle&& b) noexcept { return *this; } +bool Bundle::IsEmpty() const noexcept { + return (bundle_get_count(impl_->handle_) == 0) ? true : false; +} + std::vector Bundle::GetKeys() { std::vector v; diff --git a/unit_tests/src/test_bundle.cc b/unit_tests/src/test_bundle.cc index 0ac8827..c94b080 100644 --- a/unit_tests/src/test_bundle.cc +++ b/unit_tests/src/test_bundle.cc @@ -154,3 +154,10 @@ TEST(Bundle, GetKeysMove) { EXPECT_EQ(copied.GetName(), name); } } + +TEST(Bundle, IsEmpty) { + Bundle bundle; + EXPECT_TRUE(bundle.IsEmpty()); + bundle.Add("TestKey1", "TestVal"); + EXPECT_FALSE(bundle.IsEmpty()); +}