OSDN Git Service

Expose how many bytes are written in ProtoOutputStream
authorYi Jin <jinyithu@google.com>
Thu, 16 Nov 2017 23:32:27 +0000 (15:32 -0800)
committerYi Jin <jinyithu@google.com>
Thu, 16 Nov 2017 23:32:27 +0000 (15:32 -0800)
Bug: 69428467
Test: N/A
Change-Id: If1405885949635cebd1c6d89e220c210ef9fa210

libs/protoutil/include/android/util/ProtoOutputStream.h
libs/protoutil/src/ProtoOutputStream.cpp

index ce41849..faea9b2 100644 (file)
@@ -110,6 +110,12 @@ public:
     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.
      */
index 9d8ee72..1904d40 100644 (file)
@@ -295,6 +295,12 @@ ProtoOutputStream::end(long long token)
     }
 }
 
+size_t
+ProtoOutputStream::bytesWritten()
+{
+    return mBuffer.size();
+}
+
 bool
 ProtoOutputStream::compact() {
     if (mCompact) return true;