How rbock/sqlpp23 works
Project Type & Purpose
• sqlpp23 is a C++‑23 header‑only library (an embedded DSL) that lets C++ code express type‑safe SQL.
• It is vendor‑neutral at its core and extensible via “connectors” for specific backends (MySQL, PostgreSQL, SQLite3, SQLCipher, MariaDB).
• It includes documentation (docs/), examples (examples/), tests (tests/), build scripts (CMake), and code‑generation tools (scripts/).
High‑Level Components
• Build & Packaging
– CMakeLists.txt + cmake/… → defines CMake targets: sqlpp23::core, sqlpp23::mysql, sqlpp23::postgresql, sqlpp23::sqlite3, sqlpp23::connector_api
– .gitignore, LICENSE, ChangeLog.md, etc.
• Core Library (include/sqlpp23/core)
– Expression AST, clause builders, static checks, type traits, SQL serialization
• Connector API (connector_api/)
– Abstract interfaces: connection, connection_pool, interpreter, prepared_statement, bind_result
• Connectors (include/sqlpp23/{mysql,postgresql,sqlite3,mariadb,sqlcipher})
– Concrete implementations of connector_api, dialect‑specific SQL serialization, handle lifecycles
• Examples (examples/…)
• Tests (tests/…)
• Documentation (docs/…)
• Scripts & Tools (scripts/ddl2cpp)
Relationships & Data Flow
• At build time, CMake compiles/tests the Core and each Connector into separate targets.
• User code (examples or downstream projects) → links against core + chosen connector(s).
• The Connector API sits between Core and concrete connectors:
Core → calls Connector API interfaces → implemented by each Connector → calls into native DB client library (MySQL client, libpq, sqlite3).
• Scripts/ddl2cpp is a standalone tool that reads SQL DDL and emits C++ code—an auxiliary component, not part of the runtime library.
• Docs and examples reference Core+Connectors but do not interact at runtime.
Architectural Patterns & Principles
• Layered architecture:
– Layer 1: Core DSL (database‑vendor‑neutral expressions & serialization)
– Layer 2: Connector API (abstract “port”)
– Layer 3: Connectors (adapter/“plugin” for each SQL dialect)
– Layer 4: Native DB client libraries
• Header‑only, template‑meta‑programming to achieve compile‑time safety.
• CMake modular targets to decouple connectors.
• Test‑driven: a vast hierarchy of unit tests per core and per connector.