MacroDB is a lightweight, embedded database system designed for embedded systems and microcontrollers. It provides a simple interface for storing and retrieving data with built-in safety checks and memory management.
- Simple key-value storage interface
- Memory-safe operations with boundary checks
- Magic number validation for data integrity
- Platform abstraction layer for portability
- Configurable memory size and address space
- Type-safe data storage and retrieval
- Support for custom struct data types
- Dynamic string handling based on size information
- CMake 3.14 or higher
- C compiler with C11 support
- Git (for cloning submodules)
- Clone the repository with submodules:
git clone --recursive https://github.com/yourusername/macrodb.git
cd macrodb- Create a build directory and run CMake:
mkdir build
cd build
cmake ..
cmake --build .- Run tests:
ctest --output-on-failure#include "macrodb.h"
int main() {
// Initialize the database
db_status status = mdb_init();
if (status != DB_OK) {
// Handle error
return -1;
}
// Read a value
status = mdb_read(DATA_STRUCT);
if (status == DB_OK) {
printf("Read struct: {id: %d, age: %d, name: %s}\n",
data_struct.id, data_struct.age, data_struct.name);
}
// Write a value
my_dummy_struct_t new_data = {
.id = 1,
.age = 25,
.name = "John Doe"
};
status = mdb_write(DATA_STRUCT, &new_data);
}The database can be configured by modifying the following parameters in include/platform/pal.h:
PAL_MEMORY_SIZE: Total size of the memory spacePAL_MEMORY_START: Starting address of the memory space
1- Enhanced Struct Support
- Nested struct storage
- Array of structs support
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- Selim Keles - Initial work
- Unity Test Framework for testing support