home *** CD-ROM | disk | FTP | other *** search
- /*
- IXBTreeCursor.h
- Copyright 1991, NeXT, Inc.
- */
-
- #import "IXBTree.h"
-
- #ifdef NX_COMPILER_RELEASE_3_0
- @interface IXBTreeCursor : Object <IXCursorPositioning>
- #else NX_COMPILER_RELEASE_3_0
- @interface IXBTreeCursor : Object
- #endif NX_COMPILER_RELEASE_3_0
- {
- struct BTree *btree;
- void *keyBuffer;
- unsigned keyLength;
- unsigned bufferSize;
- unsigned storeVersion;
- unsigned keyLimit;
- unsigned traceHint;
- unsigned cursorVersion;
- unsigned cursorDepth;
- NXZone *cursorZone;
- struct BTreeTraceRecord *cursorTrace;
- struct {
- unsigned isSpanning:1;
- unsigned rightRotation:1;
- unsigned leftRotation:1;
- unsigned traceNeeded:1;
- unsigned traceOpened:1;
- unsigned zeroPosition:1;
- unsigned lastPosition:1;
- } cursorStatus;
- }
-
- - (IXBTree *)btree;
- - initWithBTree:(IXBTree *)aBTree;
-
- // these methods provided for subclasses. isSynchronized returns FALSE when
- // the btree has been modified by another cursor, or the last change to the
- // btree destroyed the synchronization. use setKey:andLength: to synchronize
- // or isMatch or getKey:andLength: if still using the same key. changeCount
- // returns the btree's notion of the store's change count. If this is stale,
- // synchronization is necessary.
-
- - (BOOL)isSynchronized;
- - (unsigned)changeCount;
-
- // the value is a pointer to a buffer. if zero, a buffer will be allocated.
- // if non- zero, it will be interpreted as a buffer pointer. do not pass an
- // uninitialized pointer.
-
- - (unsigned)readValue:(void **)value; // reads the value and returns length
- - (unsigned)readRange:(void **)value // reads part of the value
- ofLength:(unsigned)length atOffset:(unsigned)offset;
-
- - removeValue; // removes the key/value pair from the B* tree
-
- - (BOOL)writeValue:(const void *)value // replaces if key exists, else inserts
- andLength:(unsigned)length;
- - writeRange:(const void *)value
- ofLength:(unsigned)length atOffset:(unsigned)offset;
-
- // these interpret the value at the cursor location as a typed stream archive.
-
- - readObject;
- - readObjectFromZone:(NXZone *)zone;
- - (BOOL)writeObject:anObject;
-
- // returns a pointer to a potentially write mapped page. use at your own risk.
- // it is fast, since it saves copying, but if you modify the value incorrectly,
- // you may damage the btree.
-
- - (unsigned)openRange:(void **)value
- ofLength:(unsigned)length atOffset:(unsigned)offset
- forWriting:(BOOL)writing;
-
- // store hints in secondary btrees to locate primary keys quickly for read
- // only or read mostly btrees. hints may actually diminish performance when
- // use with frequently modified btrees.
-
- - (BOOL)getKey:(void **)key // returns hint for cursor position
- andLength:(unsigned *)length withHint:(unsigned *)hint;
- - (BOOL)setKey:(const void *)key // sets key with hint returned by preceding
- andLength:(unsigned)length withHint:(unsigned)hint;
-
- @end
-