Reads tokens, one at a time, from a string or a stream. More...
#import <Foundation/Foundation.h>


Instance Methods | |
| (id) | - initWithString:flags: |
| Initializes a scanner which reads a string. | |
| (id) | - initWithStream:flags: |
| Initializes a scanner which reads a stream, from its position. | |
| (NXStream *) | - stream |
| Returns the stream which is read. | |
| (BOOL) | - next |
| Moves to the next token. More... | |
| (NXScannerClass) | - tokenClass |
| Returns the class of the token, or NXScannerClassOther if there isn't one. | |
| (NXString *) | - token |
| Returns the token, or nil if there isn't one or there isn't enough memory. More... | |
| (size_t) | - tokenLength |
| Returns the length of the token in bytes, or zero if there isn't one. | |
| (size_t) | - tokenRuneCount |
| Returns the number of characters in the token, or zero if there isn't one. | |
| (size_t) | - tokenPosition |
| Returns the position of the token in the stream, or NXNotFound if there isn't one. | |
Instance Methods inherited from NXObject | |
| (void) | - dealloc |
| Frees the instance. More... | |
| (NXZone *) | - zone |
| Returns the zone in which the instance was allocated. More... | |
| (id) | - retain |
| Increases the retain count of the receiver. More... | |
| (void) | - release |
| Decreases the retain count of the receiver. More... | |
| (id) | - autorelease |
| Releases the receiver later, when the current autorelease pool of the thread is drained. More... | |
| (id) | - copy |
| Returns a copy which can't be changed by anything else, which the caller owns and has to release. More... | |
| (uintptr_t) | - hash |
| Returns a number for the object, which is the same for objects which are equal by isEqual:. More... | |
| (NXString *) | - description |
| Returns a string which describes the instance, for logging. More... | |
Instance Methods inherited from Object | |
| (id) | - init |
| Initialize the instance, after allocation. More... | |
| (Class) | - class |
| Returns the class of the instance. More... | |
| (Class) | - superclass |
| Returns the superclass of the instance. More... | |
| (BOOL) | - isEqual: |
| Compares the receiver to another object for equality. More... | |
| (BOOL) | - isKindOfClass: |
| Returns a Boolean value that indicates whether the receiver is an instance of a given class. More... | |
| (BOOL) | - conformsTo: |
| Checks if the receiver's class conforms to a protocol. More... | |
Instance Methods inherited from <ObjectProtocol> | |
| (BOOL) | - respondsToSelector: |
| Checks if the receiver responds to a selector. More... | |
Class Methods | |
| (id) | + scannerWithString:flags: |
| Returns a scanner which reads a string. More... | |
| (id) | + scannerWithStream:flags: |
| Returns a scanner which reads a stream, from its position. More... | |
Class Methods inherited from NXObject | |
| (id) | + alloc |
| Allocates a new instance in the default zone, or if there isn't one, with sys_calloc(). More... | |
| (id) | + allocWithZone: |
| Allocates a new instance in a specific zone. More... | |
| (id) | + new |
| Allocates and initializes a new instance, as [[cls alloc] init] does. More... | |
| (NXString *) | + description |
| Returns the name of the class. | |
Class Methods inherited from Object | |
| (void) | + initialize |
| Performs one-time initialization for the class. More... | |
| (Class) | + class |
| Returns the class object. More... | |
| (Class) | + superclass |
| Returns the superclass of the class. More... | |
| (const char *) | + name |
| Returns the name of the class. More... | |
| (BOOL) | + conformsTo: |
| Checks if the class conforms to a protocol. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Object | |
| Class | isa |
| A pointer to the object's class structure. More... | |
Reads tokens, one at a time, from a string or a stream.
The stream must have a position, as the scanner looks ahead and goes back. It starts at the stream's position, and after each token the stream is just after it, so the stream can be read between tokens, and the scanner carries on from wherever it is.
A string which isn't closed by its quote runs to the end. It's only closed if it's at least two bytes, ends with the quote it starts with, and that quote doesn't have an odd number of backslashes before it, which would escape it. The stream shouldn't have a zero byte, which picofuse doesn't scan correctly.
Example:
A scanner is used by one thread at a time. See Threads and mutable objects.
Definition at line 97 of file NXScanner.h.
| - (BOOL) next |
Moves to the next token.
| + (id) scannerWithStream: | (NXStream *) | stream | |
| flags: | (NXScannerFlags) | flags | |
Returns a scanner which reads a stream, from its position.
| + (id) scannerWithString: | (NXString *) | string | |
| flags: | (NXScannerFlags) | flags | |
Returns a scanner which reads a string.
| - (NXString *) token |
Returns the token, or nil if there isn't one or there isn't enough memory.
It stops at a zero byte.