Oolite 1.91.0.7646-241128-10e222e
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#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
26typedef 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
35typedef CFDictionaryRef OOALDictionaryRef;
36#define OOALIsDictionary(object) (CFGetTypeID(object) == CFDictionaryGetTypeID())
37
38#define OOALDictionaryGetValue(dictionary, key) CFDictionaryGetValue(dictionary, key)
39
40
41
42typedef CFDataRef OOALDataRef;
43typedef 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
55typedef 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
75typedef id OOALObjectRef;
76
77typedef NSString *OOALStringRef;
78typedef NSData *OOALDataRef;
79typedef NSMutableData *OOALMutableDataRef;
80typedef NSDictionary *OOALDictionaryRef;
81typedef NSAutoreleasePool *OOALAutoreleasePoolRef;
82
83#define OOALSTR(x) @""x
84
85#else
86
87typedef const void *OOALObjectRef;
88
89typedef const struct NSString *OOALStringRef;
90typedef const struct NSData *OOALDataRef;
91typedef struct NSData *OOALMutableDataRef;
92typedef const struct NSDictionary *OOALDictionaryRef;
93typedef const struct NSAutoreleasePool *OOALAutoreleasePoolRef;
94
95OOALStringRef OOALGetConstantString(const char *string); // Should only be used with string literals!
96#define OOALSTR(string) OOALGetConstantString("" string "")
97
98#endif
99
100
101void OOALRelease(OOALObjectRef object);
103
104bool OOALIsString(OOALObjectRef object);
106
109
110bool OOALIsData(OOALObjectRef object);
112void OOALMutableDataAppendBytes(OOALMutableDataRef data, const void *bytes, size_t length);
113const void *OOALDataGetBytePtr(OOALDataRef data);
114size_t OOALDataGetLength(OOALDataRef data);
115
117#define OOALDestroyAutoreleasePool(pool) OOALRelease(pool)
118
120
121#endif /* OOTCPSTREAM_USE_COREFOUNDATION */
122#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