Expose how many bytes are written in ProtoOutputStream

Bug: 69428467
Test: N/A
Change-Id: If1405885949635cebd1c6d89e220c210ef9fa210
This commit is contained in:
Yi Jin
2017-11-16 15:32:27 -08:00
parent e1c20603a4
commit 0abdfb0889
2 changed files with 12 additions and 0 deletions

View File

@@ -109,6 +109,12 @@ public:
long long start(uint64_t fieldId);
void end(long long token);
/**
* Returns how many bytes are buffered in ProtoOutputStream.
* Notice, this is not the actual(compact) size of the output data.
*/
size_t bytesWritten();
/**
* Flushes the protobuf data out to given fd. When the following functions are called,
* it is not able to write to ProtoOutputStream any more since the data is compact.

View File

@@ -295,6 +295,12 @@ ProtoOutputStream::end(long long token)
}
}
size_t
ProtoOutputStream::bytesWritten()
{
return mBuffer.size();
}
bool
ProtoOutputStream::compact() {
if (mCompact) return true;