30 #include <type_traits> 39 static_assert(std::is_unsigned<T>::value,
"Unsigned type required");
42 if (value < 10)
return string(1,
'0' +
char(value));
43 char buf[(
sizeof(T) * 5 + 1) / 2];
44 char * p = buf +
sizeof(buf);
47 char ch =
static_cast<char>(value % 10);
51 return string(p, buf +
sizeof(buf) - p);
60 if (value < 10 && value >= 0)
return string(1,
'0' +
char(value));
62 bool negative = (value < 0);
64 typedef typename std::make_unsigned<T>::type unsigned_type;
65 unsigned_type val(value);
70 char buf[(
sizeof(unsigned_type) * 5 + 1) / 2 + 1];
71 char * p = buf +
sizeof(buf);
74 char ch =
static_cast<char>(val % 10);
83 return string(p, buf +
sizeof(buf) - p);
96 str(
unsigned int value)
120 str(
unsigned long long value)
133 size_t size =
SNPRINTF(buf,
sizeof(buf), fmt, value);
135 if (size >
sizeof(buf)) size =
sizeof(buf);
137 size_t size = sprintf(buf, fmt, value);
139 if (size >=
sizeof(buf)) abort();
141 return string(buf, size);
147 return format(
"%.20g", value);
153 return format(
"%p", value);
The Xapian namespace contains public interfaces for the Xapian library.
string str(const void *value)
Convert const void * to std::string.
#define AssertRel(A, REL, B)
static string tostring_unsigned(T value)
Convert types to std::string.
static string tostring(T value)
static string format(const char *fmt, T value)
Various assertion macros.