Add HTML stream method to consume a decimal number

This commit is contained in:
iska
2015-12-22 02:13:50 +01:00
parent 846b6114fc
commit b55ca26c7e
2 changed files with 21 additions and 1 deletions
+10 -1
View File
@@ -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.
+11
View File
@@ -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];