throw std::bad_alloc();
}
-Bundle::Bundle(BundleRaw raw)
+Bundle::Bundle(BundleRaw raw, bool base64)
: impl_(new Impl(this)) {
- impl_->handle_ = bundle_decode(raw.first.get(), raw.second);
+ if (base64)
+ impl_->handle_ = bundle_decode(raw.first.get(), raw.second);
+ else
+ impl_->handle_ = bundle_decode_raw(raw.first.get(), raw.second);
if (impl_->handle_ == nullptr)
throw std::bad_alloc();
}
return std::vector<unsigned char>(bytes, bytes + size);
}
-Bundle::BundleRaw Bundle::ToRaw() {
+Bundle::BundleRaw Bundle::ToRaw(bool base64) {
bundle_raw* raw = nullptr;
int len = 0;
- int ret = bundle_encode(impl_->handle_, &raw, &len);
+ int ret;
+ if (base64)
+ ret = bundle_encode(impl_->handle_, &raw, &len);
+ else
+ ret = bundle_encode_raw(impl_->handle_, &raw, &len);
if (raw == nullptr) {
LOGE("Fail to encode data (%d)", ret);
throw std::bad_alloc();