Index: storage/common/data_element.h |
diff --git a/storage/common/data_element.h b/storage/common/data_element.h |
index bdc881296acab626574d2981697c8a7f10cbeb2c..e61929820103350f2c1c02db4ee51656e129e055 100644 |
--- a/storage/common/data_element.h |
+++ b/storage/common/data_element.h |
@@ -50,8 +50,26 @@ 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; |
michaeln
2015/01/22 21:57:46
maybe also set bytes_ to nullptr
dmurph
2015/01/23 00:42:00
Done.
|
+ } |
+ |
+ // 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); |
michaeln
2015/01/22 21:57:46
i think you can DCHECK(!bytes_);
dmurph
2015/01/23 00:42:00
Done.
|
+ 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; |