| Index: storage/common/data_element.h
|
| diff --git a/storage/common/data_element.h b/storage/common/data_element.h
|
| index bdc881296acab626574d2981697c8a7f10cbeb2c..0efe1550a91e9a509d1cc0548854167a58c3a689 100644
|
| --- a/storage/common/data_element.h
|
| +++ b/storage/common/data_element.h
|
| @@ -50,8 +50,28 @@ class STORAGE_COMMON_EXPORT DataElement {
|
| length_ = buf_.size();
|
| }
|
|
|
| + // Sets TYPE_BYTES data, and clears the internal bytes buffer.
|
| + // For use with AppendBytes.
|
| + void SetToEmptyBytes() {
|
| + type_ = TYPE_BYTES;
|
| + buf_.clear();
|
| + length_ = 0;
|
| + bytes_ = nullptr;
|
| + }
|
| +
|
| + // Copies and appends the given data into the element. SetToEmptyBytes or
|
| + // SetToBytes must be called before this method.
|
| + void AppendBytes(const char* bytes, int bytes_len) {
|
| + DCHECK_EQ(type_, TYPE_BYTES);
|
| + DCHECK_NE(length_, kuint64max);
|
| + DCHECK(!bytes_);
|
| + buf_.insert(buf_.end(), bytes, bytes + bytes_len);
|
| + length_ = buf_.size();
|
| + }
|
| +
|
| // Sets TYPE_BYTES data. This does NOT copy the given data and the caller
|
| // should make sure the data is alive when this element is accessed.
|
| + // You cannot use AppendBytes with this method.
|
| void SetToSharedBytes(const char* bytes, int bytes_len) {
|
| type_ = TYPE_BYTES;
|
| bytes_ = bytes;
|
|
|