- DATA = 0
- RECORDS = 1
- normal data file
- ORIGINAL = 0
- CURRENT = 1
- used short integers, limited file size
- N_INDEX_REC = 0
- N_DATA_REC = 1
- Number of index records
- BYTES_PER_REC = 2
- Number of data records
- BYTES_PER_ENTRY = 3
- Number of bytes/records, must be 512
- MAX_ENTRY_USED = 4
- Number of bytes/index-entry
- COUNTER = 5
- Number (origin=1) of largest index entry in use
- TYPE = 6
- incremented by 1 whenever the file changes, wraps back to 0 at max unsigned 4-byte integer
- VERSION = 7
- either DATA or RECORDS
fstream* file_ptr = new fstream("file_name", ios::nocreate); CountedPtr<fstream> file(file_ptr); SDDBootStrap bs(file); cout << "Number of index records : " << bs.nIndexRec() << endl; cout << "Number of data records : " << bs.nDataRec() << endl; cout << "Maximum index entry in use : " << bs.maxEntryUsed() << endl; // set some new values bs.setNDataRec(bs.nDataRec()+5); if (!bs.setMaxEntryUsed(bs.maxEntryUsed()+1)) { cout << "unable to set max entry used" << endl; // do something appropriate here } // write it out bs.write();
Default constructor : empty CURRENT version NOT attached to a file
The assignment operator, does a full copy
Attach
Get the CountedPtr
These just return the values.
Maximum index entries that can be used, based on
the values in the bootstrap
the numebr of entries per record
Set things that are allowed to be set
this requires a sanity check to ensure it is less than maxEntries
This returns True if the bootstrap on disk differs from the
one here. It does not change the bootstrap on disk.
sync() re-reads the values from disk. Any internal values
will be forgotten.
uInt nIndexRec() const
uInt nDataRec() const
uInt bytesPerRecord() const
uInt bytesPerEntry() const
uInt maxEntryUsed() const
uInt counter() const
uInt type() const
uInt version() const
uInt maxEntries() const
uInt entriesPerRecord() const
void setNIndexRec(uInt newValue)
void setNDataRec(uInt newValue)
void setBytesPerEntry(uInt newValue)
void setVersion(SDD_VERSION newValue)
void setType(TYPE_OF_SDD newValue)
Bool setMaxEntryUsed(uInt newValue)
Bool hasChanged()
void sync()
enum
this enum describes where things are in the bootstrap block
for ORIGINAL version files, these are short (2-byte) unsigned integers
for CURRENT version files, these are long (4-byte) unsigned integers
all unused space is filled with zeros (both ORIGINAL and CURRECT).