Binary Data Manipulation Tools


Classes

class  CRCException
 This is thrown when there is an error processing a CRC. More...
class  CRCParam
 Encapsulate parameters for CRC computation. More...

Functions

template<class T>
void gpstk::BinUtils::twiddle (T &p) throw ()
 Reverse bytes.
template<class T>
gpstk::BinUtils::intelToHost (const T &p) throw ()
 Converts Intel little-endian to host byte order, const version.
template<class T>
gpstk::BinUtils::hostToIntel (const T &p) throw ()
 Converts host byte order to Intel little-endian, const version.
template<class T>
gpstk::BinUtils::netToHost (const T &p) throw ()
 Converts host byte order to network order, const version.
template<class T>
gpstk::BinUtils::hostToNet (const T &p) throw ()
 Converts network byte order to host order, const version.
template<class T>
gpstk::BinUtils::decodeVar (std::string &str, std::string::size_type pos=std::string::npos)
 Remove (optinally) the item specified from the string and convert it from network byte order to host byte order.
template<class T>
std::string gpstk::BinUtils::encodeVar (const T &v)
 Add the network ordered binary representation of a var to the the given string.
unsigned long gpstk::BinUtils::reflect (unsigned long crc, int bitnum)
 Reflects the lower bitnum bits of crc.
unsigned long gpstk::BinUtils::computeCRC (const unsigned char *data, unsigned long len, const CRCParam &params)
 Compute CRC (suitable for polynomial orders from 1 to 32).
template<class X>
gpstk::BinUtils::xorChecksum (const std::string &str) throw (gpstk::InvalidParameter)
 Calculate an Exclusive-OR Checksum on the string /a str.

Variables

const CRCParam gpstk::BinUtils::CRCCCITT (16, 0x1021, 0xffff, 0, true, false, false)
const CRCParam gpstk::BinUtils::CRC16 (16, 0x8005, 0, 0, true, true, true)
const CRCParam gpstk::BinUtils::CRC32 (32, 0x4c11db7, 0xffffffff, 0xffffffff, true, true, true)
const CRCParam gpstk::BinUtils::CRC24Q (24, 0x823ba9, 0, 0xffffffff, true, false, false)


Function Documentation

unsigned long computeCRC const unsigned char *  data,
unsigned long  len,
const CRCParam &  params
[inline]
 

Compute CRC (suitable for polynomial orders from 1 to 32).

Does bit-by-bit computation (brute-force, no look-up tables). Default parameters are for CRC16. The following table lists parameters for common CRC algorithms (order is decimal, the other parameters are hex):

  • CRC-CCITT order=16 polynom=1021 initial=ffff final=0 direct=true refin=false refout=false
  • CRC-16 order=16 polynom=8005 initial=0 final=0 direct=true refin=true refout=true
  • CRC-32 order=32 polynom=4c11db7 initial=ffffffff final=ffffffff direct=true refin=true refout=true
    Parameters:
    data data to process CRC on.
    len length of data to process.
    params see documentation of CRCParam:w
    Returns:
    the CRC value

Definition at line 290 of file BinUtils.hpp.

Referenced by MDPHeader::checkCRC(), BinexData::getCRC(), and MDPHeader::setCRC().

T decodeVar std::string &  str,
std::string::size_type  pos = std::string::npos
 

Remove (optinally) the item specified from the string and convert it from network byte order to host byte order.

Parameters:
str the string from which to obtain data.
pos an offset into the string to pull the data from. If this value is specified, the item is not removed from the string. This function does not check for appropriate string length.

Definition at line 182 of file BinUtils.hpp.

References gpstk::BinUtils::netToHost().

std::string encodeVar const T &  v  ) 
 

Add the network ordered binary representation of a var to the the given string.

Parameters:
v the object of type T to convert to a string.

Definition at line 207 of file BinUtils.hpp.

References gpstk::BinUtils::hostToNet().

Referenced by MDPSelftestStatus::encode(), MDPObsEpoch::Observation::encode(), and MDPObsEpoch::encode().

T hostToIntel const T &  p  )  throw ()
 

Converts host byte order to Intel little-endian, const version.

Parameters:
p the object whose bytes are to be modified
Returns:
a new object which is in host byte ordering.

Definition at line 133 of file BinUtils.hpp.

References gpstk::BinUtils::twiddle().

Referenced by FICData::reallyPutRecord().

T hostToNet const T &  p  )  throw ()
 

Converts network byte order to host order, const version.

Parameters:
p the object whose bytes are to be modified.
Returns:
a new object which is in host byte order.

Definition at line 163 of file BinUtils.hpp.

References gpstk::BinUtils::twiddle().

Referenced by gpstk::BinUtils::encodeVar(), and MDPHeader::setCRC().

T intelToHost const T &  p  )  throw ()
 

Converts Intel little-endian to host byte order, const version.

Parameters:
p the object whose bytes are to be modified.
Returns:
a new object which is in Intel byte ordering.

Definition at line 118 of file BinUtils.hpp.

References gpstk::BinUtils::twiddle().

Referenced by gpstk::decodeVar(), NovatelData::operator RinexNavData(), NovatelData::operator RinexObsData(), NovatelData::reallyGetRecord(), and FICData::reallyGetRecord().

T netToHost const T &  p  )  throw ()
 

Converts host byte order to network order, const version.

Parameters:
p the object whose bytes are to be modified.
Returns:
a new object which is in network byte order.

Definition at line 148 of file BinUtils.hpp.

References gpstk::BinUtils::twiddle().

Referenced by gpstk::BinUtils::decodeVar(), and MDPHeader::readHeader().

unsigned long reflect unsigned long  crc,
int  bitnum
[inline]
 

Reflects the lower bitnum bits of crc.

Definition at line 224 of file BinUtils.hpp.

void twiddle T &  p  )  throw ()
 

Reverse bytes.

This function will reverse the bytes in any type, though it is typically meant to be used in atomic types like int and double.

Parameters:
p object whose bytes are to be reversed.

Definition at line 96 of file BinUtils.hpp.

Referenced by BinexData::extractMessageData(), BinexData::getCRC(), gpstk::BinUtils::hostToIntel(), gpstk::BinUtils::hostToNet(), gpstk::BinUtils::intelToHost(), gpstk::BinUtils::netToHost(), and BinexData::updateMessageData().

X xorChecksum const std::string &  str  )  throw (gpstk::InvalidParameter)
 

Calculate an Exclusive-OR Checksum on the string /a str.

Returns:
the calculated checksum.
Exceptions:
gpstk::InvalidParameter if there is a partial word at the end of /a str.

Definition at line 371 of file BinUtils.hpp.

References GPSTK_THROW.


Variable Documentation

const CRCParam CRC16
 

Definition at line 266 of file BinUtils.hpp.

const CRCParam CRC24Q
 

Definition at line 268 of file BinUtils.hpp.

const CRCParam CRC32
 

Definition at line 267 of file BinUtils.hpp.

const CRCParam CRCCCITT
 

Definition at line 265 of file BinUtils.hpp.


Generated on Fri Feb 3 03:31:27 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1