class CheckedArrayByteSink

Defined at line 180 of file ../../third_party/icu/default/source/common/unicode/bytestream.h

Implementation of ByteSink that writes to a flat byte array,

with bounds-checking:

This sink will not write more than capacity bytes to outbuf.

If more than capacity bytes are Append()ed, then excess bytes are ignored,

and Overflowed() will return true.

Overflow does not cause a runtime error.

ICU 4.2

Public Methods

void CheckedArrayByteSink (char * outbuf, int32_t capacity)

Constructs a ByteSink that will write to outbuf[0..capacity-1].

Parameters

outbuf buffer to write to
capacity size of the buffer ICU 4.2
void ~CheckedArrayByteSink ()

Destructor.

ICU 4.2

CheckedArrayByteSink & Reset ()

Returns the sink to its original state, without modifying the buffer.

Useful for reusing both the buffer and the sink for multiple streams.

Resets the state to NumberOfBytesWritten()=NumberOfBytesAppended()=0

and Overflowed()=false.

Returns

*this

ICU 4.6

void Append (const char * bytes, int32_t n)

Append "bytes[0,n-1]" to this.

Parameters

bytes the pointer to the bytes
n the number of bytes; must be non-negative ICU 4.2
char * GetAppendBuffer (int32_t min_capacity, int32_t desired_capacity_hint, char * scratch, int32_t scratch_capacity, int32_t * result_capacity)

Returns a writable buffer for appending and writes the buffer's capacity to

*result_capacity. For details see the base class documentation.

Parameters

min_capacity required minimum capacity of the returned buffer; must be non-negative
desired_capacity_hint desired capacity of the returned buffer; must be non-negative
scratch default caller-owned buffer
scratch_capacity capacity of the scratch buffer
result_capacity pointer to an integer which will be set to the capacity of the returned buffer

Returns

a buffer with *result_capacity>=min_capacity

ICU 4.2

int32_t NumberOfBytesWritten ()

Returns the number of bytes actually written to the sink.

Returns

number of bytes written to the buffer

ICU 4.2

Defined at line 233 of file ../../third_party/icu/default/source/common/unicode/bytestream.h

UBool Overflowed ()

Returns true if any bytes were discarded, i.e., if there was an

attempt to write more than 'capacity' bytes.

Returns

true if more than 'capacity' bytes were Append()ed

ICU 4.2

Defined at line 240 of file ../../third_party/icu/default/source/common/unicode/bytestream.h

int32_t NumberOfBytesAppended ()

Returns the number of bytes appended to the sink.

If Overflowed() then NumberOfBytesAppended()>NumberOfBytesWritten()

else they return the same number.

Returns

number of bytes written to the buffer

ICU 4.6

Defined at line 248 of file ../../third_party/icu/default/source/common/unicode/bytestream.h