#include <bundle.h>
#include <cstdio>
+#include <initializer_list>
#include <memory>
#include <string>
#include <utility>
/**
* @brief Constructor.
+ * @since_tizen 6.5
+ * @param[in] key_values The list of key-value pair
+ */
+ Bundle(std::initializer_list<
+ std::pair<std::string, std::string>> key_values);
+
+ /**
+ * @brief Constructor.
* @since_tizen 5.5
* @param[in] raw The object for BundleRaw
* @param[in] base64 @c true, @a raw is the encoded raw data using base64-encoding
throw std::bad_alloc();
}
+Bundle::Bundle(std::initializer_list<
+ std::pair<std::string, std::string>> key_values)
+ : impl_(new Impl(this)) {
+ impl_->handle_ = bundle_create();
+ if (impl_->handle_ == nullptr)
+ throw std::bad_alloc();
+ for (auto& i : key_values)
+ Add(i.first, i.second);
+}
+
Bundle::Bundle(BundleRaw raw, bool base64)
: impl_(new Impl(this)) {
if (base64)
Bundle bundle;
}
+TEST(Bundle, CtorDtor2) {
+ Bundle bundle = { {"key1", "val1"}, {"key2", "val2"}, {"key3", "val3"} };
+ EXPECT_EQ(bundle.GetString("key1"), "val1");
+ EXPECT_EQ(bundle.GetString("key2"), "val2");
+ EXPECT_EQ(bundle.GetString("key3"), "val3");
+}
+
TEST(Bundle, CopyCtor) {
Bundle bundle;
bundle.Add("TestKey", "TestVal");