X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fbundle_cpp.cc;h=6d1163cba44aaa31f1bdbbe1be9eab998b49c1a2;hb=ffa6c8af2798093c971137029b36632173d420ab;hp=9f878e6812c180f245aab1f54376750e6561394e;hpb=da902067e70bccb97afcf91f0d7085030d83d42c;p=platform%2Fcore%2Fbase%2Fbundle.git diff --git a/src/bundle_cpp.cc b/src/bundle_cpp.cc index 9f878e6..6d1163c 100644 --- a/src/bundle_cpp.cc +++ b/src/bundle_cpp.cc @@ -70,7 +70,7 @@ Bundle::Bundle(bundle* b, bool copy, bool own) } Bundle::~Bundle() { - if (impl_->handle_ && (impl_->own_ || impl_->copy_)) + if (impl_ && impl_->handle_ && (impl_->own_ || impl_->copy_)) bundle_free(impl_->handle_); } @@ -158,9 +158,8 @@ Bundle& Bundle::operator = (const Bundle& b) { } Bundle::Bundle(Bundle&& b) noexcept { - impl_ = std::unique_ptr(new Impl(this)); - impl_->handle_ = b.impl_->handle_; - b.impl_->handle_ = nullptr; + impl_ = std::move(b.impl_); + impl_->parent_ = this; } Bundle& Bundle::operator = (Bundle&& b) noexcept { @@ -171,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; @@ -246,8 +249,13 @@ std::vector Bundle::GetStringArray(const std::string& key) const { std::vector Bundle::GetByte(const std::string& key) const { size_t size; unsigned char* bytes = nullptr; - bundle_get_byte(impl_->handle_, key.c_str(), + int ret = bundle_get_byte(impl_->handle_, key.c_str(), reinterpret_cast(&bytes), &size); + if (ret != BUNDLE_ERROR_NONE) { + LOGE("bundle_get_byte() is failed"); + return {}; + } + return std::vector(bytes, bytes + size); }