diff options
author | 2016-02-28 11:09:00 +1100 | |
---|---|---|
committer | 2016-02-28 13:36:19 +1100 | |
commit | aec01e740736db267e452f0ed5947649f79e3408 (patch) | |
tree | 633ca7d80a756bfcc05d871817201c729e55142d /src/lib/util/hashing.cpp | |
parent | 3cba23966f6c1c6f9ee616e5af00ebcfcb0d0b0a (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.cpp | 22 |
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); } /** |