}
return false;
}
+
+// adapted from compatr/strtoll.c
+bool
+Parser::Tokenizer::int64 (int64_t & result, int base)
+{
+ //register uint64_t acc;
+ register uint64_t cutoff;
+ bool neg = false;
+ static SBuf zerox("0x"), zero("0");
+
+ if (buf_.isEmpty())
+ return false;
+
+ if (buf_[0] == '-') {
+ neg = true;
+ buf_.consume(1);
+ }
+ if (buf_[0] == '+')
+ buf_.consume(1);
+ if (base == 0) {
+ if (buf_.startsWith(zerox))
+ base = 16;
+ else if (buf_.startsWith(zero))
+ base = 8;
+ else
+ base = 10;
+ }
+ if (base != 8 && base != 10 && base != 16)
+ return false;
+
+ // TODO: finish
+ cutoff = neg ? -(uint64_t) INT64_MIN : INT64_MAX;
+
+ // dummy to keep compiler happy. Remove before continuing
+ if (neg) result = cutoff;
+
+ return false;
+}
*/
bool skip(const char tokenChar);
+ /** parse an unsigned int64_t at the beginning of the buffer
+ *
+ * strtoull(3)-alike function: tries to parse unsigned 64-bit integer
+ * at the beginning of the parse buffer, in the base specified by the user
+ * or guesstimated; consumes the parsed characters.
+ *
+ * \param result output value. Not touched if parseing is unsuccessful
+ * \param base specify base to do the parsing in. Admitted values are
+ * 8, 10, 16 and 0, the latter specifying to use C syntax for guessing
+ * the base
+ * \return true if the parsing was successful
+ */
+ bool uint64 (uint64_t & result, int base);
+
+ bool int64 (int64_t &result, int base);
+
private:
SBuf buf_; ///< yet unparsed input
};