mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-27 02:30:53 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9698 72102866-910b-0410-8b05-ffd578937521
334 lines
12 KiB
HTML
334 lines
12 KiB
HTML
<html><head>
|
|
<title>NSScanner</title>
|
|
</head>
|
|
<body>
|
|
<a href ="NSRunLoop.html">[Previous] </a>
|
|
<a href ="Base.html">[Up] </a>
|
|
<a href ="NSSerializer.html">[Next] </a>
|
|
<h1>NSScanner</h1>
|
|
<h3>Authors </h3>
|
|
<dl>
|
|
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
|
|
<dd>
|
|
</dl>
|
|
<p>Version: $Revision$</p>
|
|
<p>Date: $Date$</p>
|
|
<h2><a name ="cont-0">The NSScanner class documentation</a></h2>
|
|
<h2><a name ="NSScanner">NSScanner</a></h2>
|
|
<p><b>Declared in: </b> Foundation/NSScanner.h</p>
|
|
<p><b>Inherits from: </b> NSObject</p>
|
|
<p><b>Conforms to: </b> NSCopying
|
|
</p>
|
|
<hr>
|
|
|
|
<p>
|
|
|
|
The NSScanner class cluster (currently a single class in GNUstep)
|
|
provides a mechanism to parse the contents of a string into number
|
|
and string values by making a sequence of scan operations to
|
|
step through the string retrieving successive items.
|
|
</p>
|
|
|
|
<p>
|
|
|
|
You can tell the scanner whether its scanning is supposed to be
|
|
case sensitive or not, and you can specify a set of characters
|
|
to be skipped before each scanning operation (by default,
|
|
whitespace and newlines).
|
|
</p>
|
|
|
|
|
|
<h2>Instance Variables </h2>
|
|
<ul>
|
|
</ul>
|
|
<h2>Methods </h2>
|
|
<ul>
|
|
<li ><a href ="NSScanner.html#method-0">+localizedScannerWithString:</a>
|
|
<li ><a href ="NSScanner.html#method-1">+scannerWithString:</a>
|
|
<li ><a href ="NSScanner.html#method-2">-caseSensitive</a>
|
|
<li ><a href ="NSScanner.html#method-3">-charactersToBeSkipped</a>
|
|
<li ><a href ="NSScanner.html#initWithString:">-initWithString:</a>
|
|
<li ><a href ="NSScanner.html#method-4">-isAtEnd</a>
|
|
<li ><a href ="NSScanner.html#method-5">-locale</a>
|
|
<li ><a href ="NSScanner.html#method-6">-scanCharactersFromSet:intoString:</a>
|
|
<li ><a href ="NSScanner.html#method-7">-scanDecimal:</a>
|
|
<li ><a href ="NSScanner.html#method-8">-scanDouble:</a>
|
|
<li ><a href ="NSScanner.html#method-9">-scanFloat:</a>
|
|
<li ><a href ="NSScanner.html#method-10">-scanHexInt:</a>
|
|
<li ><a href ="NSScanner.html#method-11">-scanInt:</a>
|
|
<li ><a href ="NSScanner.html#method-12">-scanLocation</a>
|
|
<li ><a href ="NSScanner.html#method-13">-scanLongLong:</a>
|
|
<li ><a href ="NSScanner.html#method-14">-scanRadixUnsignedInt:</a>
|
|
<li ><a href ="NSScanner.html#method-15">-scanString:intoString:</a>
|
|
<li ><a href ="NSScanner.html#method-16">-scanUpToCharactersFromSet:intoString:</a>
|
|
<li ><a href ="NSScanner.html#method-17">-scanUpToString:intoString:</a>
|
|
<li ><a href ="NSScanner.html#method-18">-setCaseSensitive:</a>
|
|
<li ><a href ="NSScanner.html#method-19">-setCharactersToBeSkipped:</a>
|
|
<li ><a href ="NSScanner.html#setLocale:">-setLocale:</a>
|
|
<li ><a href ="NSScanner.html#method-20">-setScanLocation:</a>
|
|
<li ><a href ="NSScanner.html#method-21">-string</a>
|
|
</ul>
|
|
<hr><h2>Class Methods </h2>
|
|
<h3><a name ="method-0">localizedScannerWithString:</a></h3>
|
|
+ (id) <b>localizedScannerWithString:</b> (NSString*)aString;<br>
|
|
|
|
Returns an NSScanner instance set up to scan aString
|
|
(using <a href ="#initWithString:">initWithString:</a>)
|
|
and with a locale set the default locale
|
|
(using <a href ="#setLocale:">setLocale:</a>).
|
|
|
|
<hr>
|
|
<h3><a name ="method-1">scannerWithString:</a></h3>
|
|
+ (id) <b>scannerWithString:</b> (NSString*)aString;<br>
|
|
|
|
Returns an NSScanner instance set up to scan aString
|
|
(using <a href ="#initWithString:">initWithString:</a>)
|
|
and with no locale set.
|
|
|
|
<hr>
|
|
<hr><h2>Instances Methods </h2>
|
|
<h3><a name ="method-2">caseSensitive</a></h3>
|
|
- (BOOL) <b>caseSensitive</b>;<br>
|
|
|
|
If the scanner is set to be case-sensitive in its scanning of
|
|
the string (other than characters to be skipped), this method
|
|
returns YES, otherwise it returns NO.
|
|
<br>
|
|
The default is for a scanner to <em>not</em> be case sensitive.
|
|
|
|
<hr>
|
|
<h3><a name ="method-3">charactersToBeSkipped</a></h3>
|
|
- (NSCharacterSet*) <b>charactersToBeSkipped</b>;<br>
|
|
|
|
Returns a set of characters containing those characters that the
|
|
scanner ignores when starting any scan operation. Once a character
|
|
not in this set has been encountered during an operation, skipping
|
|
is finished, and any further characters from this set that are
|
|
found are scanned normally.
|
|
<br>
|
|
The default for this is the whitespaceAndNewlineCharacterSet.
|
|
|
|
<hr>
|
|
<h3><a name ="initWithString:">initWithString:</a></h3>
|
|
<b>This is the designated initialiser </b><br>
|
|
- (id) <b>initWithString:</b> (NSString*)aString;<br>
|
|
|
|
Initialises the scanner to scan aString. The GNUstep
|
|
implementation may make an internal copy of the original
|
|
string - so it is not safe to assume that if you modify a
|
|
mutable string that you initialised a scanner with, the changes
|
|
will be visible to the scanner.
|
|
<br>
|
|
Returns the scanner object.
|
|
|
|
<hr>
|
|
<h3><a name ="method-4">isAtEnd</a></h3>
|
|
- (BOOL) <b>isAtEnd</b>;<br>
|
|
|
|
Returns YES if there are no characters left to be scanned in the
|
|
string (or if all the characters that are left are in the set of
|
|
characters to be skipped). Returns NO otherwise.
|
|
|
|
<hr>
|
|
<h3><a name ="method-5">locale</a></h3>
|
|
- (NSDictionary*) <b>locale</b>;<br>
|
|
|
|
Returns the locale set for the scanner, or nil if no locale has
|
|
been set. A scanner uses it's locale to alter the way it handles
|
|
scanning - it uses the NSDecimalSeparator value for scanning
|
|
numbers.
|
|
|
|
<hr>
|
|
<h3><a name ="method-6">scanCharactersFromSet:intoString:</a></h3>
|
|
- (BOOL) <b>scanCharactersFromSet:</b> (NSCharacterSet*)set <b>intoString:</b> (NSString**)stringValue;<br>
|
|
|
|
After initial skipping (if any), this method scans any characters
|
|
from <em>set</em>, terminating when a character not in the set
|
|
is found.
|
|
Returns YES if any character is scanned, NO otherwise.
|
|
If <em>stringValue</em> is not null, any character scanned are
|
|
stored in a string returned in this value.
|
|
|
|
<hr>
|
|
<h3><a name ="method-7">scanDecimal:</a></h3>
|
|
- (BOOL) <b>scanDecimal:</b> (NSDecimal*)decimalValue;<br>
|
|
Standards: MacOS-X NotOpenStep<br>
|
|
|
|
Not implemented.
|
|
|
|
<hr>
|
|
<h3><a name ="method-8">scanDouble:</a></h3>
|
|
- (BOOL) <b>scanDouble:</b> (double*)doubleValue;<br>
|
|
|
|
After initial skipping (if any), this method scans a double value,
|
|
placing it in <em>doubleValue</em> if that is not null.
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, HUGE_VAL or -HUGE_VAL is put into <em>doubleValue</em>
|
|
<br>
|
|
On underflow, 0.0 is put into <em>doubleValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-9">scanFloat:</a></h3>
|
|
- (BOOL) <b>scanFloat:</b> (float*)floatValue;<br>
|
|
|
|
After initial skipping (if any), this method scans a float value,
|
|
placing it in <em>floatValue</em> if that is not null.
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, HUGE_VAL or -HUGE_VAL is put into <em>floatValue</em>
|
|
<br>
|
|
On underflow, 0.0 is put into <em>floatValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-10">scanHexInt:</a></h3>
|
|
- (BOOL) <b>scanHexInt:</b> (unsigned int*)intValue;<br>
|
|
|
|
After initial skipping (if any), this method scans a hexadecimal
|
|
integer value (optionally prefixed by "0x" or "0X"),
|
|
placing it in <em>intValue</em> if that is not null.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, INT_MAX or INT_MIN is put into <em>intValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-11">scanInt:</a></h3>
|
|
- (BOOL) <b>scanInt:</b> (int*)intValue;<br>
|
|
|
|
After initial skipping (if any), this method scans a integer value,
|
|
placing it in <em>intValue</em> if that is not null.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, INT_MAX or INT_MIN is put into <em>intValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-12">scanLocation</a></h3>
|
|
- (unsigned int) <b>scanLocation</b>;<br>
|
|
|
|
Returns the current position that the scanner has reached in
|
|
scanning the string. This is the position at which the next scan
|
|
operation will begin.
|
|
|
|
<hr>
|
|
<h3><a name ="method-13">scanLongLong:</a></h3>
|
|
- (BOOL) <b>scanLongLong:</b> (longlong*)longLongValue;<br>
|
|
|
|
After initial skipping (if any), this method scans a long
|
|
decimal integer value placing it in <em>longLongValue</em> if that
|
|
is not null.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, LONG_LONG_MAX or LONG_LONG_MIN is put into
|
|
<em>longLongValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-14">scanRadixUnsignedInt:</a></h3>
|
|
- (BOOL) <b>scanRadixUnsignedInt:</b> (unsigned int*)intValue;<br>
|
|
Standards: GNUstep NotOpenStep NotMacOS-X<br>
|
|
|
|
After initial skipping (if any), this method scans an unsigned
|
|
integer value placing it in <em>intValue</em> if that is not null.
|
|
If the number begins with "0x" or "0X" it is treated as hexadecimal,
|
|
otherwise if the number begins with "0" it is treated as octal,
|
|
otherwise the number is treated as decimal.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
<br>
|
|
On overflow, INT_MAX or INT_MIN is put into <em>intValue</em>
|
|
<br>
|
|
Scans past any excess digits
|
|
|
|
<hr>
|
|
<h3><a name ="method-15">scanString:intoString:</a></h3>
|
|
- (BOOL) <b>scanString:</b> (NSString*)aString <b>intoString:</b> (NSString**)stringValue;<br>
|
|
|
|
After initial skipping (if any), this method scans for
|
|
<em>aString</em> and places the string ound in <em>stringValue</em>
|
|
if that is not null.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
|
|
<hr>
|
|
<h3><a name ="method-16">scanUpToCharactersFromSet:intoString:</a></h3>
|
|
- (BOOL) <b>scanUpToCharactersFromSet:</b> (NSCharacterSet*)set <b>intoString:</b> (NSString**)stringValue;<br>
|
|
|
|
After initial skipping (if any), this method scans characters until
|
|
it finds one in <em>set</em>. The scanned characters are placed in
|
|
<em>stringValue</em> if that is not null.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
|
|
<hr>
|
|
<h3><a name ="method-17">scanUpToString:intoString:</a></h3>
|
|
- (BOOL) <b>scanUpToString:</b> (NSString*)aString <b>intoString:</b> (NSString**)stringValue;<br>
|
|
|
|
After initial skipping (if any), this method scans characters until
|
|
it finds <em>aString</em>. The scanned characters are placed in
|
|
<em>stringValue</em> if that is not null. If <em>aString</em> is
|
|
not found, all the characters up to the end of the scanned string
|
|
will be returned.
|
|
<br>
|
|
Returns YES if anything is scanned, NO otherwise.
|
|
|
|
<hr>
|
|
<h3><a name ="method-18">setCaseSensitive:</a></h3>
|
|
- (void) <b>setCaseSensitive:</b> (BOOL)flag;<br>
|
|
|
|
Sets the case sensitivity of the scanner.
|
|
<br>
|
|
Case sensitivity governs matrching of characters being scanned,
|
|
but does not effect the characters in the set to be skipped.
|
|
<br>
|
|
The default is for a scanner to <em>not</em> be case sensitive.
|
|
|
|
<hr>
|
|
<h3><a name ="method-19">setCharactersToBeSkipped:</a></h3>
|
|
- (void) <b>setCharactersToBeSkipped:</b> (NSCharacterSet*)skipSet;<br>
|
|
|
|
Sets the set of characters that the scanner will skip over at the
|
|
start of each scanning operation to be <em>skipSet</em>.
|
|
Skipping is performed by literal character matchins - the case
|
|
sensitivity of the scanner does not effect it.
|
|
If this is set to nil, no skipping is done.
|
|
<br>
|
|
The default for this is the whitespaceAndNewlineCharacterSet.
|
|
|
|
<hr>
|
|
<h3><a name ="setLocale:">setLocale:</a></h3>
|
|
- (void) <b>setLocale:</b> (NSDictionary*)aLocale;<br>
|
|
|
|
This method sets the locale used by the scanner to <em>aLocale</em>.
|
|
The locale may be set to nil.
|
|
|
|
<hr>
|
|
<h3><a name ="method-20">setScanLocation:</a></h3>
|
|
- (void) <b>setScanLocation:</b> (unsigned int)index;<br>
|
|
|
|
This method sets the location in the scanned string at which the
|
|
next scan operation begins.
|
|
Raises an NSRangeException if index is beyond the end of the
|
|
scanned string.
|
|
|
|
<hr>
|
|
<h3><a name ="method-21">string</a></h3>
|
|
- (NSString*) <b>string</b>;<br>
|
|
|
|
Returns the string used by the scanner.
|
|
|
|
<hr>
|
|
</body>
|
|
|
|
</html>
|