From c7994c11113b0e4e270b34bbb8ea8521ddf4a6df Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Fri, 22 Apr 2016 00:07:03 +0100 Subject: [PATCH] Added the IntToHex function. --- source/common/text.cpp | 10 ++++++++++ source/common/text.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/source/common/text.cpp b/source/common/text.cpp index d223993..f6549d2 100644 --- a/source/common/text.cpp +++ b/source/common/text.cpp @@ -256,4 +256,14 @@ bool HexToInt(std::string *HexString, int *Number){ return true; +} + +bool IntToHex(int *Number, std::string *HexString, int HexFill){ + + stringstream StringData; + StringData << setfill('0') << hex << setw(HexFill) << (*Number); + (*HexString) = StringData.str(); + + return true; + } \ No newline at end of file diff --git a/source/common/text.h b/source/common/text.h index f50113e..fa74d9b 100644 --- a/source/common/text.h +++ b/source/common/text.h @@ -7,6 +7,7 @@ #include #include #include +#include struct PropertyNameValue{ std::string Name; @@ -20,5 +21,6 @@ std::multimap ProcessTextVectors(std::vector SplitValues(std::string InputData); PropertyNameValue SplitNameValue(std::string InputData); bool HexToInt(std::string *HexString, int *Number); +bool IntToHex(int *Number, std::string *HexString, int HexFill); #endif \ No newline at end of file -- 2.39.2