This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
/
TDMultipartDocumentReader.h
59 lines (45 loc) · 1.86 KB
/
TDMultipartDocumentReader.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
//
// TDMultipartDocumentReader.h
//
//
// Created by Jens Alfke on 3/29/12.
// Copyright (c) 2012 Couchbase, Inc. All rights reserved.
//
#import "TDMultipartReader.h"
#import <TouchDB/TDStatus.h>
@class TD_Database, TD_Revision, TDBlobStoreWriter, TDMultipartDocumentReader;
typedef void(^TDMultipartDocumentReaderCompletionBlock)(TDMultipartDocumentReader*);
@interface TDMultipartDocumentReader : NSObject <TDMultipartReaderDelegate, NSStreamDelegate>
{
@private
TD_Database* _database;
TDStatus _status;
TDMultipartReader* _multipartReader;
NSMutableData* _jsonBuffer;
TDBlobStoreWriter* _curAttachment;
NSMutableDictionary* _attachmentsByName; // maps attachment name --> TDBlobStoreWriter
NSMutableDictionary* _attachmentsByDigest; // maps attachment MD5 --> TDBlobStoreWriter
NSMutableDictionary* _document;
TDMultipartDocumentReaderCompletionBlock _completionBlock;
}
// synchronous:
+ (NSDictionary*) readData: (NSData*)data
ofType: (NSString*)contentType
toDatabase: (TD_Database*)database
status: (TDStatus*)outStatus;
// asynchronous:
+ (TDStatus) readStream: (NSInputStream*)stream
ofType: (NSString*)contentType
toDatabase: (TD_Database*)database
then: (TDMultipartDocumentReaderCompletionBlock)completionBlock;
- (id) initWithDatabase: (TD_Database*)database;
@property (readonly, nonatomic) TDStatus status;
@property (readonly, nonatomic) NSDictionary* document;
@property (readonly, nonatomic) NSUInteger attachmentCount;
- (BOOL) setContentType: (NSString*)contentType;
- (BOOL) appendData: (NSData*)data;
- (TDStatus) readStream: (NSInputStream*)stream
ofType: (NSString*)contentType
then: (TDMultipartDocumentReaderCompletionBlock)completionBlock;
- (BOOL) finish;
@end