Tide 0.1.0
Functions

tide::ebml_int Namespace Reference

Functions for managing integers coded for EBML. More...

Functions

std::streamsize size_u (uint64_t integer)
 Get the size of an unsigned integer after encoding.
std::streamsize size_s (int64_t integer)
 Get the size of a signed integer after encoding.
std::vector< char > encode_u (uint64_t integer)
 Encode an unsigned integer into a buffer.
std::vector< char > encode_s (int64_t integer)
 Encode a signed integer into a buffer.
std::streamsize write_u (uint64_t integer, std::ostream &output)
 Encode and write an unsigned integer into a byte stream.
std::streamsize write_s (int64_t integer, std::ostream &output)
 Encode and write a signed integer into a byte stream.
uint64_t decode_u (std::vector< char > const &buffer)
 Decode an unsigned integer from a buffer.
int64_t decode_s (std::vector< char > const &buffer)
 Decode a signed integer from a buffer.
uint64_t read_u (std::istream &input, std::streamsize n)
 Read and decode an unsigned integer from a byte stream.
int64_t read_s (std::istream &input, std::streamsize n)
 Read and decode a signed integer from a byte stream.

Detailed Description

Functions for managing integers coded for EBML.

This namespace contains the functions used to mange the way integers, both signed and unsigned, are stored in EBML files. Rather than writing a constant number of bytes regardless of the value being stored, EBML specifies that leading 0x00 bytes and, for negative signed integers, leading 0xFF bytes, be trimmed. For example, a value of 2 will be stored as 0x02, even if the variable that holds it is 32-bit (i.e. 0x00000002). Similarly, a value of -30000, or 0xFFFFF530 in 32 bits, will be stored as 0xF530.

Note that this is distinct from the coding used on EBML Element IDs and data sizes, which relies on leading zero bits to indicate the stored size.


Function Documentation

int64_t tide::ebml_int::decode_s ( std::vector< char > const &  buffer)

Decode a signed integer from a buffer.

Decodes the unsigned integer stored in the buffer according to the EBML specification for unsigned integers.

Parameters:
[in]bufferThe buffer holding the raw data. The size of the buffer defines the number of bytes to use for the integer; it must be 8 or less.
Returns:
The decoded unsigned integer.
uint64_t tide::ebml_int::decode_u ( std::vector< char > const &  buffer)

Decode an unsigned integer from a buffer.

Decodes the unsigned integer stored in the buffer according to the EBML specification for unsigned integers.

Parameters:
[in]bufferThe buffer holding the raw data. The size of the buffer defines the number of bytes to use for the integer; it must be 8 or less.
Returns:
The decoded unsigned integer.
std::vector<char> tide::ebml_int::encode_s ( int64_t  integer)

Encode a signed integer into a buffer.

Encodes an unsigned integer according to the EBML specification for signed integers. Leading zero or 0xFF bytes are trimmed.

Parameters:
[in]integerThe integer to encode.
Returns:
A vector containing the encoded data.
std::vector<char> tide::ebml_int::encode_u ( uint64_t  integer)

Encode an unsigned integer into a buffer.

Encodes an unsigned integer according to the EBML specification for unsigned integers. Leading zero bytes are trimmed.

Parameters:
[in]integerThe integer to encode.
Returns:
A vector containing the encoded data.
int64_t tide::ebml_int::read_s ( std::istream &  input,
std::streamsize  n 
)

Read and decode a signed integer from a byte stream.

This function performs the same task as tide::ebml_int::decode_s(), but instead of reading from a basic buffer, it reads from a std::istream object.

Parameters:
[in]inputThe std::istream object to read from.
[in]nThe number of bytes from the buffer to read.
Returns:
The decoded signed integer.
Exceptions:
ReadErrorif there is an error reading the input stream.
uint64_t tide::ebml_int::read_u ( std::istream &  input,
std::streamsize  n 
)

Read and decode an unsigned integer from a byte stream.

This function performs the same task as tide::ebml_int::decode_u(), but instead of reading from a basic buffer, it reads from a std::istream object.

Parameters:
[in]inputThe std::istream object to read from.
[in]nThe number of bytes from the buffer to read.
Returns:
The decoded unsigned integer.
Exceptions:
ReadErrorif there is an error reading the input stream.
std::streamsize tide::ebml_int::size_s ( int64_t  integer)

Get the size of a signed integer after encoding.

The size required by an encoded integer depends on the value of that integer, and will range from 1 to 8 bytes.

Parameters:
[in]integerThe integer to get the size of.
Returns:
The size, in bytes, that the integer will require when coded.
std::streamsize tide::ebml_int::size_u ( uint64_t  integer)

Get the size of an unsigned integer after encoding.

The size required by an encoded integer depends on the value of that integer, and will range from 1 to 8 bytes.

Parameters:
[in]integerThe integer to get the size of.
Returns:
The size, in bytes, that the integer will require when coded.
std::streamsize tide::ebml_int::write_s ( int64_t  integer,
std::ostream &  output 
)

Encode and write a signed integer into a byte stream.

This function performs the same task as tide::ebml_int::encode_s(), but instead of writing to a basic buffer, it writes to a std::ostream object.

Parameters:
[in]integerThe integer to encode.
[in]outputThe std::ostream object to write to.
Returns:
The number of bytes written.
Exceptions:
WriteErrorif there is an error writing the output stream.
std::streamsize tide::ebml_int::write_u ( uint64_t  integer,
std::ostream &  output 
)

Encode and write an unsigned integer into a byte stream.

This function performs the same task as tide::ebml_int::encode_u(), but instead of writing to a basic buffer, it writes to a std::ostream object.

Parameters:
[in]integerThe integer to encode.
[in]outputThe std::ostream object to write to.
Returns:
The number of bytes written.
Exceptions:
WriteErrorif there is an error writing the output stream.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines