Oolite
Loading...
Searching...
No Matches
OOPListParsing.h File Reference
import <Foundation/Foundation.h>
Include dependency graph for OOPListParsing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

id OOPropertyListFromData (NSData *data, NSString *whereFrom)
id OOPropertyListFromFile (NSString *path)
NSDictionary * OODictionaryFromData (NSData *data, NSString *whereFrom)
NSDictionary * OODictionaryFromFile (NSString *path)
NSArray * OOArrayFromData (NSData *data, NSString *whereFrom)
NSArray * OOArrayFromFile (NSString *path)

Function Documentation

◆ OOArrayFromData()

NSArray * OOArrayFromData ( NSData * data,
NSString * whereFrom )

Definition at line 213 of file OOPListParsing.m.

214{
215 id result = OOPropertyListFromData(data, whereFrom);
216 return ValueIfClass(result, [NSArray class]);
217}
static id ValueIfClass(id value, Class class)
id OOPropertyListFromData(NSData *data, NSString *whereFrom)

References OOPropertyListFromData(), and ValueIfClass().

Here is the call graph for this function:

◆ OOArrayFromFile()

NSArray * OOArrayFromFile ( NSString * path)

Definition at line 219 of file OOPListParsing.m.

220{
221 id result = OOPropertyListFromFile(path);
222 return ValueIfClass(result, [NSArray class]);
223}
id OOPropertyListFromFile(NSString *path)

References OOPropertyListFromFile(), and ValueIfClass().

Referenced by ResourceManager::arrayFromFilesNamed:inFolder:andMerge:cache:, ResourceManager::checkOXPMessagesInPath:, and OOScript::worldScriptsAtPath:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OODictionaryFromData()

NSDictionary * OODictionaryFromData ( NSData * data,
NSString * whereFrom )

Definition at line 201 of file OOPListParsing.m.

202{
203 id result = OOPropertyListFromData(data, whereFrom);
204 return ValueIfClass(result, [NSDictionary class]);
205}

References OOPropertyListFromData(), and ValueIfClass().

Here is the call graph for this function:

◆ OODictionaryFromFile()

◆ OOPropertyListFromData()

id OOPropertyListFromData ( NSData * data,
NSString * whereFrom )

Definition at line 48 of file OOPListParsing.m.

49{
50 id result = nil;
51 NSString* error = nil;
52
53 if (whereFrom == nil)
54 whereFrom = @"<data in memory>";
55 if (UNIVERSE != nil) {
56 OOLog(kOOLogPListInformation, @"Parsing %@ as a property list.", whereFrom);
57 }
58
59 if (data != nil) {
60#ifndef NO_DYNAMIC_PLIST_DTD_CHANGE
61 data = ChangeDTDIfApplicable(data);
62#endif
63
64 result = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:NULL errorDescription:&error];
65 if (result == nil) // Foundation parser failed
66 {
67#if OOLITE_RELEASE_PLIST_ERROR_STRINGS
68 [error autorelease];
69#endif
70 // Ensure we can say something sensible...
71 if (error == nil)
72 error = @"<no error message>";
73 if (whereFrom == nil)
74 whereFrom = @"<data in memory>";
75
76 OOLog(kOOLogPListFoundationParseError, @"Failed to parse %@ as a property list.\n%@", whereFrom, error);
77 }
78 }
79
80 return result;
81}
#define OOLog(class, format,...)
Definition OOLogging.h:84
static NSString *const kOOLogPListFoundationParseError
static NSString *const kOOLogPListInformation
return nil
#define UNIVERSE
Definition Universe.h:827

References kOOLogPListFoundationParseError, kOOLogPListInformation, nil, OOLog, and UNIVERSE.

Referenced by OOArrayFromData(), OODictionaryFromData(), and OOPropertyListFromFile().

Here is the caller graph for this function:

◆ OOPropertyListFromFile()

id OOPropertyListFromFile ( NSString * path)

Definition at line 83 of file OOPListParsing.m.

84{
85 id result = nil;
86 NSData* data = nil;
87
88 if (path != nil) {
89 // Load file, if it exists...
90 data = CopyDataFromFile(path);
91 if (data != nil) {
92 // ...and parse it
93 result = OOPropertyListFromData(data, path);
94 [data release];
95 }
96 // Non-existent file is not an error.
97 }
98
99 return result;
100}
static NSData * CopyDataFromFile(NSString *path)

References CopyDataFromFile(), nil, and OOPropertyListFromData().

Referenced by OOArrayFromFile(), and OODictionaryFromFile().

Here is the call graph for this function:
Here is the caller graph for this function: