quakeforge/ruamoko/include/PropertyList.h
Bill Currie 7a478b4ce7 [libr] Make PLItem more useful
I can't say that I like what's there even now, but at least PLItem can
be used without a lot of casting. Really, Ruamoko needs dictionary and
string classes so reading a property list can build more natural object
trees rather than this mess from when I knew too little.
2020-07-05 16:53:35 +09:00

63 lines
1.2 KiB
Objective-C

#ifndef __ruamoko_PropertyList_h
#define __ruamoko_PropertyList_h
#include <plist.h>
#include <Object.h>
@class PLItem;
@protocol PLDictionary
- (int) count;
- (int) numKeys;
- (PLItem *) getObjectForKey:(string) key;
- (PLItem *) allKeys;
- addKey:(string) key value:(PLItem *) value;
@end
@protocol PLArray
- (int) count;
- (int) numObjects;
- (PLItem *) getObjectAtIndex:(int) index;
- addObject:(PLItem *) object;
- insertObject:(PLItem *) object atIndex:(int) index;
@end
@protocol PLString
- (string) string;
@end
@interface PLItem: Object <PLDictionary, PLArray, PLString>
{
plitem_t item;
int own;
}
+ (PLItem *) newDictionary;
+ (PLItem *) newArray;
+ (PLItem *) newData:(void*) data size:(int) len;
+ (PLItem *) newString:(string) str;
+ (PLItem *) fromString:(string) str;
+ (PLItem *) fromFile:(QFile) file;
- initWithItem:(plitem_t) item;
- initWithOwnItem:(plitem_t) item;
- (string) write;
- (pltype_t) type;
@end
@interface PLDictionary: PLItem <PLDictionary>
+ (PLDictionary *) new;
@end
@interface PLArray: PLItem <PLArray>
+ (PLArray *) new;
@end
@interface PLData: PLItem
+ (PLData *) new:(void*) data size:(int) len;
@end
@interface PLString: PLItem <PLString>
+ (PLString *) new:(string) str;
@end
#endif//__ruamoko_PropertyList_h