| Index: storage/common/data_element.cc
|
| diff --git a/storage/common/data_element.cc b/storage/common/data_element.cc
|
| index f26058b7fb42875343474391d615fc11c2d546bf..c2e40c9a426643e92b12194cf74fd4bd57541a89 100644
|
| --- a/storage/common/data_element.cc
|
| +++ b/storage/common/data_element.cc
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <iomanip>
|
| +
|
| #include "storage/common/data_element.h"
|
|
|
| namespace storage {
|
| @@ -52,4 +54,46 @@ void DataElement::SetToDiskCacheEntryRange(uint64 offset, uint64 length) {
|
| length_ = length;
|
| }
|
|
|
| +std::ostream& operator<<(std::ostream& os, const DataElement& x) {
|
| + const uint64 kMaxDataPrintLength = 40;
|
| + os << "<DataElement>{type: ";
|
| + switch (x.type()) {
|
| + case DataElement::TYPE_BYTES: {
|
| + auto flags = os.flags();
|
| + os << "TYPE_BYTES, data: [" << std::hex;
|
| + uint64 length = std::min(x.length(), kMaxDataPrintLength);
|
| + for (size_t i = 0; i < length; i++) {
|
| + os << std::setfill('0') << std::setw(2) << +(x.bytes()[i]) << ' ';
|
| + }
|
| + os.flags(flags);
|
| + if (length < x.length()) {
|
| + os << "<...truncated due to length...>";
|
| + }
|
| + os << "]";
|
| + break;
|
| + }
|
| + case DataElement::TYPE_FILE:
|
| + os << "TYPE_FILE, path: " << x.path().AsUTF8Unsafe()
|
| + << ", expected_modification_time: " << x.expected_modification_time();
|
| + break;
|
| + case DataElement::TYPE_BLOB:
|
| + os << "TYPE_BLOB, uuid: " << x.blob_uuid();
|
| + break;
|
| + case DataElement::TYPE_FILE_FILESYSTEM:
|
| + os << "TYPE_FILE_FILESYSTEM, filesystem_url: " << x.filesystem_url();
|
| + break;
|
| + case DataElement::TYPE_DISK_CACHE_ENTRY:
|
| + os << "TYPE_DISK_CACHE_ENTRY";
|
| + break;
|
| + case DataElement::TYPE_BYTES_DESCRIPTION:
|
| + os << "TYPE_BYTES_DESCRIPTION";
|
| + break;
|
| + case DataElement::TYPE_UNKNOWN:
|
| + os << "TYPE_UNKNOWN";
|
| + break;
|
| + }
|
| + os << ", length: " << x.length() << ", offset: " << x.offset() << "}";
|
| + return os;
|
| +}
|
| +
|
| } // namespace storage
|
|
|