43 #ifndef ETISS_FASTSTRING_H_
44 #define ETISS_FASTSTRING_H_
48 #include <type_traits>
59 template <
unsigned maxlen_plus1>
63 void strcpy(
char *dst,
const char *src)
66 while (pos < maxlen_plus1)
68 const char sc = src[pos];
85 std::vector<std::pair<size_t, size_t>>
fields;
89 size_t char_size(
unsigned,
size_t *,
bool *) {
return 0; }
90 template <
typename... O>
91 size_t char_size(
unsigned pos,
size_t *
size,
bool *isPlaceholder,
const char *
s, O... others)
93 size[pos] = strlen(
s);
94 isPlaceholder[pos] =
false;
97 template <
typename... O>
98 size_t char_size(
unsigned pos,
size_t *
size,
bool *isPlaceholder,
size_t len, O... others)
101 isPlaceholder[pos] =
true;
108 template <
typename... O>
109 void char_copy(
unsigned pos,
char *buf,
size_t *
size,
const char *
s, O... others)
114 template <
typename... O>
122 template <
typename... T>
126 size_t element[
sizeof...(str)];
127 bool placeholder[
sizeof...(str)];
128 size_t total =
char_size(0, element, placeholder,
str...);
130 buffer =
new char[total + 1];
138 for (
size_t i = 0; i <
sizeof...(str); i++)
142 fields.push_back(std::make_pair(offset, element[i]));
144 offset = offset + element[i];
148 template <
typename T>
149 std::enable_if<std::is_integral<T>::value,
void>
write_dec(
unsigned field, T value)
151 std::pair<size_t, size_t> f =
fields[field];
152 size_t pos = f.first + f.second;
161 std::cerr <<
"out of range buffer operation" << std::endl;
167 char c = (char)(value % 10);
173 while (pos >= f.first)
188 std::cerr <<
"out of range buffer operation" << std::endl;
196 inline void writet(
unsigned field,
const char *buf,
size_t length,
char terminator =
' ',
char fill =
' ')
200 if (
length + 2 > f.second)
205 std::cerr <<
"out of range buffer operation" << std::endl;
general configuration and logging
__DEVICE__ void * memset(void *__a, int __b, size_t __c)
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
__device__ __2f16 float c
__device__ __2f16 float bool s
void strcpy(char *dst, const char *src)
std::ostream & operator<<(std::ostream &os, const form_string &fs)
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
void log(Verbosity level, std::string msg)
write log message at the given level.
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)