cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBVarInt/CBVarInt.h File Reference

Simple structure for variable size integers information. This is an annoying structure used in the bitcoin protocol. One has to wonder why it was ever used. More...

#include "CBByteArray.h"

Go to the source code of this file.

Data Structures

struct  CBVarInt
 Contains decoded variable size integer information. More...

Functions

CBVarInt CBVarIntDecode (CBByteArray *bytes, uint32_t offset)
 Decodes variable size integer from bytes into a CBVarInt structure.
void CBVarIntEncode (CBByteArray *bytes, uint32_t offset, CBVarInt varInt)
 Encodes variable size integer into bytes.
CBVarInt CBVarIntFromUInt64 (uint64_t integer)
 Returns a variable integer from a 64 bit integer.
uint8_t CBVarIntSizeOf (uint64_t value)
 Returns the variable integer byte size of a 64 bit integer.

Detailed Description

Simple structure for variable size integers information. This is an annoying structure used in the bitcoin protocol. One has to wonder why it was ever used.


Function Documentation

CBVarInt CBVarIntDecode ( CBByteArray bytes,
uint32_t  offset 
)

Decodes variable size integer from bytes into a CBVarInt structure.

Parameters:
bytesThe byte array to decode a variable size integer from.
offsetOffset to start decoding from.
Returns:
The CBVarInt information
void CBVarIntEncode ( CBByteArray bytes,
uint32_t  offset,
CBVarInt  varInt 
)

Encodes variable size integer into bytes.

Parameters:
bytesThe byte array to encode a variable size integer into.
offsetOffset to start decoding from.
varIntVariable integer structure.
CBVarInt CBVarIntFromUInt64 ( uint64_t  integer)

Returns a variable integer from a 64 bit integer.

Parameters:
integerThe 64 bit integer
Returns:
A CBVarInt.
uint8_t CBVarIntSizeOf ( uint64_t  value)

Returns the variable integer byte size of a 64 bit integer.

Parameters:
valueThe 64 bit integer
Returns:
The size of a variable integer for this integer.