整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
29
util/HexBinaryCodec.cpp
Executable file
29
util/HexBinaryCodec.cpp
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue