class CordOutputStream
Defined at line 416 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
A ZeroCopyOutputStream that writes to a Cord. This stream implements
WriteCord() in a way that can share memory between the source and
destination cords rather than copying.
Public Methods
void CordOutputStream (size_t size_hint)
Creates an OutputStream streaming serialized data into a Cord. `size_hint`,
if given, is the expected total size of the resulting Cord. This is a hint
only, used for optimization. Callers can obtain the generated Cord value by
invoking `Consume()`.
void CordOutputStream (absl::Cord cord, size_t size_hint)
Creates an OutputStream with an initial Cord value. This constructor can be
used by applications wanting to directly append serialization data to a
given cord. In such cases, donating the existing value as in:
CordOutputStream stream(std::move(cord));
message.SerializeToZeroCopyStream(
&stream
);
cord = std::move(stream.Consume());
is more efficient then appending the serialized cord in application code:
CordOutputStream stream;
message.SerializeToZeroCopyStream(
&stream
);
cord.Append(stream.Consume());
The former allows `CordOutputStream` to utilize pre-existing privately
owned Cord buffers from the donated cord where the latter does not, which
may lead to more memory usage when serialuzing data into existing cords.
void CordOutputStream (absl::Cord cord, absl::CordBuffer buffer, size_t size_hint)
Creates an OutputStream with an initial Cord value and initial buffer.
This donates both the preexisting cord in `cord`, as well as any
pre-existing data and additional capacity in `buffer`.
This function is mainly intended to be used in internal serialization logic
using eager buffer initialization in EpsCopyOutputStream.
The donated buffer can be empty, partially empty or full: the outputstream
will DTRT in all cases and preserve any pre-existing data.
void CordOutputStream (absl::CordBuffer buffer, size_t size_hint)
Creates an OutputStream with an initial buffer.
This method is logically identical to, but more efficient than:
`CordOutputStream(absl::Cord(), std::move(buffer), size_hint)`
void CordOutputStream (const CordOutputStream & )
`CordOutputStream` is neither copiable nor assignable
Defined at line 459 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h
bool Next (void ** data, int * size)
implements `ZeroCopyOutputStream` ---------------------------------
void BackUp (int count)
int64_t ByteCount ()
bool WriteCord (const absl::Cord & cord)
absl::Cord Consume ()
Consumes the serialized data as a cord value. `Consume()` internally
flushes any pending state 'as if' BackUp(0) was called. While a final call
to BackUp() is generally required by the `ZeroCopyOutputStream` contract,
applications using `CordOutputStream` directly can call `Consume()` without
a preceding call to `BackUp()`.
While it will rarely be useful in practice (and especially in the presence
of size hints) an instance is safe to be used after a call to `Consume()`.
The only logical change in state is that all serialized data is extracted,
and any new serialization calls will serialize into new cord data.
CordOutputStream & operator= (const CordOutputStream & )
Defined at line 460 of file ../../third_party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h