define database.h

This commit is contained in:
blobert 2024-02-18 18:46:34 +01:00
parent d0fdf63e77
commit 1f9fb962fb
6 changed files with 54 additions and 4 deletions

View File

@ -0,0 +1,20 @@
#include "cdb_database.h"
#include "../File-Page Abstraction/cdb_file-page.h"
struct db_Database_impl {
char * directory;
db_Table * tables;
};
struct db_Table_impl {
char * name;
db_Database database;
db_Column * columns;
fp_File data;
fp_File variableData;
};
struct db_Data_impl {
db_Table table;
void * data;
};

View File

@ -0,0 +1,33 @@
typedef struct db_Database_impl * db_Database;
typedef struct db_Table_impl * db_Table;
typedef struct db_Data_impl * db_Data;
typedef int db_Error;
typedef enum {
BINARY8, BINARY16, BINARY32, BINARY64, BINARYREF
} db_ColumnType;
typedef struct {
char * name;
db_ColumnType type;
} db_Column;
// Creates new database in specified directory
db_Database db_databaseNew(const char * directory);
// Closes specified Database and frees memory
void db_databaseClose(db_Database db);
// Creates, gets, renames, closes and deletes a Table
db_Error db_tableNew(db_Database db, char * name, db_Column * columns, unsigned int count);
db_Error db_tableRename(db_Table table);
db_Error db_tableDelete(db_Table table);
db_Error db_tableClose(db_Table table);
db_Table db_tableGet(char * name);
// Creates empty new Data
db_Data db_tableEntryNew(db_Table table);
db_Error db_tableEntrySet(db_Data entry, char * columnName, void * data);
db_Error db_tableEntryAdd(db_Table table, db_Data data);
unsigned long db_tableSize(db_Table table);
db_Error db_tableClear(db_Table table);

View File

@ -1,5 +1,5 @@
#include "cdb_file-page.h" #include "cdb_file-page.h"
#include "../System Abstraction/cdb_sustem.h" #include "../System Abstraction/cdb_system.h"
struct fp_File_impl{ struct fp_File_impl{
sys_File file; sys_File file;

View File

@ -11,9 +11,6 @@ void fp_fileSetPageSize(fp_File file, unsigned long pageSize);
//negative values indicate the removable of the latest pages; so this library doesn't need more functions //negative values indicate the removable of the latest pages; so this library doesn't need more functions
void * fp_fileAppendPages(fp_File file, long numberOfPages); void * fp_fileAppendPages(fp_File file, long numberOfPages);
void * fp_fileToMemory(fp_File file); void * fp_fileToMemory(fp_File file);
void fp_fileFlush(fp_File file); void fp_fileFlush(fp_File file);
void fp_fileClose(fp_File file); void fp_fileClose(fp_File file);