On 7/29/2015 22:51, Daniel Stenberg wrote:
On Wed, 29 Jul 2015, Honza Bambas wrote:

I've recently introduced a class making parsing string inputs much safer and simpler.

http://www.janbambas.cz/string-parsing-made-simple-with-mozillatokenizer/

Nice! How does it act when hitting 64bit integer overflows?

Sorry, lost among all the emails.

So, there are two ways to read integers with Tokenizer (after bug 1188983):
- via Next or Check
- via ReadInteger

The first two return a Token with uint64_t AsInteger() method if it fits uint64_t. Otherwise the type of the token is TOKEN_ERROR.

The *templated* bool ReadInteger(T* result) does a runtime check whether the parsed number fits the result type. If not, returns false, if yes, sets the result value to your int and forwards the cursor.

And one more note: Tokenizer doesn't automatically recognize negative numbers.

-hb-
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to