FileStore SDK

FileStore SDK 3.x can be found at https://github.com/alscube/FileStore

FileStore SDK is a lightweight cross platform SDK for reading and writing defined records on Windows,  macOS, and Linux.  The sdk is based on Qt.  There are 13 classes that provide over 120 methods.

FileStore SDK provides base classes that are extended to create the file and record definitions.  For the file operations the sdk manages the record inserts, updates, and deletes.  The file classes keep track of deleted records and keeps the file size compact. 

The record operations help with accessing fields, validating field changes, tracking field modification, as well as reading and writing.

Auxiliary classes are provided to manage exceptions and log events.

A BTree class is included to create indexing associate with your defined records.

The downloaded SDK provides full documentation and a complete example to get you started.

The FileStore SDK is currently built for Qt 6.x and is available for Windows 64-bit, macOS universal apps (x86_64 and arm64), and Linux.

If a Qt build is not available for your needs please let me know, I should be able to provide one.   

While source code is not provided, the compiled SDK is free to use.  Available for use under the LGPLv3 license.


Details

The FileStore SDK creates a record file for each record definition created.   

Each file contains a header and record data, the header looks like

        |-----------------------------|
        | File Header                 |
        |   version                   |
        |   type                      |
        |   file ID                   |
        |   field count               |
        |   record size               |
        |   record count              |
        |   active record count       |
        |   first deleted             |
        |   last deleted              |
        |   file state                |
        |   spare 1                   |
        |   spare 2                   |
        |   spare 3                   |
        
|   spare 4                   |
        |
   spare 5                   |
        |-----------------------------|

The file header holds

    File Version                                   ( user defined )
    File Type                                       ( user define )
    A unique file ID                            ( user define )
    Record field count                        ( FileStore managed )
    Total record size                           ( calculated size )
    Total number of records               
( FileStore managed )
    Total number of active records     ( records not deleted )
    Offset of first deleted record        
( FileStore managed )
    Offset to last deleted record         
( FileStore managed )
    File state, open or closed.  Tracks if file was closed properly.  
( FileStore managed )
    Five spare data fields                     
( user define )

All file header fields have accessors.    

The record data is laid out as 

        |------------------------------------------------|
        | file header                                    |
        |------------------------------------------------|
        
| record header | record data                    |
        | record header | record data                    |
        | record header | record data                    |
        | record header | record data                    |
        |------------------------------------------------|

The record fields are

    Deleted flag                        ( FileStore managed )
    Previous record deleted     
( FileStore managed )
    Next record deleted            
( FileStore managed )
    Record data                        ( user defined )

Internal record management keeps track of the deleted records and reuses them as needed.  


The FileStore file base class provides the following methods

const QString& GetTableName() const;
const QString GetFileName( ) const;
const QString& GetPathFileName( ) const;

virtual ResultValue Create( );
virtual void CreateT( );
virtual ResultValue CreateDefaultEntries( );
virtual void CreateDefaultEntriesT( );

virtual ResultValue DeleteFile( );

virtual ResultValue Open( );
virtual void OpenT( bool markOpen = true );
virtual bool IsOpen( );

virtual ResultValue Close( );
virtual void CloseT( );

virtual ResultValue Insert( FSRecordBase& rec );
virtual void InsertT( FSRecordBase& rec );

virtual ResultValue Read( FSRecordBase& rec );
virtual void ReadT( FSRecordBase& rec );

virtual ResultValue ReadNext( FSRecordBase& rec );
virtual void ReadNextT( FSRecordBase& rec );

virtual void SetReadNextRecordIndex( REC_ID nextRecordIndex = NO_REC_ID);

        void SetSkipDeletedRecords( bool skipDeletedRecords );

virtual ResultValue Update( FSRecordBase& rec );
virtual void UpdateT( FSRecordBase& rec );

virtual ResultValue Delete( int recordId );
virtual void DeleteT( int recordId );

// ** Abstract methods to be implemented in the derived File class **
virtual FILE_ID GetFileID( ) const = 0;
virtual int GetFileType( ) const = 0;
virtual int GetFieldCount( ) const = 0;
virtual int GetRecordSize( ) const = 0;
virtual FSRecordBase* NewRecord( REC_ID recordId = NO_REC_ID ) = 0;
virtual FSRecordBase* _NewRecord( REC_ID recordId = NO_REC_ID );

// **** FILE HEADER FIELDS ****
qint32 GetHeaderFileVersion( );
FILE_TYPE GetHeaderFileType( );
FILE_ID GetHeaderFileId( );
QString GetHeaderFileIdAsString( );
qint32 GetHeaderFileFieldCount( );
qint32 GetHeaderFileRecordSize( );
qint32 GetHeaderFileTotalRecordCount( );
qint32 GetHeaderFileActiveRecordCount( );
qint32 GetHeaderFileFirstDeleted( );
qint32 GetHeaderFileLastDeleted( );
FILE_STATE GetHeaderFileOpenCloseState( );
qint32  GetHeaderSpareField( int spareIndex ) const;
void SetHeaderSpareField( int spareIndex, qint32 spareValue );
int GetTotalHeaderSize( );

        ResultValue WriteHeader( );
void WriteHeaderT( );


    


No comments:

Post a Comment