-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathMessagePackParser.h
41 lines (33 loc) · 1.24 KB
/
MessagePackParser.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
//
// MessagePackParser.h
// Fetch TV Remote
//
// Created by Chris Hulbert on 23/06/11.
// Copyright 2011 Digital Five. All rights reserved.
//
#import <Foundation/Foundation.h>
#include "msgpack_src/msgpack.h"
typedef enum
{
MPRawsAsNSString_NSNullOnFail,
MPRawsAsNSString_NSDataOnFail,
MPRawsAsNSString_ExceptionOnFail,
MPRawsAsNSData,
} MPRawHandling;
@interface MessagePackParser : NSObject {
// This is only for MessagePackParser+Streaming category.
msgpack_unpacker unpacker;
}
//parse the data into an NSObject. handle raw bytes as specified:
// - MPRawsAsNSString_ExceptionOnFail: try to decode the bytes with utf8.
// if the decoding fails, raise an exception
// - MPRawsAsNSString_NSNullOnFail: try to decode the bytes with utf8.
// if the decoding fails, put an NSNull in that part of the message.
// - MPRawsAsNSString_NSDataOnFail: try to decode the bytes with utf8.
// if the decoding fails, put an NSData in that part of the message.
// - MPRawsAsNSData: always leave bytes as they are, leaving them as
// NSDatas.
+ (id)parseData:(NSData*)data rawHandling:(MPRawHandling)rawHandling;
//parse the data into an NSObject, handling raws with MPRawsAsNSString_ExceptionOnFail
+ (id)parseData:(NSData*)data;
@end