summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/hashing.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2016-02-28 11:09:00 +1100
committer Vas Crabb <vas@vastheman.com>2016-02-28 13:36:19 +1100
commitaec01e740736db267e452f0ed5947649f79e3408 (patch)
tree633ca7d80a756bfcc05d871817201c729e55142d /src/lib/util/hashing.cpp
parent3cba23966f6c1c6f9ee616e5af00ebcfcb0d0b0a (diff)
Replace strformat, strprintf and strcatprintf with type-safe steam_format and string_format
Update MAME to use new function Instantiate ODR-used static constant members Make some of the UI code more localisable Remove use of retired functions in tools
Diffstat (limited to 'src/lib/util/hashing.cpp')
-rw-r--r--src/lib/util/hashing.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/util/hashing.cpp b/src/lib/util/hashing.cpp
index 8e85e4a42d2..240e64af9ad 100644
--- a/src/lib/util/hashing.cpp
+++ b/src/lib/util/hashing.cpp
@@ -10,6 +10,8 @@
#include "hashing.h"
#include <zlib.h>
+#include <iomanip>
+#include <sstream>
//**************************************************************************
@@ -81,10 +83,12 @@ bool sha1_t::from_string(const char *string, int length)
std::string sha1_t::as_string() const
{
- std::string buffer;
+ std::ostringstream buffer;
+ buffer.fill('0');
+ buffer << std::hex;
for (auto & elem : m_raw)
- strcatprintf(buffer, "%02x", elem);
- return buffer;
+ buffer << std::setw(2) << unsigned(elem);
+ return buffer.str();
}
@@ -124,10 +128,12 @@ bool md5_t::from_string(const char *string, int length)
std::string md5_t::as_string() const
{
- std::string buffer;
+ std::ostringstream buffer;
+ buffer.fill('0');
+ buffer << std::hex;
for (auto & elem : m_raw)
- strcatprintf(buffer, "%02x", elem);
- return buffer;
+ buffer << std::setw(2) << unsigned(elem);
+ return buffer.str();
}
@@ -168,7 +174,7 @@ bool crc32_t::from_string(const char *string, int length)
std::string crc32_t::as_string() const
{
- return strformat("%08x", m_raw);
+ return string_format("%08x", m_raw);
}
@@ -225,7 +231,7 @@ bool crc16_t::from_string(const char *string, int length)
std::string crc16_t::as_string() const
{
- return strformat("%04x", m_raw);
+ return string_format("%04x", m_raw);
}
/**