aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-11-09 06:04:15 +0100
committerSven Gothel <[email protected]>2020-11-09 06:04:15 +0100
commit43ad530af98168289e3538c89d3cbb20a4d016de (patch)
tree00ba3a838374e855709cfbbb943b45846f3223a2
parentee20f12669484de9070a5f29f8c1bec272797c91 (diff)
Adding uint128HexString() and uint256HexString()
-rw-r--r--include/jau/basic_types.hpp2
-rw-r--r--src/basic_types.cpp7
2 files changed, 9 insertions, 0 deletions
diff --git a/include/jau/basic_types.hpp b/include/jau/basic_types.hpp
index 35ab97c..ffb7109 100644
--- a/include/jau/basic_types.hpp
+++ b/include/jau/basic_types.hpp
@@ -682,6 +682,8 @@ namespace jau {
std::string uint32HexString(const uint32_t v, const bool leading0X=true) noexcept;
std::string uint64HexString(const uint64_t v, const bool leading0X=true) noexcept;
std::string aptrHexString(const void * v, const bool leading0X=true) noexcept;
+ std::string uint128HexString(const uint128_t v, const bool leading0X=true) noexcept;
+ std::string uint256HexString(const uint256_t v, const bool leading0X=true) noexcept;
/**
* If lsbFirst is true, orders LSB left -> MSB right, usual for byte streams.
diff --git a/src/basic_types.cpp b/src/basic_types.cpp
index 2297fd5..2c105d8 100644
--- a/src/basic_types.cpp
+++ b/src/basic_types.cpp
@@ -200,6 +200,13 @@ std::string jau::aptrHexString(const void * v, const bool leading0X) noexcept {
return uint64HexString((uint64_t)v, leading0X);
}
+std::string jau::uint128HexString(const uint128_t v, const bool leading0X) noexcept {
+ return bytesHexString(v.data, 0, sizeof(v.data), false /* lsbFirst */, leading0X);
+}
+std::string jau::uint256HexString(const uint256_t v, const bool leading0X) noexcept {
+ return bytesHexString(v.data, 0, sizeof(v.data), false /* lsbFirst */, leading0X);
+}
+
static const char* HEX_ARRAY = "0123456789ABCDEF";
std::string jau::bytesHexString(const uint8_t * bytes, const nsize_t offset, const nsize_t length, const bool lsbFirst, const bool leading0X) noexcept {