9 # error This is a userspace-only header, not allowed by the current build.
12 #include <sifteo/abi.h>
37 Fixed(
int value,
unsigned width,
bool leadingZeroes=
false)
38 : value(value), width(width), leadingZeroes(leadingZeroes) {}
61 FixedFP(
float value,
unsigned left,
unsigned right,
bool leadingZeroes=
false)
62 : widthL(left), widthR(right), leadingZeroes(leadingZeroes)
77 case 0: valueR = value * 0;
break;
78 case 1: valueR = value * 10;
break;
79 case 2: valueR = value * 100;
break;
80 case 3: valueR = value * 1000;
break;
81 case 4: valueR = value * 10000;
break;
82 case 5: valueR = value * 100000;
break;
83 case 6: valueR = value * 1000000;
break;
84 case 7: valueR = value * 10000000;
break;
85 case 8: valueR = value * 100000000;
break;
86 case 9: valueR = value * 1000000000;
break;
92 unsigned widthL, widthR;
109 Hex(uint32_t value,
unsigned width=8,
bool leadingZeroes=
true)
110 : value(value), width(width), leadingZeroes(leadingZeroes) {}
129 Hex64(uint64_t value,
unsigned width=16,
bool leadingZeroes=
true)
130 : value(value), width(width), leadingZeroes(leadingZeroes) {}
146 inline int strncmp(
const char *a,
const char *b,
unsigned count)
148 return _SYS_strncmp(a, b, count);
157 inline unsigned strnlen(
const char *str, uint32_t maxLen) {
158 return _SYS_strnlen(str, maxLen);
171 template <
unsigned tCapacity>
175 typedef char* iterator;
176 typedef const char* const_iterator;
199 operator const char *()
const {
210 return _SYS_strnlen(buffer, tCapacity-1);
220 return &buffer[
size()];
229 const_iterator
end()
const {
230 return &buffer[
size()];
240 return buffer[0] ==
'\0';
252 template <
class T>
int compare(
const T &other)
const {
271 _SYS_strlcpy(buffer, src, tCapacity);
277 _SYS_strlcat(buffer, src, tCapacity);
283 return buffer[index];
288 return buffer[index];
293 return buffer[index];
298 return buffer[index];
303 _SYS_strlcat(buffer, src, tCapacity);
309 _SYS_strlcat_int(buffer, src, tCapacity);
315 _SYS_strlcat_int_fixed(buffer, src.value, src.width, src.leadingZeroes, tCapacity);
321 _SYS_strlcat_int_fixed(buffer, src.valueL, src.widthL, src.leadingZeroes, tCapacity);
322 _SYS_strlcat(buffer,
".", tCapacity);
323 _SYS_strlcat_int_fixed(buffer, src.valueR, src.widthR,
true, tCapacity);
329 _SYS_strlcat_int_hex(buffer, src.value, src.width, src.leadingZeroes, tCapacity);
335 uint32_t high = src.value >> 32;
336 uint32_t low = src.value;
337 if (src.width > 8 || high != 0) {
338 _SYS_strlcat_int_hex(buffer, high, src.width - 8, src.leadingZeroes, tCapacity);
339 _SYS_strlcat_int_hex(buffer, low, 8,
true, tCapacity);
341 _SYS_strlcat_int_hex(buffer, low, src.width, src.leadingZeroes, tCapacity);
377 char buffer[tCapacity];