29 lines
894 B
C++
Executable file
29 lines
894 B
C++
Executable file
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include "HexBinaryCodec.h"
|
|
#include <sstream>
|
|
#include <Poco/HexBinaryEncoder.h>
|
|
|
|
namespace Util
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DEFINE
|
|
*******************************************************************************
|
|
*/
|
|
std::string HexBinaryCodec::encode(const void* data, unsigned size, bool uppercase)
|
|
{
|
|
std::ostringstream ostr;
|
|
Poco::HexBinaryEncoder encoder(ostr);
|
|
encoder.rdbuf()->setUppercase(uppercase);
|
|
uint8_t* pBytes = (uint8_t*)data;
|
|
for (unsigned i = 0; i < size; i++)
|
|
encoder << pBytes[i];
|
|
encoder.close();
|
|
|
|
return ostr.str();
|
|
}
|
|
}
|