OmniSketch  0.1
Oh my sketch!
OmniSketch::Data::DataFormat Class Reference

Parse the format in config file. More...

#include <data.h>

Public Member Functions

int32_t getRecordLength () const
 Get the length of a record. More...
 
int32_t getKeyLength () const
 Get the key length. More...
 
 DataFormat (const toml::array &array)
 Construct by specifications in config file. More...
 
template<int32_t key_len>
const int8_t * readAsFormat (Record< key_len > &record, const int8_t *byte) const
 Unscramble byte string in given format. More...
 
template<int32_t key_len>
const int8_t * writeAsFormat (const Record< key_len > &record, int8_t *byte) const
 Scramble the record in given format. More...
 

Detailed Description

Parse the format in config file.

Attention
Specifications in config file must be in compliance with the following rules. Otherwise an exception would be thrown.
Field Name Viable Length Further Constraints
flowkey 4, 8, 13 Specify exactly once
timestamp 1, 2, 4, 8 In microseconds. Specify at most once
length 1, 2, 4, 8 Specify at most once
padding > 0 None

Constructor & Destructor Documentation

◆ DataFormat()

OmniSketch::Data::DataFormat::DataFormat ( const toml::array &  array)

Construct by specifications in config file.

It is suggested that toml::array is fetched via a call to Util::ConfigParser::parseConfig(T &, const std::string_view) const with T = toml::array.

Member Function Documentation

◆ getKeyLength()

int32_t OmniSketch::Data::DataFormat::getKeyLength ( ) const
inline

Get the key length.

◆ getRecordLength()

int32_t OmniSketch::Data::DataFormat::getRecordLength ( ) const
inline

Get the length of a record.

◆ readAsFormat()

template<int32_t key_len>
const int8_t * OmniSketch::Data::DataFormat::readAsFormat ( Record< key_len > &  record,
const int8_t *  byte 
) const

Unscramble byte string in given format.

Template Parameters
key_lenlength of flowkey
Parameters
recordthe record to be stored to
bytepointer to byte string
Returns
pointer to the head of unprocessed byte string
Attention
An exception would be thrown if key_len does not match that in DataFormat.

◆ writeAsFormat()

template<int32_t key_len>
const int8_t * OmniSketch::Data::DataFormat::writeAsFormat ( const Record< key_len > &  record,
int8_t *  byte 
) const

Scramble the record in given format.

Template Parameters
key_lenlength of flowkey
Parameters
recordthe record to be deserialized
byteto store the deserialized message
Returns
right after the end of the message
Attention
An exception would be thrown if key_len does not match that in DataFormat.