1#ifndef ROSE_StringUtility_NumberToString_H
2#define ROSE_StringUtility_NumberToString_H
4#include <Rose/BitOps.h>
7#include <Sawyer/IntervalSet.h>
11namespace StringUtility {
29#if !defined(_MSC_VER) && \
30 defined(BACKEND_CXX_IS_GNU_COMPILER) && \
31 ((BACKEND_CXX_COMPILER_MAJOR_VERSION_NUMBER == 4 && BACKEND_CXX_COMPILER_MINOR_VERSION_NUMBER > 6) || \
32 BACKEND_CXX_COMPILER_MAJOR_VERSION_NUMBER > 4) && \
60ROSE_UTIL_API std::string
toHex2(uint64_t value,
size_t nbits,
61 bool show_unsigned_decimal=
true,
bool show_signed_decimal=
true,
62 uint64_t decimal_threshold=256);
63ROSE_UTIL_API std::string
signedToHex2(uint64_t value,
size_t nbits);
68 return toHex2((uint64_t)value, 8*
sizeof(T));
87ROSE_UTIL_API std::string
addrToString(uint64_t value,
size_t nbits = 0);
108template<
typename Un
signed>
109std::string
toBinary(Unsigned value,
size_t nBits = 0,
size_t groupSize = 4,
const std::string groupSeparator =
"_") {
113 for (
size_t i = nBits; i > 0; --i) {
115 if (groupSize > 0 && i > 1 && (i-1) % groupSize == 0)
116 retval += groupSeparator;
A container holding a set of values.
Range of values delimited by endpoints.
Holds a value or nothing.
size_t nBits(Unsigned=Unsigned(0))
Number of bits in a type or value.
bool bit(Unsigned src, size_t i)
Extract a single bit.
ROSE_UTIL_API std::string addrToString(uint64_t value, size_t nbits=0)
Convert a virtual address to a string.
std::string toBinary(Unsigned value, size_t nBits=0, size_t groupSize=4, const std::string groupSeparator="_")
Convert a number to a binary string.
ROSE_UTIL_API std::string numberToString(long long)
Convert an integer to a string.
std::string signedToHex(T value)
Convert a number to a hexadecimal and decimal string.
ROSE_UTIL_API std::string toHex2(uint64_t value, size_t nbits, bool show_unsigned_decimal=true, bool show_signed_decimal=true, uint64_t decimal_threshold=256)
Convert a number to a hexadecimal and decimal string.
std::string toHex(T value)
Convert a number to a hexadecimal and decimal string.
ROSE_UTIL_API std::string unsignedToHex2(uint64_t value, size_t nbits)
Convert a number to a hexadecimal and decimal string.
ROSE_UTIL_API std::string intToHex(uint64_t)
Convert an integer to a hexadecimal string.
ROSE_UTIL_API std::string signedToHex2(uint64_t value, size_t nbits)
Convert a number to a hexadecimal and decimal string.
std::string unsignedToHex(T value)
Convert a number to a hexadecimal and decimal string.