}
- bool starts_with(cxx::String const &c) const
+ Index starts_with(cxx::String const &c) const
{
unsigned long i;
for (i = 0; i < c._len && i < _len; ++i)
if (_start[i] != c[i])
- return false;
- return i == c._len;
+ return 0;
+ return i == c._len ? start() + i : 0;
}
char const *find(int c, char const *s) const
bool eof(char const *s) const { return s >= _start + _len || !*s; }
+ template<typename INT>
+ int from_dec(INT *v) const
+ {
+ *v = 0;
+ Index c;
+ for (c = start(); !eof(c); ++c)
+ {
+ unsigned char n;
+ if (*c >= '0' && *c <= '9')
+ n = *c - '0';
+ else
+ return c - start();
+
+ *v *= 10;
+ *v += n;
+ }
+ return c - start();
+ }
+
template<typename INT>
int from_hex(INT *v) const
{
shift += 4;
if (shift > sizeof(INT) * 8)
return -1;
- *v <<= 4;
unsigned char n;
if (*c >= '0' && *c <= '9')
n = *c - '0';
else
return c - start();
+ *v <<= 4;
*v |= n;
}
return c - start();