BitMagicC++Library
Data Structures | Enumerations | Functions
bvector<> serialization
Collaboration diagram for bvector<> serialization:

Data Structures

class  bm::serializer< BV >
 Bit-vector serialization class. More...
 
class  bm::deseriaizer_base< DEC >
 Base deserialization class. More...
 
class  bm::deserializer< BV, DEC >
 Deserializer for bit-vector. More...
 
class  bm::serial_stream_iterator< DEC >
 Serialization stream iterator. More...
 
class  bm::operation_deserializer< BV >
 Deserializer, performs logical operations between bit-vector and serialized bit-vector. More...
 

Enumerations

enum  bm::serialization_flags { bm::BM_NO_BYTE_ORDER = 1, bm::BM_NO_GAP_LENGTH = (1 << 1) }
 Bit mask flags for serialization algorithm. More...
 

Functions

template<class BV >
unsigned bm::serialize (const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
 Saves bitvector into memory. More...
 
template<class BV >
unsigned bm::serialize (BV &bv, unsigned char *buf, unsigned serialization_flags=0)
 Saves bitvector into memory. Allocates temporary memory block for bvector. More...
 
template<class BV >
unsigned bm::deserialize (BV &bv, const unsigned char *buf, bm::word_t *temp_block=0)
 Bitvector deserialization from memory. More...
 

Detailed Description

Serialization for bvector<> container

Enumeration Type Documentation

◆ serialization_flags

Bit mask flags for serialization algorithm.

Enumerator
BM_NO_BYTE_ORDER 

save no byte-order info (save some space)

BM_NO_GAP_LENGTH 

save no GAP info (save some space)

Definition at line 1141 of file bmserial.h.

Function Documentation

◆ deserialize()

template<class BV >
unsigned bm::deserialize ( BV &  bv,
const unsigned char *  buf,
bm::word_t temp_block = 0 
)

Bitvector deserialization from memory.

Parameters
bv- target bvector
buf- pointer on memory which keeps serialized bvector
temp_block- pointer on temporary block, if NULL bvector allocates own.
Returns
Number of bytes consumed by deserializer.

Function desrializes bitvector from memory block containig results of previous serialization. Function does not remove bits which are currently set. Effectively it means OR logical operation between current bitset and previously serialized one.

Examples:
sample14.cpp, sample4.cpp, and xsample01.cpp.

Definition at line 1250 of file bmserial.h.

References bm::BigEndian, BM_ASSERT, bm::BM_HM_NO_BO, bm::deserializer< BV, DEC >::deserialize(), bm::decoder_base::get_8(), and bm::LittleEndian.

Referenced by convert_bv2bvs(), bm::compressed_collection_deserializer< CBC >::deserialize(), bm::deserializer< BV, DEC >::deserializer(), main(), and bm::sparse_vector_deserialize().

◆ serialize() [1/2]

template<class BV >
unsigned bm::serialize ( const BV &  bv,
unsigned char *  buf,
bm::word_t temp_block = 0,
unsigned  serialization_flags = 0 
)

Saves bitvector into memory.

Function serializes content of the bitvector into memory. Serialization adaptively uses compression(variation of GAP encoding) when it is benefitial.

Parameters
bv- source bvecor
buf- pointer on target memory area. No range checking in the function. It is responsibility of programmer to allocate sufficient amount of memory using information from calc_stat function.
temp_block- pointer on temporary memory block. Cannot be 0; If you want to save memory across multiple bvectors allocate temporary block using allocate_tempblock and pass it to serialize. (Serialize does not deallocate temp_block.)
serialization_flagsFlags controlling serilization (bit-mask) (use OR-ed serialization flags)
Returns
Size of serialization block.
See also
calc_stat, serialization_flags

Serialization format:

| HEADER | BLOCKS |
Header structure:
  BYTE : Serialization header (bit mask of BM_HM_*)
  BYTE : Byte order ( 0 - Big Endian, 1 - Little Endian)
  INT16: Reserved (0)
  INT16: Reserved Flags (0)
 

Definition at line 1189 of file bmserial.h.

References bm::BM_NO_BYTE_ORDER, bm::BM_NO_GAP_LENGTH, and bm::serializer< BV >::byte_order_serialization().

Referenced by bm::serialize().

◆ serialize() [2/2]

template<class BV >
unsigned bm::serialize ( BV &  bv,
unsigned char *  buf,
unsigned  serialization_flags = 0 
)

Saves bitvector into memory. Allocates temporary memory block for bvector.

Parameters
bv- source bvecor
buf- pointer on target memory area. No range checking in the function. It is responsibility of programmer to allocate sufficient amount of memory using information from calc_stat function.
serialization_flagsFlags controlling serilization (bit-mask) (use OR-ed serialization flags)

Definition at line 1224 of file bmserial.h.

References bm::serialize().

Referenced by bm::serializer< bvector_type >::serialize().