A modern Object-Relational Mapping (ORM) library for C++20, designed to provide type-safe database operations with compile-time validation.
- C++20 Modern Features: Leverages concepts, constexpr if, and other modern C++ features
- Type Safety: Compile-time type checking for database operations
- Header-Only Design: Easy integration into existing projects (planned)
- Cross-Platform: Works on Linux, macOS, and Windows
- Comprehensive Testing: Google Test integration for reliable development
ormcpp/
├── CMakeLists.txt # Main CMake configuration
├── README.md # This file
├── src/ # Source files
│ └── main.cpp # Example/demo application
├── include/ # Header files
│ └── ormcpp/ # Library headers (to be added)
├── tests/ # Test files
│ ├── CMakeLists.txt # Test configuration
│ └── basic_test.cpp # Basic tests
├── docs/ # Documentation
├── examples/ # Usage examples
└── build/ # Build directory (generated)
- CMake 3.20 or higher
- GCC 11+ or Clang 12+ (C++20 support required)
- Git (for dependency management)
- Internet connection (for downloading Google Test)
git clone <your-repo-url>
cd ormcpp
# Create build directory
mkdir -p build
cd build
# Configure with CMake
cmake ..
# Build the project
make
# Or use cmake to build
cmake --build .
# Run the main executable
./ormcpp
# Run tests directly
./tests/ormcpp_tests
# Or use CTest for detailed output
ctest --verbose
# Run specific test
ctest -R BasicTest
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
cmake -DCMAKE_BUILD_TYPE=Release ..
make
# Using GCC
cmake -DCMAKE_CXX_COMPILER=g++ ..
# Using Clang
cmake -DCMAKE_CXX_COMPILER=clang++ ..
- Create header files in
include/ormcpp/
- Create source files in
src/
(if not header-only) - Add tests in
tests/
- Update CMakeLists.txt if needed
- Build and test
The project uses Google Test for unit testing:
# Add new test file in tests/
touch tests/my_new_test.cpp
# CMake will automatically detect and compile new test files
cd build && make
# Run all tests
./tests/ormcpp_tests
#include <gtest/gtest.h>
#include "ormcpp/your_header.hpp"
TEST(YourTestSuite, TestName) {
// Your test code
EXPECT_EQ(expected, actual);
}
This project leverages modern C++20 features:
- Concepts: Type constraints for template parameters
- constexpr if: Compile-time conditional compilation
- Template improvements: Enhanced template argument deduction
- Modules: (Planned for future versions)
#include <ormcpp/orm.hpp>
// Define your entity
class User : public ormcpp::Entity {
public:
int id;
std::string name;
std::string email;
std::string getTableName() const override {
return users;
}
};
// Use the ORM
int main() {
ormcpp::Repository<User> userRepo(sqlite:///users.db);
// Find users
auto users = userRepo.findAll();
// Find by condition
auto admins = userRepo.findBy(role, admin);
return 0;
}
Compiler | Minimum Version | Status |
---|---|---|
GCC | 11.0 | ✅ Tested |
Clang | 12.0 | ✅ Tested |
MSVC | 19.29 | 🟡 Should work |
Target | Description |
---|---|
ormcpp |
Main executable |
ormcpp_lib |
Library (static/interface) |
ormcpp_tests |
Test executable |
run_tests |
Custom target to run tests |
The build system provides a configuration summary:
-- ormcpp Configuration Summary:
-- Version: 1.0.0
-- Build type: Debug
-- C++ standard: 20
-- Compiler: GNU
-
CMake version too old:
- Update CMake to 3.20 or higher
-
C++20 not supported:
- Update compiler (GCC 11+, Clang 12+)
-
Google Test download fails:
- Check internet connection
- May need to configure proxy if behind corporate firewall
-
Build fails with template errors:
- Ensure you're using a C++20 compatible compiler
- Check that
-std=c++20
is being used
# Verbose build output
make VERBOSE=1
# Clean rebuild
rm -rf build
mkdir build && cd build
cmake .. && make
# Check compiler version
g++ --version
cmake --version
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Add tests for new functionality
- Run tests:
ctest
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is developed using:
- Docker: For consistent development environment
- CLion: IDE with remote development support
- GCC 11: Primary compiler for C++20 features
[Add your license here]
- Basic ORM functionality
- SQLite backend
- PostgreSQL backend
- MySQL backend
- Query builder
- Migrations support
- Connection pooling
- Header-only conversion
- Initial project setup
- CMake configuration with C++20
- Google Test integration
- Basic project structure