mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Documentation added
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14974 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
f6cc9ceb34
commit
e3be05fe04
4 changed files with 205 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
|||
2002-11-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: adocument property list stuff.
|
||||
* Source/NSUserDefaults.m: set integers, floats and bools as NSNumber
|
||||
|
||||
2002-11-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/gnustep/base/NSObject.h: Removed GNUstep plist extensions.
|
||||
|
|
|
@ -3870,11 +3870,194 @@ handle_printf_atsign (FILE *stream,
|
|||
return [super replacementObjectForPortCoder: aCoder];
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Attempts to interpret the receiver as a <em>property list</em>
|
||||
* and returns the result. If the receiver does not contain a
|
||||
* string representation of a <em>property list</em> then the method
|
||||
* returns nil.
|
||||
* </p>
|
||||
* <p>There are three readable <em>property list</em> storage formats -
|
||||
* The binary format used by [NSSerializer] does not concern us here,
|
||||
* but there are two 'human readable' formats, the <em>traditional</em>
|
||||
* OpenStep format (which is extended in GNUstep) and the <em>XML</em> format.
|
||||
* </p>
|
||||
* <p>The [NSArray-descriptionWithLocale:indent:] and
|
||||
* [NSDictionary-descriptionWithLocale:indent:] methods
|
||||
* both generate strings containing traditional style <em>property lists</em>,
|
||||
* but [NSArray-writeToFile:atomically:] and
|
||||
* [NSDictionary-writeToFile:atomically:] generate either traditional or
|
||||
* XML style <em>property lists</em> depending on the value of the
|
||||
* GSMacOSXCompatible and NSWriteOldStylePropertyLists user defaults.<br />
|
||||
* If GSMacOSXCompatible is YES then XML <em>property lists</em> are
|
||||
* written unless NSWriteOldStylePropertyLists is also YES.<br />
|
||||
* By default GNUstep writes old style data and always supports reading of
|
||||
* either style.
|
||||
* </p>
|
||||
* <p>The traditional format is more compact and more easily readable by
|
||||
* people, but (without the GNUstep extensions) cannot represent date and
|
||||
* number objects (except as strings). The XML format is more verbose and
|
||||
* less readable, but can be fed into modern XML tools and thus used to
|
||||
* pass data to non-OpenStep applications more readily.
|
||||
* </p>
|
||||
* <p>The traditional format is strictly ascii encoded, with any unicode
|
||||
* characters represented by escape sequences. The XML format is encoded
|
||||
* as UTF8 data.
|
||||
* </p>
|
||||
* <p>Both the traditional format and the XML format permit comments to be
|
||||
* placed in <em>property list</em> documents. In traditional format the
|
||||
* comment notations used in ObjectiveC programming are supported, while
|
||||
* in XML format, the standard SGML comment sequences are used.
|
||||
* </p>
|
||||
* A <em>property list</em> may only be one of the following classes -
|
||||
* <deflist>
|
||||
* <term>[NSArray]</term>
|
||||
* <desc>
|
||||
* An array which is either empty or contains only <em>property list</em>
|
||||
* objects.<br />
|
||||
* An array is delimited by round brackets and its contents are comma
|
||||
* <em>separated</em> (there is no comma after the last array element).
|
||||
* <example>
|
||||
* ( "one", "two", "three" )
|
||||
* </example>
|
||||
* In XML format, an array is an element whose name is <code>array</code>
|
||||
* and whose content is the array content.
|
||||
* <example>
|
||||
* <array><string>one</string><string>two</string><string>three</string></array>
|
||||
* </example>
|
||||
* </desc>
|
||||
* <term>[NSData]</term>
|
||||
* <desc>
|
||||
* An array is represented as a series of pairs of hexadecimal characters
|
||||
* (each pair representing a byte of data) enclosed in angle brackets.
|
||||
* Spaces are ignored).
|
||||
* <example>
|
||||
* < 54637374 696D67 >
|
||||
* </example>
|
||||
* In XML format, a data object is an element whose name is
|
||||
* <code>data</code> and whose content is a stream of base64 encoded bytes.
|
||||
* </desc>
|
||||
* <term>[NSDate]</term>
|
||||
* <desc>
|
||||
* Date objects were not traditionally allowed in <em>property lists</em>
|
||||
* but were added when the XML format was intoroduced. GNUstep provides
|
||||
* an extension to the traditional <em>property list</em> format to
|
||||
* support date objects, but older code will not read
|
||||
* <em>property lists</em> containing this extension.<br />
|
||||
* This format consists of an asterisk follwed by the letter 'D' then a
|
||||
* date/time in YYYY-MM-DD HH:MM:SS +/-ZZZZ format, all enclosed within
|
||||
* angle brackets.
|
||||
* <example>
|
||||
* <*D2002-03-22 11:30:00 +0100>
|
||||
* </example>
|
||||
* In XML format, a date object is an element whose name is
|
||||
* <code>date</code> and whose content is a date in the above format.
|
||||
* <example>
|
||||
* <date>2002-03-22 11:30:00 +0100</date>
|
||||
* </example>
|
||||
* </desc>
|
||||
* <term>[NSDictionary]</term>
|
||||
* <desc>
|
||||
* A dictionary which is either empty or contains only <em>string</em>
|
||||
* keys and <em>property list</em> objects.<br />
|
||||
* A dictionary is delimited by curly brackets and its contents are
|
||||
* semicolon <em>terminated</em> (there is a semicolon after each value).
|
||||
* Each item in the dictionary is a key/value pair with an equals sign
|
||||
* after the key and before the value.
|
||||
* <example>
|
||||
* {
|
||||
* "key1" = "value1";
|
||||
* }
|
||||
* </example>
|
||||
* In XML format, a dictionary is an element whose name is
|
||||
* <code>dictionary</code> and whose content consists of pairs of
|
||||
* strings and other <em>property list</em> objects.
|
||||
* <example>
|
||||
* <dictionary>
|
||||
* <string>key1</string>
|
||||
* <string>value1</string>
|
||||
* </dictionary>
|
||||
* </example>
|
||||
* </desc>
|
||||
* <term>[NSNumber]</term>
|
||||
* <desc>
|
||||
* Number objects were not traditionally allowed in <em>property lists</em>
|
||||
* but were added when the XML format was intoroduced. GNUstep provides
|
||||
* an extension to the traditional <em>property list</em> format to
|
||||
* support number objects, but older code will not read
|
||||
* <em>property lists</em> containing this extension.<br />
|
||||
* Numbers are stored in a variety of formats depending on their values.
|
||||
* <list>
|
||||
* <item>boolean ... either <code><*BY></code> for YES or
|
||||
* <code><*BN></code> for NO.<br />
|
||||
* In XML format this is either <code><true /></code> or
|
||||
* <code><false /></code>
|
||||
* </item>
|
||||
* <item>integer ... <code><*INNN></code> where NNN is an
|
||||
* integer.<br />
|
||||
* In XML format this is <code><integer>NNN<integer></code>
|
||||
* </item>
|
||||
* <item>real ... <code><*RNNN></code> where NNN is a real
|
||||
* number.<br />
|
||||
* In XML format this is <code><real>NNN<real></code>
|
||||
* </item>
|
||||
* </list>
|
||||
* </desc>
|
||||
* <term>[NSString]</term>
|
||||
* <desc>
|
||||
* A string is either stored literally (if it contains no spaces or special
|
||||
* characters), or is stored as a quoted string with special characters
|
||||
* escaped where necessary.<br />
|
||||
* Escape conventions are similar to those normally used in ObjectiveC
|
||||
* programming, using a backslash followed by -
|
||||
* <list>
|
||||
* <item><strong>\</strong> a backslash character</item>
|
||||
* <item><strong>"</strong> a quote character</item>
|
||||
* <item><strong>b</strong> a backspace character</item>
|
||||
* <item><strong>n</strong> a newline character</item>
|
||||
* <item><strong>r</strong> a carriage return character</item>
|
||||
* <item><strong>t</strong> a tab character</item>
|
||||
* <item><strong>OOO</strong> (three octal digits)
|
||||
* an arbitrary ascii character</item>
|
||||
* <item><strong>UXXXX</strong> (where X is a hexadecimal digit)
|
||||
* a an arbitrary unicode character</item>
|
||||
* </list>
|
||||
* <example>
|
||||
* "hello world & others"
|
||||
* </example>
|
||||
* In XML format, the string is simply stored in UTF8 format as the
|
||||
* content of a <code>string</code> element, and the only character
|
||||
* escapes required are those used by XML such as the
|
||||
* '&lt;' markup representing a '<' character.
|
||||
* <example>
|
||||
* <string>hello world &amp; others</string>"
|
||||
* </example>
|
||||
* </desc>
|
||||
* </deflist>
|
||||
*/
|
||||
- (id) propertyList
|
||||
{
|
||||
return GSPropertyList(self);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Reads a <em>property list</em> (see -propertyList) from a simplified
|
||||
* file format. This format is a traditional style property list file
|
||||
* containing a single dictionary, but with the leading '{' and trailing
|
||||
* '}' characters omitted.
|
||||
* </p>
|
||||
* <p>That is to say, the file contains only semicolon separated key/value
|
||||
* pairs (and optionally comments). As a convenience, it is possible to
|
||||
* omit the equals sign and the value, so an entry consists of a key string
|
||||
* followed by a semicolon. In this case, the value for that key is
|
||||
* assumed to be an empty string.
|
||||
* </p>
|
||||
* <example>
|
||||
* // Strings file entries follow -
|
||||
* key1 = " a string value";
|
||||
* key2; // This key has an empty string as a value.
|
||||
* "Another key" = "a longer string value for th third key";
|
||||
* </example>
|
||||
*/
|
||||
- (NSDictionary*) propertyListFromStringsFileFormat
|
||||
{
|
||||
return GSPropertyListFromStringsFormat(self);
|
||||
|
|
|
@ -998,9 +998,9 @@ static NSString *pathForUser(NSString *user)
|
|||
*/
|
||||
- (void) setBool: (BOOL)value forKey: (NSString*)defaultName
|
||||
{
|
||||
id obj = (value)?@"YES": @"NO";
|
||||
NSNumber *n = [NSNumber numberWithBool: value];
|
||||
|
||||
[self setObject: obj forKey: defaultName];
|
||||
[self setObject: n forKey: defaultName];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1010,10 +1010,9 @@ static NSString *pathForUser(NSString *user)
|
|||
*/
|
||||
- (void) setFloat: (float)value forKey: (NSString*)defaultName
|
||||
{
|
||||
char buf[32];
|
||||
NSNumber *n = [NSNumber numberWithFloat: value];
|
||||
|
||||
sprintf(buf,"%g",value);
|
||||
[self setObject: [NSStringClass stringWithCString: buf] forKey: defaultName];
|
||||
[self setObject: n forKey: defaultName];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1023,10 +1022,9 @@ static NSString *pathForUser(NSString *user)
|
|||
*/
|
||||
- (void) setInteger: (int)value forKey: (NSString*)defaultName
|
||||
{
|
||||
char buf[32];
|
||||
NSNumber *n = [NSNumber numberWithInt: value];
|
||||
|
||||
sprintf(buf,"%d",value);
|
||||
[self setObject: [NSStringClass stringWithCString: buf] forKey: defaultName];
|
||||
[self setObject: n forKey: defaultName];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1085,10 +1083,14 @@ static BOOL isPlistObject(id o)
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets an object value for defaultName in the application domain.
|
||||
* <br />Causes a NSUserDefaultsDidChangeNotification to be posted
|
||||
* Sets an object value for defaultName in the application domain.<br />
|
||||
* The defaultName must be a non-empty string.<br />
|
||||
* The value must be an instance of one of the [NSString-propertyList]
|
||||
* classes.<br />
|
||||
* <p>Causes a NSUserDefaultsDidChangeNotification to be posted
|
||||
* if this is the first change to a persistent-domain since the
|
||||
* last -synchronize.
|
||||
* </p>
|
||||
*/
|
||||
- (void) setObject: (id)value forKey: (NSString*)defaultName
|
||||
{
|
||||
|
|
|
@ -1801,24 +1801,24 @@ NSLog(@"Element '%@' not implemented", name); // FIXME
|
|||
[buf appendString: @"<p>\n"];
|
||||
[self incIndent];
|
||||
}
|
||||
return [node nextElement];
|
||||
return [node next];
|
||||
}
|
||||
else if ([n isEqual: @"example"] == YES)
|
||||
{
|
||||
[buf appendString: @"<pre>\n"];
|
||||
[self outputText: [node firstChild] to: buf];
|
||||
[buf appendString: @"\n</pre>\n"];
|
||||
return [node nextElement];
|
||||
return [node next];
|
||||
}
|
||||
else if ([n isEqual: @"embed"] == YES)
|
||||
{
|
||||
NSLog(@"Element 'embed' not supported");
|
||||
return [node nextElement];
|
||||
return [node next];
|
||||
}
|
||||
else if ([n isEqual: @"index"] == YES)
|
||||
{
|
||||
[self outputNode: node to: buf];
|
||||
return [node nextElement];
|
||||
return [node next];
|
||||
}
|
||||
else if ([textNodes member: n] != nil)
|
||||
{
|
||||
|
@ -1969,7 +1969,7 @@ NSLog(@"Element '%@' not implemented", name); // FIXME
|
|||
{
|
||||
return node; // Not a list
|
||||
}
|
||||
node = [node nextElement];
|
||||
node = [node next];
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue