Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (112 sloc) 4.6 KB
// TDInternal.h
// TouchDB
// Created by Jens Alfke on 12/8/11.
// Copyright (c) 2011 Couchbase, Inc. All rights reserved.
#import <TouchDB/TD_Database.h>
#import "TD_Database+Attachments.h"
#import "TD_DatabaseManager.h"
#import "TD_View.h"
#import "TD_Server.h"
#import "TDRouter.h"
#import "TDReplicator.h"
#import "TDRemoteRequest.h"
#import "TDBlobStore.h"
@class TD_Attachment;
@interface TD_Database ()
@property (readwrite, copy) NSString* name; // make it settable
@property (readonly) FMDatabase* fmdb;
@property (readonly) TDBlobStore* attachmentStore;
- (BOOL) openFMDB;
- (SInt64) getDocNumericID: (NSString*)docID;
- (SequenceNumber) getSequenceOfDocument: (SInt64)docNumericID
revision: (NSString*)revID
onlyCurrent: (BOOL)onlyCurrent;
- (TD_RevisionList*) getAllRevisionsOfDocumentID: (NSString*)docID
numericID: (SInt64)docNumericID
onlyCurrent: (BOOL)onlyCurrent;
- (TDStatus) deleteViewNamed: (NSString*)name;
- (NSMutableDictionary*) documentPropertiesFromJSON: (NSData*)json
docID: (NSString*)docID
revID: (NSString*)revID
deleted: (BOOL)deleted
sequence: (SequenceNumber)sequence
options: (TDContentOptions)options;
- (NSString*) winningRevIDOfDocNumericID: (SInt64)docNumericID
isDeleted: (BOOL*)outIsDeleted;
@interface TD_Database (Insertion_Internal)
- (NSData*) encodeDocumentJSON: (TD_Revision*)rev;
- (TDStatus) validateRevision: (TD_Revision*)newRev previousRevision: (TD_Revision*)oldRev;
@interface TD_Database (Attachments_Internal)
- (void) rememberAttachmentWritersForDigests: (NSDictionary*)writersByDigests;
- (id) attachmentWriterForAttachment: (NSDictionary*)attachment;
- (BOOL) storeBlob: (NSData*)blob creatingKey: (TDBlobKey*)outKey;
- (TDStatus) insertAttachment: (TD_Attachment*)attachment
forSequence: (SequenceNumber)sequence;
- (TDStatus) copyAttachmentNamed: (NSString*)name
fromSequence: (SequenceNumber)fromSequence
toSequence: (SequenceNumber)toSequence;
- (BOOL) inlineFollowingAttachmentsIn: (TD_Revision*)rev error: (NSError**)outError;
@interface TD_Database (Replication_Internal)
- (void) stopAndForgetReplicator: (TDReplicator*)repl;
- (NSString*) lastSequenceWithCheckpointID: (NSString*)checkpointID;
- (BOOL) setLastSequence: (NSString*)lastSequence withCheckpointID: (NSString*)checkpointID;
+ (NSString*) joinQuotedStrings: (NSArray*)strings;
@interface TD_View ()
- (id) initWithDatabase: (TD_Database*)db name: (NSString*)name;
@property (readonly) int viewID;
- (NSArray*) dump;
- (void) databaseClosing;
@interface TD_Server ()
+ (TD_Server*) createEmptyAtPath: (NSString*)path; // for testing
+ (TD_Server*) createEmptyAtTemporaryPath: (NSString*)name; // for testing
@interface TD_DatabaseManager ()
@property (readonly, nonatomic) TDReplicatorManager* replicatorManager;
+ (TD_DatabaseManager*) createEmptyAtPath: (NSString*)path; // for testing
+ (TD_DatabaseManager*) createEmptyAtTemporaryPath: (NSString*)name; // for testing
@interface TDRouter ()
- (id) initWithDatabaseManager: (TD_DatabaseManager*)dbManager request: (NSURLRequest*)request;
@interface TDReplicator ()
// protected:
@property (copy) NSString* lastSequence;
@property (readwrite, nonatomic) NSUInteger changesProcessed, changesTotal;
- (void) maybeCreateRemoteDB;
- (void) beginReplicating;
- (void) addToInbox: (TD_Revision*)rev;
- (void) addRevsToInbox: (TD_RevisionList*)revs;
- (void) processInbox: (TD_RevisionList*)inbox; // override this
- (TDRemoteJSONRequest*) sendAsyncRequest: (NSString*)method
path: (NSString*)relativePath
body: (id)body
onCompletion: (TDRemoteRequestCompletionBlock)onCompletion;
- (void) addRemoteRequest: (TDRemoteRequest*)request;
- (void) removeRemoteRequest: (TDRemoteRequest*)request;
- (void) asyncTaskStarted;
- (void) asyncTasksFinished: (NSUInteger)numTasks;
- (void) stopped;
- (void) databaseClosing;
- (void) revisionFailed; // subclasses call this if a transfer fails
- (void) retry;
- (void) reachabilityChanged: (TDReachability*)host;
- (BOOL) goOffline;
- (BOOL) goOnline;
@property (readonly) BOOL savingCheckpoint;
Something went wrong with that request. Please try again.