You are here: Start » Function Reference » All Functions » Binary Data » WriteLongToBuffer
This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.
Header: | STD.h |
---|---|
Namespace: | fil |
Module: | FoundationLite |
Converts integer value into specified binary representation and writes it to a byte buffer.
Syntax
void fil::WriteLongToBuffer ( const fil::ByteBuffer& inBuffer, ftl::Optional<int> inOffset, ftl::int64 inValue, fil::IntegerBinaryFormat::Type inFormat, fil::ByteBuffer& outBuffer )
Parameters
Name | Type | Range | Default | Description | |
---|---|---|---|---|---|
![]() |
inBuffer | const ByteBuffer& | Initial buffer to be expanded | ||
![]() |
inOffset | Optional<int> | 0 - ![]() |
NIL | Write destination position |
![]() |
inValue | int64 | Value to be written | ||
![]() |
inFormat | IntegerBinaryFormat::Type | Signed_64Bit_LittleEndian | Binary serialization format of integer data | |
![]() |
outBuffer | ByteBuffer& | Resulting data |
In-place Processing
This function supports in-place data processing - you can pass the same reference to inBuffer and outBuffer
Read more about In-place Computation.
Description
This filter is intended for generating a raw binary data in the ByteBuffer by writing a properly serialized integer value provided as Long data type.
Resulting ByteBuffer data on the outBuffer output is created by expanding data from buffer on the inBuffer input. Data is written starting at the position specified by the inOffset input (in bytes). When written data spans beyond the end of the input buffer the resulting buffer length is expanded (event when inOffset points beyond the end of the input buffer). When the inOffset input is set to Auto data is written at the end of the input buffer.
Integer value is converted into a binary representation according to the inFormat input value:
- Signed_8Bit - signed two's complement 8-bit integer, 1 byte long.
- Signed_16Bit_LittleEndian - signed two's complement 16-bit integer, 2 bytes long with little-endian byte order.
- Signed_32Bit_LittleEndian - signed two's complement 32-bit integer, 4 bytes long with little-endian byte order.
- Signed_64Bit_LittleEndian - signed two's complement 64-bit integer, 8 bytes long with little-endian byte order.
- Unsigned_8Bit - unsigned 8-bit integer, 1 byte long.
- Unsigned_16Bit_LittleEndian - unsigned 16-bit integer, 2 bytes long with little-endian byte order.
- Unsigned_64Bit_LittleEndian - unsigned 64-bit integer, 8 bytes long with little-endian byte order.
- Signed_16Bit_BigEndian - signed two's complement 16-bit integer, 2 bytes long with big-endian byte order.
- Signed_32Bit_BigEndian - signed two's complement 32-bit integer, 4 bytes long with big-endian byte order.
- Signed_64Bit_BigEndian - signed two's complement 64-bit integer, 8 bytes long with big-endian byte order.
- Unsigned_16Bit_BigEndian - unsigned 16-bit integer, 2 bytes long with big-endian byte order.
- Unsigned_32Bit_BigEndian - unsigned 32-bit integer, 4 bytes long with big-endian byte order.
- Unsigned_64Bit_BigEndian - unsigned 64-bit integer, 8 bytes long with big-endian byte order.
Supported numeric range of stored value also depends on selected format:
- Signed_8Bit: -128...127
- Signed_16Bit_: -32768...32767
- Signed_32Bit_: -2147483648...2147483647
- Signed_64Bit_: -9223372036854775808...9223372036854775807
- Unsigned_8Bit: 0...255
- Unsigned_16Bit_: 0...65535
- Unsigned_32Bit_: 0...4294967295
- Unsigned_64Bit_: 0...18446744073709551615 *
*) actual achievable range in the application is also limited by the Long type
When a value from the inValue input (which is a signed 64-bit integer) cannot be stored in the selected format (it is out of its range) a DomainError is raised.
Errors
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Input value is out of the valid range for specified integer binary format. Value provided on inValue input cannot be cast to the type specified by the inFormat input. |
DomainError | Not supported integer binary format. |
IoError | Resulting byte buffer size is too large. |
See Also
- ReadLongFromBuffer – Reads integer value in specified binary format from a byte buffer.
- WriteIntegerToBuffer – Converts integer value into specified binary representation and writes it to a byte buffer.