This class inherits from bsl::streambuf, and holds and wraps another streambuf. It forwards input through the held streambuf, and checks for invalid UTF‐8. The wrapping object does not support ouput, only input. If the held streambuf supports seeking, seeks are supported, though not forward seeks, and pubseekoff(0, bsl::ios_base::cur) is supported whether the wrapped streambuf supports seeking or not.

Synopsis

Declared in <bdlde_utf8checkinginstreambufwrapper.h>

class Utf8CheckingInStreamBufWrapper
    : public std::streambuf

Base Classes

Name

Description

std::streambuf

Enums

Name

Description

Unnamed enum

Error status values for seek failures.

Member Functions

Name

Description

Utf8CheckingInStreamBufWrapper [constructor]

Create a Utf8StreamBufInputWrapper object having no associated streambuf. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0 or not specified, the currently installed default allocator is used.

Utf8CheckingInStreamBufWrapper [constructor]

Create an empty UTF‐8 checking streambuf wrapper using the specified basicAllocator to supply memory.

Utf8CheckingInStreamBufWrapper [constructor]

Create a Utf8StreamBufInputWrapper associated with the specified streamBuf. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

~Utf8CheckingInStreamBufWrapper [destructor] [virtual]

Destroy this object.

errorStatus

Return the current error mode of this object. This will be either 0 (no errors or end of data), k_SEEK_FAIL, which is positive, or a value from Utf8Util::ErrorStatus, which are all negative.

isValid

Return true if this wrapper currently holds a streambuf and is not in a failed seek state.

reset

Associate this object with the specified streamBuf, releasing any previously held streambuf.

operator BloombergLP::bslmf::NestedTraitDeclaration<Utf8CheckingInStreamBufWrapper, UsesBslmaAllocator>

Utf8CheckingInStreamBufWrapper uses a bslma allocator.

Static Member Functions

Name

Description

toAscii

Return a description of the specified errorStatus. Note that errorStatus is either: * k_SEEK_FAIL * A value from Utf8Util::ErrorStatus, which are all negative, in the case of invalid UTF‐8. * 0 if no errors have occurred, in which case NO_ERROR will be returned. Note that this includes the case where end of file has been reached without any error occurring. * If errorStatus is an invalid value, "(* unrecognized value *)" will be returned.

Protected Member Functions

Name

Description

imbue [virtual]

If sb is the name of the streambuf held by this object, set sb to the specified locale as though sb.pubimbue(locale) had been called. If this object does not hold a streambuf, this method has no effect. Note that this function is forwarded to by the public method pubimbue in the base class.

overflow [virtual]

Unconditionally return traits_type::eof(). The optionally specified argument is ignored.

pbackfail [virtual]

Back up input one byte. Return the byte at the new position, or eof with the state of this object unchanged on failure. If the optionally specified c is not eof, substitute c for the previous byte and return that value. If c is eof, do not substitute it for the previous byte and return the byte was there, or if the previous byte is unknown, fail. If values of c that are not eof are specified, this function will succeed for at least 8 successive calls, possibly many more times. The behavior is undefined unless c is either eof or a value representable as a char_type. Note that this is forwarded to with a char_type passed to c by the public method sputbackc in the base class, and called with eof passed to c by the public method sungetc in the base class.

seekoff [virtual]

Move the position associated with this object according to the specified offset and whence:

seekpos [virtual]

Set the position of this object to the specified absolute offset. If a seek on the held streambuf occurs, the specified mode is passed to it. This function delegates to seekoff(offset, bsl::ios_base::beg, mode), see that function for further detail. The behavior is undefined unless bsl::ios_base::in is set in mode. Note that this function is forwarded to by the public method pubseekpos in the base class.

showmanyc [virtual]

Return the number of bytes that are guaranteed that can be read before underflow returns eof. If the object is not in a valid state, ‐1 will be returned. Note that often, the actual number of bytes that can be read will be much greater than the value returned by this function.

underflow [virtual]

Replenish the input buffer with data obtained from the held streambuf, and return the next byte of input (or eof if no input is available). This function assumes that either the input buffer is empty or that the end of it has been reached. If this object is not in a valid state, eof will be returned.

xsgetn [virtual]

Read up to the specified numBytes characters from this object to the specified buffer and return the number of characters successfully read. A return value of 0 means that either a UTF‐8 error or end of file has been encountered (errorStatus must be called to distinguish between the two), but a non‐zero return value less than numBytes will usually be returned when neither end of file nor a UTF‐8 error has been encountered. The behavior is undefined unless 4 <= numBytes. Note that this function is forwarded to by the public method sgetn in the base class.

xsputn [virtual]

Output function, not supported in this input‐only implementation; stubbed out, arguments ignored, returns 0. Note that this function is forwarded to by sputn in the base class.

Created with MrDocs