ICU 78.1 78.1 |
Implementation ofByteSink that writes to a flat byte array, with bounds-checking: This sink will not write more than capacity bytes to outbuf.More...
#include <bytestream.h>

Public Member Functions | |
| CheckedArrayByteSink (char *outbuf, int32_t capacity) | |
| Constructs aByteSink that will write to outbuf[0..capacity-1].More... | |
| virtual | ~CheckedArrayByteSink () |
| Destructor.More... | |
| virtualCheckedArrayByteSink & | Reset () |
| Returns the sink to its original state, without modifying the buffer.More... | |
| virtual void | Append (const char *bytes, int32_t n) override |
| Append "bytes[0,n-1]" to this.More... | |
| virtual char * | GetAppendBuffer (int32_t min_capacity, int32_t desired_capacity_hint, char *scratch, int32_t scratch_capacity, int32_t *result_capacity) override |
| Returns a writable buffer for appending and writes the buffer's capacity to *result_capacity.More... | |
| int32_t | NumberOfBytesWritten () const |
| Returns the number of bytes actually written to the sink.More... | |
| UBool | Overflowed () const |
| Returns true if any bytes were discarded, i.e., if there was an attempt to write more than 'capacity' bytes.More... | |
| int32_t | NumberOfBytesAppended () const |
| Returns the number of bytes appended to the sink.More... | |
Public Member Functions inherited fromicu::ByteSink | |
| ByteSink () | |
| Default constructor.More... | |
| virtual | ~ByteSink () |
| Virtual destructor.More... | |
| void | AppendU8 (const char *bytes, int32_t n) |
| Appends n bytes to this.More... | |
| void | AppendU8 (const char8_t *bytes, int32_t n) |
| Appends n bytes to this.More... | |
| virtual void | Flush () |
| Flush internal buffers.More... | |
Implementation ofByteSink 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 areAppend()ed, then excess bytes are ignored, andOverflowed() will return true. Overflow does not cause a runtime error.
Definition at line182 of filebytestream.h.
| icu::CheckedArrayByteSink::CheckedArrayByteSink | ( | char * | outbuf, |
| int32_t | capacity | ||
| ) |
| virtual |
Destructor.
| overridevirtual |
Append "bytes[0,n-1]" to this.
| bytes | the pointer to the bytes |
| n | the number of bytes; must be non-negative |
Implementsicu::ByteSink.
| overridevirtual |
Returns a writable buffer for appending and writes the buffer's capacity to *result_capacity.
For details see the base class documentation.
| 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 |
Reimplemented fromicu::ByteSink.
| inline |
Returns the number of bytes appended to the sink.
IfOverflowed() thenNumberOfBytesAppended()>NumberOfBytesWritten() else they return the same number.
Definition at line250 of filebytestream.h.
| inline |
Returns the number of bytes actually written to the sink.
Definition at line235 of filebytestream.h.
| inline |
Returns true if any bytes were discarded, i.e., if there was an attempt to write more than 'capacity' bytes.
Definition at line242 of filebytestream.h.
| virtual |
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 toNumberOfBytesWritten()=NumberOfBytesAppended()=0 andOverflowed()=false.