class ZeroCopyOutputStream

Defined at line 176 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

Abstract interface similar to an output stream but designed to minimize

copying.

Public Methods

bool Next (void ** data, int * size)

Obtains a buffer into which data can be written. Any data written

into this buffer will eventually (maybe instantly, maybe later on)

be written to the output.

Preconditions:

* "size" and "data" are not NULL.

Postconditions:

* If the returned value is false, an error occurred. All errors are

permanent.

* Otherwise, "size" points to the actual number of bytes in the buffer

and "data" points to the buffer.

* Ownership of this buffer remains with the stream, and the buffer

remains valid only until some other method of the stream is called

or the stream is destroyed.

* Any data which the caller stores in this buffer will eventually be

written to the output (unless BackUp() is called).

* It is legal for the returned buffer to have zero size, as long

as repeatedly calling Next() eventually yields a buffer with non-zero

size.

void BackUp (int count)

Backs up a number of bytes, so that the end of the last buffer returned

by Next() is not actually written. This is needed when you finish

writing all the data you want to write, but the last buffer was bigger

than you needed. You don't want to write a bunch of garbage after the

end of your data, so you use BackUp() to back up.

This method can be called with `count = 0` to finalize (flush) any

previously returned buffer. For example, a file output stream can

flush buffers returned from a previous call to Next() upon such

BackUp(0) invocations. ZeroCopyOutputStream callers should always

invoke BackUp() after a final Next() call, even if there is no

excess buffer data to be backed up to indicate a flush point.

Preconditions:

* The last method called must have been Next().

* count must be less than or equal to the size of the last buffer

returned by Next().

* The caller must not have written anything to the last "count" bytes

of that buffer.

Postconditions:

* The last "count" bytes of the last buffer returned by Next() will be

ignored.

int64_t ByteCount ()

Returns the total number of bytes written since this object was created.

bool WriteAliasedRaw (const void * data, int size)

Write a given chunk of data to the output. Some output streams may

implement this in a way that avoids copying. Check AllowsAliasing() before

calling WriteAliasedRaw(). It will ABSL_CHECK fail if WriteAliasedRaw() is

called on a stream that does not allow aliasing.

NOTE: It is caller's responsibility to ensure that the chunk of memory

remains live until all of the data has been consumed from the stream.

void ZeroCopyOutputStream ()

Defined at line 178 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

void ZeroCopyOutputStream (const ZeroCopyOutputStream & )

Defined at line 179 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

ZeroCopyOutputStream & operator= (const ZeroCopyOutputStream & )

Defined at line 180 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

void ~ZeroCopyOutputStream ()

Defined at line 181 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

bool AllowsAliasing ()

Defined at line 241 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream.h

bool WriteCord (const absl::Cord & cord)

Writes the given Cord to the output.

The default implementation iterates over all Cord chunks copying all cord

data into the buffer(s) returned by the stream's `Next()` method.

Some streams may implement this in a way that avoids copying the cord

data by copying and managing a copy of the provided cord instead.