diff options
Diffstat (limited to 'src/nids.h')
-rw-r--r-- | src/nids.h | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -3,12 +3,15 @@ | |||
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | #include "bu/bitstring.h" | 5 | #include "bu/bitstring.h" |
6 | #include "bu/exceptionbase.h" | ||
6 | 7 | ||
7 | namespace Bu | 8 | namespace Bu |
8 | { | 9 | { |
9 | class Stream; | 10 | class Stream; |
10 | class NidsStream; | 11 | class NidsStream; |
11 | 12 | ||
13 | subExceptionDecl( NidsException ) | ||
14 | |||
12 | /** | 15 | /** |
13 | * Numerically Indexed Data Streams. This is a working name so I can | 16 | * Numerically Indexed Data Streams. This is a working name so I can |
14 | * actually get some code written instead of agonizing over the name. | 17 | * actually get some code written instead of agonizing over the name. |
@@ -24,6 +27,14 @@ namespace Bu | |||
24 | virtual ~Nids(); | 27 | virtual ~Nids(); |
25 | 28 | ||
26 | /** | 29 | /** |
30 | * Initialize this object based on the data already in the assosiated | ||
31 | * stream. This will be called automatically for you if you forget, | ||
32 | * but if you want to pre-initialize for some reason, just call this | ||
33 | * once before you actually start doing anything with your Nids. | ||
34 | */ | ||
35 | void initialize(); | ||
36 | |||
37 | /** | ||
27 | * Create a new Nids system in the assosiated stream. This should be | 38 | * Create a new Nids system in the assosiated stream. This should be |
28 | * used carefully, it will destroy all data already within the stream. | 39 | * used carefully, it will destroy all data already within the stream. |
29 | * More options will probably be added soon. | 40 | * More options will probably be added soon. |
@@ -46,14 +57,16 @@ namespace Bu | |||
46 | */ | 57 | */ |
47 | NidsStream openStream( int iID ); | 58 | NidsStream openStream( int iID ); |
48 | 59 | ||
60 | int getBlockSize(); | ||
61 | |||
49 | private: | 62 | private: |
50 | typedef struct Block | 63 | typedef struct Block |
51 | { | 64 | { |
52 | uint32_t iFirstBlock; | 65 | uint32_t uFirstBlock; |
53 | uint32_t iNextBlock; | 66 | uint32_t uNextBlock; |
54 | uint32_t iPrevBlock; | 67 | uint32_t uPrevBlock; |
55 | uint32_t iBytesUsed; | 68 | uint32_t uBytesUsed; |
56 | uint32_t iReserved; | 69 | uint32_t uReserved; |
57 | unsigned char pData[0]; | 70 | unsigned char pData[0]; |
58 | } Block; | 71 | } Block; |
59 | 72 | ||
@@ -62,9 +75,14 @@ namespace Bu | |||
62 | blockUnused = 0xFFFFFFFFUL | 75 | blockUnused = 0xFFFFFFFFUL |
63 | }; | 76 | }; |
64 | 77 | ||
65 | void extendStream( int iID, int iBlockCount=1 ); | 78 | uint32_t createBlock( uint32_t uFirstBlock, uint32_t uPrevBlock, |
66 | void getBlock( int iIndex, struct Nids::Block *pBlock ); | 79 | int iPreAllocate=1 ); |
67 | void setBlock( int iIndex, struct Nids::Block *pBlock ); | 80 | void getBlock( uint32_t uIndex, struct Nids::Block *pBlock ); |
81 | void setBlock( uint32_t uIndex, struct Nids::Block *pBlock ); | ||
82 | void updateStreamSize( uint32_t uIndex, uint32_t uSize ); | ||
83 | uint32_t getNextBlock( uint32_t uIndex, struct Nids::Block *pBlock ); | ||
84 | Block *newBlock(); | ||
85 | void deleteBlock( Block *pBlock ); | ||
68 | 86 | ||
69 | private: | 87 | private: |
70 | Bu::Stream &sStore; | 88 | Bu::Stream &sStore; |