| Index: third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
|
| diff --git a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
|
| index a598ef2e3d196cd37c718fc87f5b543beb7ab7b2..9d81ccfbfd08e8c45cb6504c5ae39fefb166936c 100644
|
| --- a/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
|
| +++ b/third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
|
| @@ -51,6 +51,7 @@
|
| #include <string>
|
| #include <iosfwd>
|
| #include <google/protobuf/io/zero_copy_stream.h>
|
| +#include <google/protobuf/stubs/callback.h>
|
| #include <google/protobuf/stubs/common.h>
|
| #include <google/protobuf/stubs/scoped_ptr.h>
|
| #include <google/protobuf/stubs/stl_util.h>
|
| @@ -148,6 +149,9 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
|
| void BackUp(int count);
|
| int64 ByteCount() const;
|
|
|
| + protected:
|
| + void SetString(string* target);
|
| +
|
| private:
|
| static const int kMinimumSize = 16;
|
|
|
| @@ -156,6 +160,27 @@ class LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {
|
| GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);
|
| };
|
|
|
| +// LazyStringOutputStream is a StringOutputStream with lazy acquisition of
|
| +// the output string from a callback. The string is owned externally, and not
|
| +// deleted in the stream destructor.
|
| +class LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream {
|
| + public:
|
| + // Callback should be permanent (non-self-deleting). Ownership is transferred
|
| + // to the LazyStringOutputStream.
|
| + explicit LazyStringOutputStream(ResultCallback<string*>* callback);
|
| + ~LazyStringOutputStream();
|
| +
|
| + // implements ZeroCopyOutputStream, overriding StringOutputStream -----------
|
| + bool Next(void** data, int* size);
|
| + int64 ByteCount() const;
|
| +
|
| + private:
|
| + const google::protobuf::scoped_ptr<ResultCallback<string*> > callback_;
|
| + bool string_is_set_;
|
| +
|
| + GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyStringOutputStream);
|
| +};
|
| +
|
| // Note: There is no StringInputStream. Instead, just create an
|
| // ArrayInputStream as follows:
|
| // ArrayInputStream input(str.data(), str.size());
|
|
|