XBinder  Version 2.9.x
Macros | Functions
rtxBitEncode.h File Reference

Bit encode functions. More...

#include "rtxsrc/rtxContext.h"

Go to the source code of this file.

Macros

#define rtxEncByteAlignPattern(pctxt, pattern)
 This macro will byte-align the context buffer by encoding according to the given pattern. More...
 

Functions

EXTERNRT int rtxEncBitsPattern (OSCTXT *pctxt, OSUINT8 pattern, OSSIZE nbits)
 This function encodes the given number of bits using a repeating bit pattern. More...
 
EXTERNRT int rtxEncBit (OSCTXT *pctxt, OSBOOL value)
 This function will set the bit at the current encode bit cursor position to 1 or 0 and advance the cursor pointer. More...
 
EXTERNRT int rtxEncBits (OSCTXT *pctxt, OSUINT32 value, OSSIZE nbits)
 This function encodes a number of the least significant bits (up to 32) of an unsigned integer value. More...
 
EXTERNRT int rtxEncBitsFromSize (OSCTXT *pctxt, OSSIZE value, OSSIZE nbits)
 This function encodes a number of the least significant bits from a size type. More...
 
EXTERNRT int rtxEncBitsFromByteArray (OSCTXT *pctxt, const OSOCTET *pvalue, OSSIZE nbits)
 This function will encode a series of bits from an octet array. More...
 
EXTERNRT int rtxCopyBits (OSCTXT *pctxt, const OSOCTET *pvalue, OSSIZE nbits, OSUINT32 bitOffset)
 This function will encode a series of bits from an octet array. More...
 
EXTERNRT int rtxMergeBits (OSCTXT *pctxt, OSUINT32 value, OSSIZE nbits)
 This function will merge a series of bits (up to 32) from an unsigned integer value into an existing encoded data buffer. More...
 

Detailed Description

Bit encode functions.

Definition in file rtxBitEncode.h.

Macro Definition Documentation

◆ rtxEncByteAlignPattern

#define rtxEncByteAlignPattern (   pctxt,
  pattern 
)
Value:
if ((pctxt)->buffer.bitOffset != 8) { \
rtxEncBits(pctxt, pattern, (pctxt)->buffer.bitOffset); }

This macro will byte-align the context buffer by encoding according to the given pattern.

If the buffer is not aligned, the lowest bits of the current byte, which have not be written already, will be set to the corresponding lowest bites of the pattern.

Definition at line 44 of file rtxBitEncode.h.

Function Documentation

◆ rtxCopyBits()

EXTERNRT int rtxCopyBits ( OSCTXT pctxt,
const OSOCTET *  pvalue,
OSSIZE  nbits,
OSUINT32  bitOffset 
)

This function will encode a series of bits from an octet array.

Encoding started from specified bit offset.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvaluePointer to bit string to be encoded.
nbitsNumber of bits from the value to encode.
bitOffsetStarting bit offset.
Returns
Status of the operation. Zero if successful; a negative status code if failed.

◆ rtxEncBit()

EXTERNRT int rtxEncBit ( OSCTXT pctxt,
OSBOOL  value 
)

This function will set the bit at the current encode bit cursor position to 1 or 0 and advance the cursor pointer.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
valueThe value to be encoded.

◆ rtxEncBits()

EXTERNRT int rtxEncBits ( OSCTXT pctxt,
OSUINT32  value,
OSSIZE  nbits 
)

This function encodes a number of the least significant bits (up to 32) of an unsigned integer value.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
valueThe value to be encoded.
nbitsNumber of bits from the value to encode.
Returns
Status of the operation. Zero if successful; a negative status code if failed.

◆ rtxEncBitsFromByteArray()

EXTERNRT int rtxEncBitsFromByteArray ( OSCTXT pctxt,
const OSOCTET *  pvalue,
OSSIZE  nbits 
)

This function will encode a series of bits from an octet array.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pvaluePointer to bit string to be encoded.
nbitsNumber of bits from the value to encode.
Returns
Status of the operation. Zero if successful; a negative status code if failed.

◆ rtxEncBitsFromSize()

EXTERNRT int rtxEncBitsFromSize ( OSCTXT pctxt,
OSSIZE  value,
OSSIZE  nbits 
)

This function encodes a number of the least significant bits from a size type.

The maximum that may be encoded is the maximum held by the type (32 or 64 bits).

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
valueThe value to be encoded.
nbitsNumber of bits from the value to encode.
Returns
Status of the operation. Zero if successful; a negative status code if failed.

◆ rtxEncBitsPattern()

EXTERNRT int rtxEncBitsPattern ( OSCTXT pctxt,
OSUINT8  pattern,
OSSIZE  nbits 
)

This function encodes the given number of bits using a repeating bit pattern.

This function may be used to encode any number of bits (including more than 8 bits). It will take the bit values to encode from the pattern, in accordance with the buffer's bit offset. For example, if the next bit to encode is the highest bit of the next byte in the buffer, then the bit value encoded will be the highest bit of the pattern.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
patternThe repeating pattern.
bitsThe number of bits to encode.

◆ rtxMergeBits()

EXTERNRT int rtxMergeBits ( OSCTXT pctxt,
OSUINT32  value,
OSSIZE  nbits 
)

This function will merge a series of bits (up to 32) from an unsigned integer value into an existing encoded data buffer.

Parameters
pctxtPointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
valueThe value to be encoded.
nbitsNumber of bits from the value to merge.
Returns
Status of the operation. Zero if successful; a negative status code if failed.