It is recommended to build library and run tests using Dev containers in Visual Studio Code.
For development purposes use a devcontainer named developing.
- Install WSL
- Install the Docker client (Windows / Mac / Linux)
- Make sure Docker client is the latest version
- Microsoft VS Code
- VS Code should also have the "Dev Containers" extension installed. To check it, open "View: Extensions" with
Ctrl + Shift + Xor as shown in the screenshot below:
- VS Code should also have the "Dev Containers" extension installed. To check it, open "View: Extensions" with
- Make sure Docker daemon is running before opening the dev container (
Ctrl + Shift + P-> "Reopen in container" or click here + "Reopen in container")
To build this project, open the VS Code terminal (Ctrl + Shift + ~) and run conan install . --build=missing.
After the Conan install process, open the CMake extension and click Configure.
When the project configuration is finished, click Build to build the project.
- Run the database container via docker compose command
docker compose up -dfrom workspace. - Import environment variables declared in the
.envfile while in the dev container and using the commandexport $(grep -v '^#' .env | xargs). If the file containing the environment variables is named something other than.env, you should modify the command to specify the correct name.
To launch the executable, click Launch in the CMake extension.
The project includes the clang-tidy code analyzer and the clang-format formatter. Configuration files are located in the project root: .clang-tidy and .clang-format, respectively.
To use linters you need to install:
Clang-format code formatting occurs automatically when saving a file using the CodeAnalysis C/C++ extension.
To start manually, you need to run the command find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run, while in the root of the project.
To automatically fix errors, run find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format -i from the project root.
Clang-tidy code checking occurs in the background using the CodeAnalysis C/C++ extension.
To start manually, you need to run the command find ./src -name "*.cpp" -o -name "*.h" | xargs clang-tidy -p ./build/Debug | grep "error:", while in the root of the project.
The project presents an example of test implementation using GTest tools. Test files are located in the test directory at the root of the project. Inside the test directory there is a CMakeLists.txt file created specifically for building a separate executable file for tests.
To run tests, go to the build/Debug directory, and then run the ctest command in the terminal (Ctrl + Shift + ~).
Alternatively, use the CMake Tools Extension in VS Code. To do this, open the CMake Tools Extension and click Test, after configuring and building the project.
After creating the database or model, it is necessary to generate the auxiliary ODB files with the command odb --std c++20 -d pgsql --generate-query -o odb-gen <model header file> from the folder src/data/models.
After executing the command, files will be created or updated in the folder `src/data/models/odb-gen'. Please do not modify or transfer these files for the correct operation of the application.
The alembic tool is used to work with migrations. To work with it, you need to modify or create a python model according to the cpp version of the model.
- Create/change python model according declared cpp model.
- Change terminal workspace to
src/data. - Use the alembic command
alembic revision --autogenerate -m '<name of migration>'for create new migration to database. - If its needed upgrade local database with latest migration with commnd
alembic upgrade head.







