Oolite
Loading...
Searching...
No Matches
OOTCPStreamDecoderAbstractionLayer.h
Go to the documentation of this file.
1/* OOTCPStreamDecoderAbstractionLayer.h
2
3Abstraction layer to allow OOTCPStreamDecoder to work with CoreFoundation/
4CF-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#define OOTCPSTREAM_USE_COREFOUNDATION 0
12#endif
13
14#if OOTCPSTREAM_USE_COREFOUNDATION
15
16#import "JAAutoreleasePool.h"
17#include <CoreFoundation/CoreFoundation.h>
18
19#define OOALRelease(object) CFRelease(object)
20
21#define OOTypeDescription(object) JAAutorelease(CFCopyTypeIDDescription(CFGetTypeID(object)))
22
23typedef CFStringRef OOALStringRef;
24#define OOALIsString(object) (CFGetTypeID(object) == CFStringGetTypeID())
25
26#define OOALSTR(str) CFSTR(str)
27
28#define OOALStringCreateWithFormatAndArguments(format, args) CFStringCreateWithFormatAndArguments(kCFAllocatorDefault, NULL, format, args)
29
30typedef CFDictionaryRef OOALDictionaryRef;
31#define OOALIsDictionary(object) (CFGetTypeID(object) == CFDictionaryGetTypeID())
32
33#define OOALDictionaryGetValue(dictionary, key) CFDictionaryGetValue(dictionary, key)
34
35typedef CFDataRef OOALDataRef;
36typedef CFMutableDataRef OOALMutableDataRef;
37#define OOALIsData(object) (CFGetTypeID(object) == CFDataGetTypeID())
38
39#define OOALDataCreateMutable(capacity) CFDataCreateMutable(kCFAllocatorDefault, capacity)
40
41#define OOALMutableDataAppendBytes(data, bytes, length) CFDataAppendBytes(data, bytes, length)
42
43#define OOALDataGetBytePtr(data) CFDataGetBytePtr(data)
44#define OOALDataGetLength(data) CFDataGetLength(data)
45
46typedef JAAutoreleasePoolRef OOALAutoreleasePoolRef;
47
48#define OOALCreateAutoreleasePool() JACreateAutoreleasePool()
49#define OOALDestroyAutoreleasePool(pool) JADestroyAutoreleasePool(pool)
50
51#define OOALPropertyListFromData(data, errStr) JAAutorelease(CFPropertyListCreateFromXMLData(kCFAllocatorDefault, data, kCFPropertyListImmutable, errStr))
52
53#else /* !OOTCPSTREAM_USE_COREFOUNDATION */
54
55#include <stdarg.h>
56#include <stdbool.h>
57#include <stdlib.h>
58
59#if __OBJC__
60
61#import <Foundation/Foundation.h>
62
63typedef id OOALObjectRef;
64
65typedef NSString* OOALStringRef;
66typedef NSData* OOALDataRef;
67typedef NSMutableData* OOALMutableDataRef;
68typedef NSDictionary* OOALDictionaryRef;
69typedef NSAutoreleasePool* OOALAutoreleasePoolRef;
70
71#define OOALSTR(x) @"" x
72
73#else
74
75typedef const void* OOALObjectRef;
76
77typedef const struct NSString* OOALStringRef;
78typedef const struct NSData* OOALDataRef;
79typedef struct NSData* OOALMutableDataRef;
80typedef const struct NSDictionary* OOALDictionaryRef;
81typedef const struct NSAutoreleasePool* OOALAutoreleasePoolRef;
82
83OOALStringRef OOALGetConstantString(const char* string); // Should only be used with string literals!
84#define OOALSTR(string) OOALGetConstantString("" string "")
85
86#endif
87
90
93
96
99void OOALMutableDataAppendBytes(OOALMutableDataRef data, const void* bytes, size_t length);
102
104#define OOALDestroyAutoreleasePool(pool) OOALRelease(pool)
105
107
108#endif /* OOTCPSTREAM_USE_COREFOUNDATION */
109#endif /* INCLUDED_OOTCPStreamDecoderAbstractionLayer_h */
OOALStringRef OOTypeDescription(OOALObjectRef object)
bool OOALIsDictionary(OOALObjectRef object)
OOALStringRef OOALStringCreateWithFormatAndArguments(OOALStringRef format, va_list args)
const struct NSAutoreleasePool * OOALAutoreleasePoolRef
void OOALMutableDataAppendBytes(OOALMutableDataRef data, const void *bytes, size_t length)
const void * OOALDataGetBytePtr(OOALDataRef data)
const struct NSString * OOALStringRef
size_t OOALDataGetLength(OOALDataRef data)
const void * OOALObjectRef
OOALObjectRef OOALDictionaryGetValue(OOALDictionaryRef dictionary, OOALObjectRef key)
bool OOALIsData(OOALObjectRef object)
OOALStringRef OOALGetConstantString(const char *string)
const struct NSDictionary * OOALDictionaryRef
bool OOALIsString(OOALObjectRef object)
OOALAutoreleasePoolRef OOALCreateAutoreleasePool(void)
struct NSData * OOALMutableDataRef
OOALMutableDataRef OOALDataCreateMutable(size_t capacity)
void OOALRelease(OOALObjectRef object)
OOALObjectRef OOALPropertyListFromData(OOALMutableDataRef data, OOALStringRef *errStr)
const struct NSData * OOALDataRef