diff --git a/HTMLKit/HTMLInputStreamReader.h b/HTMLKit/HTMLInputStreamReader.h index c4a6f88..bf8f769 100644 --- a/HTMLKit/HTMLInputStreamReader.h +++ b/HTMLKit/HTMLInputStreamReader.h @@ -88,6 +88,15 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason); */ - (BOOL)consumeCharacter:(UTF32Char)character; +/** + Consumes characters at the current location matching an unsigned number. + + @param result Upon return, contains the consumed unsigned number. Pass `NULL` to skip over an unsigned number at the + current location. + @returns YES if an unsigned number could be consumed at the current location, NO otherwise. + */ +- (BOOL)consumeNumber:(unsigned long long *)result; + /** Consumes characters at the current location matching a decimal number. @@ -95,7 +104,7 @@ typedef void (^ HTMLStreamReaderErrorCallback)(NSString *reason); current location. @returns YES if a decimal number could be consumed at the current location, NO otherwise. */ -- (BOOL)consumeNumber:(unsigned long long *)result; +- (BOOL)consumeDecimalNumber:(NSDecimal *)result; /** Consumes characters at the current location matching a hexadecimal number. diff --git a/HTMLKit/HTMLInputStreamReader.m b/HTMLKit/HTMLInputStreamReader.m index 3df5f8d..d01f880 100644 --- a/HTMLKit/HTMLInputStreamReader.m +++ b/HTMLKit/HTMLInputStreamReader.m @@ -152,6 +152,17 @@ return success; } +- (BOOL)consumeDecimalNumber:(NSDecimal *)result +{ + NSDecimal scanned; + BOOL success = [_scanner scanDecimal:&scanned]; + if (success == NO) return NO; + + *result = scanned; + _location = _scanner.scanLocation; + return success; +} + - (BOOL)consumeHexNumber:(unsigned long long *)result { NSCharacterSet *set = [NSCharacterSet HTMLHexNumberCharacterSet];