BitMagic-C++
Public Types | Public Member Functions
bm::encoder Class Reference

Memory encoding. More...

#include <encoding.h>

Public Types

typedef unsigned char * position_type
 

Public Member Functions

 encoder (unsigned char *buf, size_t size)
 Construction. More...
 
void put_8 (unsigned char c)
 Puts one character into the encoding buffer. More...
 
void put_16 (bm::short_t s)
 Puts short word (16 bits) into the encoding buffer. More...
 
void put_16 (const bm::short_t *s, unsigned count)
 Method puts array of short words (16 bits) into the encoding buffer. More...
 
void put_32 (bm::word_t w)
 Puts 32 bits word into encoding buffer. More...
 
void put_32 (const bm::word_t *w, unsigned count)
 Encodes array of 32-bit words. More...
 
void put_64 (bm::id64_t w)
 Puts 64 bits word into encoding buffer. More...
 
void put_prefixed_array_32 (unsigned char c, const bm::word_t *w, unsigned count)
 Encode 8-bit prefix + an array. More...
 
void put_prefixed_array_16 (unsigned char c, const bm::short_t *s, unsigned count, bool encode_count)
 Encode 8-bit prefix + an array. More...
 
void memcpy (const unsigned char *src, size_t count)
 copy bytes into target buffer or just rewind if src is NULL More...
 
size_t size () const
 Returns size of the current encoding stream. More...
 
unsigned char * get_pos () const
 Get current memory stream position. More...
 
void set_pos (unsigned char *buf_pos)
 Set current memory stream position. More...
 

Detailed Description

Memory encoding.

Class for encoding data into memory. Class handles aligment issues with the integer data types.

Definition at line 49 of file encoding.h.

Member Typedef Documentation

◆ position_type

typedef unsigned char* bm::encoder::position_type

Definition at line 52 of file encoding.h.

Constructor & Destructor Documentation

◆ encoder()

bm::encoder::encoder ( unsigned char *  buf,
size_t  size 
)
inline

Construction.

Parameters
buf- memory buffer pointer.
size- size of the buffer

Definition at line 371 of file encoding.h.

Member Function Documentation

◆ get_pos()

encoder::position_type bm::encoder::get_pos ( ) const
inline

◆ memcpy()

void bm::encoder::memcpy ( const unsigned char *  src,
size_t  count 
)
inline

copy bytes into target buffer or just rewind if src is NULL

Definition at line 459 of file encoding.h.

References BM_ASSERT.

Referenced by put_16(), put_32(), put_64(), bm::sparse_vector_serializer< SV >::serialize(), and bm::compressed_collection_serializer< CBC >::serialize().

◆ put_16() [1/2]

BMFORCEINLINE void bm::encoder::put_16 ( bm::short_t  s)

◆ put_16() [2/2]

void bm::encoder::put_16 ( const bm::short_t s,
unsigned  count 
)
inline

Method puts array of short words (16 bits) into the encoding buffer.

Definition at line 432 of file encoding.h.

References memcpy().

◆ put_32() [1/2]

void bm::encoder::put_32 ( bm::word_t  w)
inline

Puts 32 bits word into encoding buffer.

Parameters
w- word to encode.

Definition at line 499 of file encoding.h.

References memcpy().

Referenced by bm::serializer< bvector_type >::encode_bit_digest(), bm::serializer< bvector_type >::encode_bit_interval(), bm::serializer< bvector_type >::encode_header(), and put_prefixed_array_32().

◆ put_32() [2/2]

void bm::encoder::put_32 ( const bm::word_t w,
unsigned  count 
)
inline

Encodes array of 32-bit words.

Definition at line 539 of file encoding.h.

References memcpy().

◆ put_64()

void bm::encoder::put_64 ( bm::id64_t  w)
inline

◆ put_8()

BMFORCEINLINE void bm::encoder::put_8 ( unsigned char  c)

◆ put_prefixed_array_16()

void bm::encoder::put_prefixed_array_16 ( unsigned char  c,
const bm::short_t s,
unsigned  count,
bool  encode_count 
)
inline

◆ put_prefixed_array_32()

void bm::encoder::put_prefixed_array_32 ( unsigned char  c,
const bm::word_t w,
unsigned  count 
)
inline

◆ set_pos()

void bm::encoder::set_pos ( unsigned char *  buf_pos)
inline

◆ size()

size_t bm::encoder::size ( ) const
inline

The documentation for this class was generated from the following file: