forked from mirek/YAML.framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
YAMLSerialization.h
113 lines (88 loc) · 4.46 KB
/
YAMLSerialization.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// YAMLSerialization.h
// YAML Serialization support by Mirek Rusin based on C library LibYAML by Kirill Simonov
// Released under MIT License
//
// Copyright 2010 Mirek Rusin
// Copyright 2010 Stanislav Yudin
//
#import <Foundation/Foundation.h>
// Mimics NSPropertyListMutabilityOptions
typedef enum {
kYAMLReadOptionImmutable = 0x0000000000000001,
kYAMLReadOptionMutableContainers = 0x0000000000000010,
kYAMLReadOptionMutableContainersAndLeaves = 0x0000000000000110,
kYAMLReadOptionStringScalars = 0x0000000000001000
} YAMLReadOptions;
typedef enum {
kYAMLErrorNoErrors,
kYAMLErrorCodeParserInitializationFailed,
kYAMLErrorCodeParseError,
kYAMLErrorCodeEmitterError,
kYAMLErrorInvalidOptions,
kYAMLErrorCodeOutOfMemory,
kYAMLErrorInvalidYamlObject,
} YAMLErrorCode;
typedef enum {
kYAMLWriteOptionSingleDocument = 0x0000000000000001,
kYAMLWriteOptionMultipleDocuments = 0x0000000000000010,
} YAMLWriteOptions;
extern NSString *const YAMLErrorDomain;
@interface YAMLSerialization : NSObject
#pragma mark YAML reading
// Returns all document objects from parsed YAML stream.
+ (NSMutableArray *) objectsWithYAMLStream: (NSInputStream *) stream
options: (YAMLReadOptions) opt
error: (NSError **) error;
// Returns all document objects from parsed YAML data.
+ (NSMutableArray *) objectsWithYAMLData: (NSData *) data
options: (YAMLReadOptions) opt
error: (NSError **) error;
// Returns all document objects from parsed YAML string.
+ (NSMutableArray *) objectsWithYAMLString: (NSString *) string
options: (YAMLReadOptions) opt
error: (NSError **) error;
// Returns first object from parsed YAML stream.
+ (id) objectWithYAMLStream: (NSInputStream *) stream
options: (YAMLReadOptions) opt
error: (NSError **) error;
// Returns first object from parsed YAML data.
+ (id) objectWithYAMLData: (NSData *) data
options: (YAMLReadOptions) opt
error: (NSError **) error;
// Returns first object from parsed YAML string.
+ (id) objectWithYAMLString: (NSString *) string
options: (YAMLReadOptions) opt
error: (NSError **) error;
#pragma mark Writing YAML
// Returns YES on success, NO otherwise.
+ (BOOL) writeObject: (id) object
toYAMLStream: (NSOutputStream *) stream
options: (YAMLWriteOptions) opt
error: (NSError **) error;
// Caller is responsible for releasing returned object.
+ (NSData *) createYAMLDataWithObject: (id) object
options: (YAMLWriteOptions) opt
error: (NSError **) error NS_RETURNS_RETAINED;
// Returns autoreleased object.
+ (NSData *) YAMLDataWithObject: (id) object
options: (YAMLWriteOptions) opt
error: (NSError **) error;
// Caller is responsible for releasing returned object.
+ (NSString *) createYAMLStringWithObject: (id) object
options: (YAMLWriteOptions) opt
error: (NSError **) error NS_RETURNS_RETAINED;
// Returns autoreleased object.
+ (NSString *) YAMLStringWithObject: (id) object
options: (YAMLWriteOptions) opt
error: (NSError **) error;
#pragma mark Deprecated
// Deprecated, use objectsWithYAMLStream:options:error or objectWithYAMLStream:options:error instead.
+ (NSMutableArray *) YAMLWithStream: (NSInputStream *) stream options: (YAMLReadOptions) opt error: (NSError **) error __attribute__((deprecated));
// Deprecated, use objectsWithYAMLData:options:error or objectWithYAMLData:options:error instead.
+ (NSMutableArray *) YAMLWithData: (NSData *) data options: (YAMLReadOptions) opt error: (NSError **) error __attribute__((deprecated));
// Deprecated, use YAMLDataWithObject:options:error or createYAMLDataWithObject:options:error instead.
+ (NSData *) dataFromYAML: (id) object options: (YAMLWriteOptions) opt error: (NSError **) error __attribute__((deprecated));
// Deprecated, use writeYAMLObject:toStream:options:error instead.
+ (BOOL) writeYAML: (id) object toStream: (NSOutputStream *) stream options: (YAMLWriteOptions) opt error: (NSError **) error __attribute__((deprecated));
@end