utils.cpp File Reference


Detailed Description

Implementation of various useful utility functions.

Definition in file utils.cpp.

#include <hn/hnprec.h>
#include <hn/utils.h>
#include <sstream>

Include dependency graph for utils.cpp:

Go to the source code of this file.


Namespaces

namespace  Utils

Functions

unsigned char hex2dec (unsigned char c)
 Converts passed character to decimal notation.
std::string decode (const char *data, uint32_t length)
 Convert passed data into hexadecimal notation.
std::string encode (const char *data, uint32_t length)
 Convert hexadecimal character string into binary format.
void hexDump (std::ostream &o, const std::string &data)
 Print hexadecimal dump of specified data into specified stream.
std::string hexDump (const std::string &data)
 Convert passed string into formatted hexadecimal string.

Function Documentation

std::string DLLEXPORT Utils::decode const char *  data,
uint32_t  length
 

Convert passed data into hexadecimal notation.

Parameters:
data Data to be decoded.
length Length of data.
Returns:
Hexadecimal notation of the data.

Definition at line 46 of file utils.cpp.

References CHECK_THROW.

Referenced by HashSetBase::compare(), Utils::decode(), HashBase::decode(), and PartData::onHashEvent().

std::string DLLEXPORT Utils::encode const char *  data,
uint32_t  length
 

Convert hexadecimal character string into binary format.

Parameters:
data Data to be encoded.
length Length of data.
Returns:
Binary representation of the passed data.
Note:
Throws std::runtime_error from hex2dec if passed data is not well-formed hexadecimal stream.

Definition at line 60 of file utils.cpp.

References CHECK_THROW, and Utils::hex2dec().

Referenced by Utils::encode().

Here is the call graph for this function:

unsigned char hex2dec unsigned char  c  )  [inline]
 

Converts passed character to decimal notation.

Parameters:
c Hexadecimal-compatible unsigned character
Returns:
Decimal notation of given input

Definition at line 32 of file utils.cpp.

Referenced by Utils::encode().

std::string DLLEXPORT Utils::hexDump const std::string &  data  ) 
 

Convert passed string into formatted hexadecimal string.

Parameters:
data Data to convert
Returns:
Formatted hex-dump of the data.

Definition at line 141 of file utils.cpp.

References Utils::hexDump().

Here is the call graph for this function:

void DLLEXPORT Utils::hexDump std::ostream &  o,
const std::string &  data
 

Print hexadecimal dump of specified data into specified stream.

Parameters:
o Stream to write to
data Data to be written

Definition at line 77 of file utils.cpp.

Referenced by Utils::hexDump(), and CGComm::invalidType().