Line data Source code
1 0 : /* OOTCPStreamDecoderAbstractionLayer.h 2 : 3 : Abstraction layer to allow OOTCPStreamDecoder to work with CoreFoundation/ 4 : CF-Lite, Cocoa Foundation or GNUstep Foundation. 5 : */ 6 : 7 : #ifndef INCLUDED_OOTCPStreamDecoderAbstractionLayer_h 8 : #define INCLUDED_OOTCPStreamDecoderAbstractionLayer_h 9 : 10 : #ifndef OOTCPSTREAM_USE_COREFOUNDATION 11 0 : #define OOTCPSTREAM_USE_COREFOUNDATION 0 12 : #endif 13 : 14 : #if OOTCPSTREAM_USE_COREFOUNDATION 15 : 16 : #include <CoreFoundation/CoreFoundation.h> 17 : #import "JAAutoreleasePool.h" 18 : 19 : 20 : #define OOALRelease(object) CFRelease(object) 21 : 22 : #define OOTypeDescription(object) JAAutorelease(CFCopyTypeIDDescription(CFGetTypeID(object))) 23 : 24 : 25 : 26 : typedef CFStringRef OOALStringRef; 27 : #define OOALIsString(object) (CFGetTypeID(object) == CFStringGetTypeID()) 28 : 29 : #define OOALSTR(str) CFSTR(str) 30 : 31 : #define OOALStringCreateWithFormatAndArguments(format, args) CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, NULL, format, args) 32 : 33 : 34 : 35 : typedef CFDictionaryRef OOALDictionaryRef; 36 : #define OOALIsDictionary(object) (CFGetTypeID(object) == CFDictionaryGetTypeID()) 37 : 38 : #define OOALDictionaryGetValue(dictionary, key) CFDictionaryGetValue(dictionary, key) 39 : 40 : 41 : 42 : typedef CFDataRef OOALDataRef; 43 : typedef CFMutableDataRef OOALMutableDataRef; 44 : #define OOALIsData(object) (CFGetTypeID(object) == CFDataGetTypeID()) 45 : 46 : #define OOALDataCreateMutable(capacity) CFDataCreateMutable(kCFAllocatorDefault, capacity) 47 : 48 : #define OOALMutableDataAppendBytes(data, bytes, length) CFDataAppendBytes(data, bytes, length) 49 : 50 : #define OOALDataGetBytePtr(data) CFDataGetBytePtr(data) 51 : #define OOALDataGetLength(data) CFDataGetLength(data) 52 : 53 : 54 : 55 : typedef JAAutoreleasePoolRef OOALAutoreleasePoolRef; 56 : 57 : #define OOALCreateAutoreleasePool() JACreateAutoreleasePool() 58 : #define OOALDestroyAutoreleasePool(pool) JADestroyAutoreleasePool(pool) 59 : 60 : 61 : 62 : #define OOALPropertyListFromData(data, errStr) JAAutorelease(CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, kCFPropertyListImmutable, errStr)) 63 : 64 : #else /* !OOTCPSTREAM_USE_COREFOUNDATION */ 65 : 66 : #include <stdarg.h> 67 : #include <stdbool.h> 68 : #include <stdlib.h> 69 : 70 : 71 : #if __OBJC__ 72 : 73 : #import <Foundation/Foundation.h> 74 : 75 : typedef id OOALObjectRef; 76 : 77 : typedef NSString *OOALStringRef; 78 : typedef NSData *OOALDataRef; 79 : typedef NSMutableData *OOALMutableDataRef; 80 : typedef NSDictionary *OOALDictionaryRef; 81 : typedef NSAutoreleasePool *OOALAutoreleasePoolRef; 82 : 83 : #define OOALSTR(x) @""x 84 : 85 : #else 86 : 87 0 : typedef const void *OOALObjectRef; 88 : 89 0 : typedef const struct NSString *OOALStringRef; 90 0 : typedef const struct NSData *OOALDataRef; 91 0 : typedef struct NSData *OOALMutableDataRef; 92 0 : typedef const struct NSDictionary *OOALDictionaryRef; 93 0 : typedef const struct NSAutoreleasePool *OOALAutoreleasePoolRef; 94 : 95 0 : OOALStringRef OOALGetConstantString(const char *string); // Should only be used with string literals! 96 0 : #define OOALSTR(string) OOALGetConstantString("" string "") 97 : 98 : #endif 99 : 100 : 101 0 : void OOALRelease(OOALObjectRef object); 102 0 : OOALStringRef OOTypeDescription(OOALObjectRef object); 103 : 104 0 : bool OOALIsString(OOALObjectRef object); 105 0 : OOALStringRef OOALStringCreateWithFormatAndArguments(OOALStringRef format, va_list args); 106 : 107 0 : bool OOALIsDictionary(OOALObjectRef object); 108 0 : OOALObjectRef OOALDictionaryGetValue(OOALDictionaryRef dictionary, OOALObjectRef key); 109 : 110 0 : bool OOALIsData(OOALObjectRef object); 111 0 : OOALMutableDataRef OOALDataCreateMutable(size_t capacity); 112 0 : void OOALMutableDataAppendBytes(OOALMutableDataRef data, const void *bytes, size_t length); 113 0 : const void *OOALDataGetBytePtr(OOALDataRef data); 114 0 : size_t OOALDataGetLength(OOALDataRef data); 115 : 116 0 : OOALAutoreleasePoolRef OOALCreateAutoreleasePool(void); 117 0 : #define OOALDestroyAutoreleasePool(pool) OOALRelease(pool) 118 : 119 0 : OOALObjectRef OOALPropertyListFromData(OOALMutableDataRef data, OOALStringRef *errStr); 120 : 121 : #endif /* OOTCPSTREAM_USE_COREFOUNDATION */ 122 : #endif /* INCLUDED_OOTCPStreamDecoderAbstractionLayer_h */