JubeatPlus 3.9.11
Loading...
Searching...
No Matches
CDataScanner Class Reference

A byte-oriented scanner over an NSData 's bytes. More...

#include <CDataScanner.h>

Inheritance diagram for CDataScanner:
Collaboration diagram for CDataScanner:

Instance Methods

(instancetype) - init
 Initialises an empty scanner with no data.
(instancetype) - initWithData:
 Initialises the scanner and points it at some bytes.
(unichar) - currentCharacter
 The character at the cursor without consuming it.
(unichar) - scanCharacter
 Consumes and returns the character at the cursor.
(BOOL) - scanCharacter:
 Consumes the cursor character when it matches.
(BOOL) - scanUTF8String:intoString:
 Consumes a fixed UTF-8 run, optionally returning it as a string.
(BOOL) - scanString:intoString:
 Consumes a fixed string, optionally returning it.
(BOOL) - scanCharactersFromSet:intoString:
 Consumes the run of characters that are members of a set.
(BOOL) - scanUpToString:intoString:
 Consumes everything up to the next occurrence of a string.
(BOOL) - scanUpToCharactersFromSet:intoString:
 Consumes everything up to the next character that is a member of a set.
(BOOL) - scanNumber:
 Consumes a number literal, decoding it to an integer or a decimal.
(BOOL) - scanDecimalNumber:
 Consumes a number literal, always decoding it to an NSDecimalNumber .
(BOOL) - scanDataOfLength:intoPointer:
 Consumes a fixed number of bytes, returning a pointer into the data.
(BOOL) - scanDataOfLength:intoData:
 Consumes a fixed number of bytes, returning them as an NSData .
(void) - skipWhitespace
 Advances the cursor past any whitespace.
(nullable NSString *) - remainingString
 The bytes from the cursor to the end, decoded as a UTF-8 string.
(NSData *) - remainingData
 The bytes from the cursor to the end.
(BOOL) - scanCStyleComment:
 Consumes a C-style block comment (slash-star to star-slash).
(BOOL) - scanCPlusPlusStyleComment:
 Consumes a C++-style // comment through to the end of the line.
(NSUInteger) - lineOfScanLocation
 The one-based-ish count of line breaks before the cursor.
(NSDictionary *) - userInfoForScanLocation
 Diagnostic user info describing where the cursor is: its line, column, offset, and a snippet marking the position.
(void) - setData:
 Points the scanner at some bytes.
(void) - skipWhitespace
 Advances past any whitespace at the cursor.
(unichar) - currentCharacter
 The character at the cursor without consuming it.
(unichar) - scanCharacter
 Consumes and returns the character at the cursor.
(BOOL) - scanCharacter:
 Consumes the cursor character when it matches.
(BOOL) - scanUTF8String:intoString:
 Consumes a fixed UTF-8 run, optionally returning it.
(BOOL) - scanNumber:
 Consumes a JSON number literal.
(NSUInteger) - scanLocation
 The current byte offset.
(void) - setScanLocation:
 Rewinds or advances the cursor to a byte offset.
(NSDictionary *) - userInfoForScanLocation
 Diagnostic user-info describing where the cursor is.

Class Methods

(void) + initialize
 Primes the shared character set of number-literal characters.

Protected Attributes

NSData * data
 The bytes being scanned; retained.
char * start
 The first byte of the input.
char * end
 One past the last byte of the input.
char * current
 The next byte the scanner will read.
NSUInteger length
 The byte count of data .

Properties

NSUInteger scanLocation
 The cursor's byte offset from the start of the data.
NSUInteger bytesRemaining
 The number of bytes between the cursor and the end of the data.
BOOL isAtEnd
 Whether the cursor has reached or passed the end of the data.

Detailed Description

A byte-oriented scanner over an NSData 's bytes.

The byte-oriented scanner superclass; not reconstructed as its own file yet, so it is forward-declared here as an NSObject subclass exposing only what CJSONScanner uses.

The scanner keeps three raw pointers into the data: start (the first byte), end (one past the last byte), and current (the next byte to read). scanLocation is the cursor's byte offset, current - start . The scan-and-advance methods move current forward and return whether they matched.

See TYPES_PENDING.md.

The two byte-cursor ivars are named as TouchJSON names them, without an underscore, and are reached directly by -scanNotQuoteCharactersIntoString: .

Method Documentation

◆ currentCharacter [1/2]

- (unichar) currentCharacter

The character at the cursor without consuming it.

Returns
The byte at the cursor, widened to a unichar .
Ghidra address:
0x61c14
Ghidra address:
0x61c14

◆ currentCharacter [2/2]

- (unichar) currentCharacter

The character at the cursor without consuming it.

Returns
The character at the cursor.

◆ init

- (instancetype) init

Initialises an empty scanner with no data.

Returns
The initialised scanner.
Ghidra address:
0x619c8
Ghidra address:
0x619c8

Implemented in CJSONScanner.

◆ initialize

+ (void) initialize

Primes the shared character set of number-literal characters.

Ghidra address:
0x61968

Implemented in CJSONScanner.

◆ initWithData:

- (instancetype) initWithData: (nullable NSData *) someData

Initialises the scanner and points it at some bytes.

Parameters
someDataThe bytes to scan.
Returns
The initialised scanner.
Ghidra address:
0x61a00

◆ lineOfScanLocation

- (NSUInteger) lineOfScanLocation

The one-based-ish count of line breaks before the cursor.

Returns
The number of carriage returns and newlines between the start and the cursor.
Ghidra address:
0x62ff8
Ghidra address:
0x62ff8

◆ remainingData

- (NSData *) remainingData

The bytes from the cursor to the end.

Returns
The remaining bytes.
Ghidra address:
0x62510
Ghidra address:
0x62510

◆ remainingString

- (NSString *) remainingString

The bytes from the cursor to the end, decoded as a UTF-8 string.

Returns
The remaining text.
Ghidra address:
0x62480
Ghidra address:
0x62480

◆ scanCharacter [1/2]

- (unichar) scanCharacter

Consumes and returns the character at the cursor.

Returns
The byte at the cursor, widened to a unichar .
Ghidra address:
0x61c28
Ghidra address:
0x61c28

◆ scanCharacter [2/2]

- (unichar) scanCharacter

Consumes and returns the character at the cursor.

Returns
The consumed character.

◆ scanCharacter: [1/2]

- (BOOL) scanCharacter: (unichar) character

Consumes the cursor character when it matches.

Parameters
characterThe character to match.
Returns
Whether the cursor character matched and was consumed.
Ghidra address:
0x61c44
Ghidra address:
0x61c44

◆ scanCharacter: [2/2]

- (BOOL) scanCharacter: (unichar) character

Consumes the cursor character when it matches.

Parameters
characterThe character to match.
Returns
YES when the character matched and was consumed, NO otherwise.

◆ scanCharactersFromSet:intoString:

- (BOOL) scanCharactersFromSet: (NSCharacterSet *) set
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes the run of characters that are members of a set.

Parameters
setThe set whose members are consumed.
outStringWhere to return the consumed run, when the caller wants it.
Returns
Whether any characters were consumed.
Ghidra address:
0x61e34

◆ scanCPlusPlusStyleComment:

- (BOOL) scanCPlusPlusStyleComment: (NSString *_Nullable *_Nullable) outComment

Consumes a C++-style // comment through to the end of the line.

Parameters
outCommentWhere to return the comment's inner text, when the caller wants it.
Returns
Whether a comment was consumed.
Ghidra address:
0x62eac

◆ scanCStyleComment:

- (BOOL) scanCStyleComment: (NSString *_Nullable *_Nullable) outComment

Consumes a C-style block comment (slash-star to star-slash).

Parameters
outCommentWhere to return the comment's inner text, when the caller wants it.
Returns
Whether a comment was consumed.
Ghidra address:
0x62d4c

◆ scanDataOfLength:intoData:

- (BOOL) scanDataOfLength: (NSUInteger) scanLength
intoData: (NSData *_Nullable *_Nullable) outData 

Consumes a fixed number of bytes, returning them as an NSData .

Parameters
scanLengthThe number of bytes to consume.
outDataWhere to return the consumed bytes, when the caller wants it.
Returns
Whether enough bytes remained.
Ghidra address:
0x62350

◆ scanDataOfLength:intoPointer:

- (BOOL) scanDataOfLength: (NSUInteger) scanLength
intoPointer: (const void *_Nullable *_Nullable) outPointer 

Consumes a fixed number of bytes, returning a pointer into the data.

Parameters
scanLengthThe number of bytes to consume.
outPointerWhere to return the pointer to the consumed bytes, when the caller wants it.
Returns
Whether enough bytes remained.
Ghidra address:
0x622e4

◆ scanDecimalNumber:

- (BOOL) scanDecimalNumber: (NSDecimalNumber *_Nullable *_Nullable) outNumber

Consumes a number literal, always decoding it to an NSDecimalNumber .

Parameters
outNumberWhere to return the decoded number, when the caller wants it.
Returns
Whether a number was consumed.
Ghidra address:
0x62244

◆ scanLocation

- (NSUInteger) scanLocation

The current byte offset.

Returns
The cursor's byte offset.

◆ scanNumber: [1/2]

- (BOOL) scanNumber: (NSNumber *_Nullable *_Nullable) outNumber

Consumes a number literal, decoding it to an integer or a decimal.

Parameters
outNumberWhere to return the decoded number, when the caller wants it.
Returns
Whether a number was consumed.
Ghidra address:
0x620e0

◆ scanNumber: [2/2]

- (BOOL) scanNumber: (NSNumber *_Nullable *_Nullable) outNumber

Consumes a JSON number literal.

Parameters
outNumberOn success, the scanned number; may be nullptr .
Returns
YES when a number was scanned, NO otherwise.

◆ scanString:intoString:

- (BOOL) scanString: (NSString *) string
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes a fixed string, optionally returning it.

Parameters
stringThe string to match at the cursor.
outStringWhere to return the matched string, when the caller wants it.
Returns
Whether the string matched and was consumed.
Ghidra address:
0x61d34

◆ scanUpToCharactersFromSet:intoString:

- (BOOL) scanUpToCharactersFromSet: (NSCharacterSet *) set
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes everything up to the next character that is a member of a set.

Parameters
setThe set whose first member stops the scan.
outStringWhere to return the skipped-over text, when the caller wants it.
Returns
Whether any characters were consumed.
Ghidra address:
0x61ff0

◆ scanUpToString:intoString:

- (BOOL) scanUpToString: (NSString *) string
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes everything up to the next occurrence of a string.

Parameters
stringThe delimiter to stop before.
outStringWhere to return the skipped-over text, when the caller wants it.
Returns
Whether the delimiter was found.
Ghidra address:
0x61f24

◆ scanUTF8String:intoString: [1/2]

- (BOOL) scanUTF8String: (const char *) string
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes a fixed UTF-8 run, optionally returning it as a string.

Parameters
stringThe NUL-terminated bytes to match at the cursor.
outStringWhere to return the matched run, when the caller wants it.
Returns
Whether the run matched and was consumed.
Ghidra address:
0x61c74

◆ scanUTF8String:intoString: [2/2]

- (BOOL) scanUTF8String: (const char *) string
intoString: (NSString *_Nullable *_Nullable) outString 

Consumes a fixed UTF-8 run, optionally returning it.

Parameters
stringThe UTF-8 run to match.
outStringOn a match, the matched run; may be nullptr .
Returns
YES when the run matched and was consumed, NO otherwise.

◆ setData:

- (void) setData: (nullable NSData *) data

Points the scanner at some bytes.

Parameters
dataThe bytes to scan.

Implemented in CJSONScanner.

◆ setScanLocation:

- (void) setScanLocation: (NSUInteger) location

Rewinds or advances the cursor to a byte offset.

Parameters
locationThe byte offset to move the cursor to.
Ghidra address:
0x61bb8

◆ skipWhitespace

- (void) skipWhitespace

Advances the cursor past any whitespace.

Ghidra address:
0x623f0

◆ userInfoForScanLocation [1/2]

- (NSDictionary *) userInfoForScanLocation

Diagnostic user info describing where the cursor is: its line, column, offset, and a snippet marking the position.

Returns
The user-info dictionary.
Ghidra address:
0x63048
Ghidra address:
0x63048

◆ userInfoForScanLocation [2/2]

- (NSDictionary *) userInfoForScanLocation

Diagnostic user-info describing where the cursor is.

Returns
An error user-info dictionary naming the cursor's position.

Member Data Documentation

◆ data

- (NSData *) data
readwritenonatomicstrongprotected

The bytes being scanned; retained.

The bytes being scanned.

Setting new bytes resets the cursor to the start.

Note
The getter is at 0x61aa0 and the setter at 0x61ab0.

Property Documentation

◆ bytesRemaining

- (NSUInteger) bytesRemaining
readnonatomicassign

The number of bytes between the cursor and the end of the data.

Note
The getter is at 0x61a80.
Ghidra address:
0x61a80

◆ isAtEnd

- (BOOL) isAtEnd
readnonatomicassign

Whether the cursor has reached or passed the end of the data.

Note
The getter is at 0x61bd8.
Ghidra address:
0x61bd8

◆ scanLocation

- (NSUInteger) scanLocation
readwritenonatomicassign

The cursor's byte offset from the start of the data.

Note
The getter is at 0x61a60 and the setter at 0x61bb8.
Ghidra address:
0x61a60

The documentation for this class was generated from the following files: