BloombergLP::bslx::TestInStream

This class provides input methods to unexternalize values, and C-style arrays of values, of fundamental types from their byte representations. Each input method also verifies the input value type. By default, if invalid data is detected, error messages are displayed on stdout; this error reporting may be disabled via the setQuiet method. Note that attempting to read beyond the end of a stream will automatically invalidate the stream. See the bslx package-level documentation for the definition of the BDEX InStream protocol.

Synopsis

Declared in <bslx_testinstream.h>

class TestInStream;

Member Functions

NameDescription
TestInStream [constructor]Constructors
~TestInStream [destructor]Destroy this test input stream.
cursor Return the index of the next byte to be extracted from this stream.
data Return the address of the contiguous, non-modifiable external memory buffer of this stream. The behavior of accessing elements outside the range [ data() .. data() + (length() - 1) ] is undefined.
getArrayFloat32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that IEEE single-precision (4-byte) floating-point array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity. Note that for non-conforming platforms, this operation may be lossy.
getArrayFloat64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that IEEE double-precision (8-byte) floating-point array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity. Note that for non-conforming platforms, this operation may be lossy.
getArrayInt16 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 16-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt24 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 24-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 32-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt40 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 40-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt48 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 48-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt56 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 56-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 64-bit signed integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayInt8 getArrayInt8 overloads
getArrayUint16 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 16-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint24 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 24-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 32-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint40 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 40-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint48 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 48-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint56 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 56-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 64-bit unsigned integer array value into the specified variables of the specified numVariables if its type and length are appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variables is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variables is undefined. The behavior is undefined unless 0 <= numVariables and variables has sufficient capacity.
getArrayUint8 getArrayUint8 overloads
getFloat32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that IEEE single-precision (4-byte) floating-point value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined. Note that for non-conforming platforms, this operation may be lossy.
getFloat64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that IEEE double-precision (8-byte) floating-point value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined. Note that for non-conforming platforms, this operation may be lossy.
getInt16 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 16-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt24 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 24-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 32-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt40 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 40-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt48 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 48-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt56 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 56-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 64-bit signed integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getInt8 getInt8 overloads
getLength If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 8-bit unsigned integer or 32-bit signed integer value representing a length (see the bslx package-level documentation) into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. Consume an 8-bit unsigned integer if the most significant bit of this byte is 0, otherwise consume a 32-bit signed integer and set the most significant bit to zero in the resultant variable. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getString If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume a string from this input stream, assign that value to the specified variable, update the cursor location, and return a reference to this stream. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined. The string must be prefaced by a non-negative integer indicating the number of characters composing the string. The behavior is undefined unless the length indicator is non-negative.
getUint16 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 16-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint24 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 24-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint32 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 32-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint40 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 40-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint48 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 48-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint56 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 56-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint64 If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 64-bit unsigned integer value into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
getUint8 getUint8 overloads
getVersion If required, throw a TestInStreamException (see throwExceptionIfInputLimitExhausted); otherwise, consume the 8-bit unsigned integer type code, verify the type of the next value in this stream, consume that 8-bit unsigned integer value representing a version (see the bslx package-level documentation) into the specified variable if its type is appropriate, update the cursor location, and return a reference to this stream. If the type is incorrect, then this stream is marked invalid and the value of variable is unchanged. If this stream is initially invalid, this operation has no effect. If this function otherwise fails to extract a valid value, this stream is marked invalid and the value of variable is undefined.
inputLimit Return the current number of input requests left before an exception is thrown. A negative value indicates that no exception is scheduled.
invalidate Put this input stream in an invalid state. This function has no effect if this stream is already invalid. Note that this function should be called whenever a value extracted from this stream is determined to be invalid, inconsistent, or otherwise incorrect.
isEmpty Return true if this stream is empty, and false otherwise. Note that this function enables higher-level types to verify that, after successfully reading all expected data, no data remains.
isQuiet Return true if this stream's quiet mode is ON, and false otherwise.
isValid Return true if this stream is valid, and false otherwise. An invalid stream is a stream in which insufficient or invalid data was detected during an extraction operation. Note that an empty stream will be valid unless an extraction attempt or explicit invalidation causes it to be otherwise.
length Return the total number of bytes stored in the external memory buffer.
reset reset overloads
seek Set the index of the next byte to be extracted from this stream to the specified offset from the beginning of the stream, and validate this stream if it is currently invalid. The behavior is undefined unless offset <= length().
setInputLimit Set the number of input operations allowed on this stream to the specified limit before an exception is thrown. If limit is less than 0, no exception is to be thrown. By default, no exception is scheduled.
setQuiet Set the quiet mode for this test stream to the specified (boolean) flagValue. If flagValue is true, then quiet mode is turned ON and no error messages will be written to standard output. If flagValue is false, then quiet mode is turned OFF. Note that quiet mode is turned OFF by default.
operator void const* Return a non-zero value if this stream is valid, and 0 otherwise. An invalid stream is a stream for which an input operation was detected to have failed.

Friends

NameDescription
BloombergLP::bslx::operator<<Write the specified object to the specified output stream in some reasonable (multi-line) format, and return a reference to stream.

Non-Member Functions

NameDescription
operator>>Read the specified value from the specified input stream following the requirements of the BDEX protocol (see the bslx package-level documentation), and return a reference to stream. The behavior is undefined unless TYPE is BDEX-compliant.