OmniSketch  0.1
Oh my sketch!
OmniSketch::Util Namespace Reference

Utils of manipulating integers, parsing configuration files and so on. More...

Classes

class  ConfigParser
 Parse config file and return its configurations in a versatile manner. More...
 
class  DynamicIntX
 Integer of any fixed length. More...
 
class  PcapParser
 Pcap Parser. More...
 

Functions

template<typename T >
Mangle (T key)
 Mangling a multi-byte object. More...
 
bool IsPrime (int32_t n)
 Compute primality of a 32-bit number. More...
 
int32_t NextPrime (int32_t n)
 Find the next prime number. More...
 
uint16_t Net2Host16 (uint16_t val)
 Convert a 2-byte word from network endian to the host endian. More...
 
uint32_t Net2Host32 (uint32_t val)
 Convert a 4-byte word from network endian to host endian. More...
 
bool Endianness ()
 Endianness of the platform. More...
 

Detailed Description

Utils of manipulating integers, parsing configuration files and so on.

Implementation of some utils.

Implementation of templated methods.

Todo:
Support "txt", "null" & "pcap" mode

Function Documentation

◆ Endianness()

bool OmniSketch::Util::Endianness ( )
inline

Endianness of the platform.

Returns
true on big endian; false on small endian.

◆ IsPrime()

bool OmniSketch::Util::IsPrime ( int32_t  n)

Compute primality of a 32-bit number.

Parameters
nNumber to be checked
Returns
true if is a prime; false otherwise.
Warning
n must be positive. Otherwise an exception would be thrown.

◆ Mangle()

template<typename T >
T OmniSketch::Util::Mangle ( key)

Mangling a multi-byte object.

Template Parameters
Tobject type
Parameters
keythe object
Returns
the mangled object

◆ Net2Host16()

uint16_t OmniSketch::Util::Net2Host16 ( uint16_t  val)

Convert a 2-byte word from network endian to the host endian.

◆ Net2Host32()

uint32_t OmniSketch::Util::Net2Host32 ( uint32_t  val)

Convert a 4-byte word from network endian to host endian.

◆ NextPrime()

int32_t OmniSketch::Util::NextPrime ( int32_t  n)

Find the next prime number.

Parameters
nStarting number
Returns
Next prime number
Warning
n must be positive. Otherwise an exception would be thrown.