The Project Structure
Organizing Your Project
The Erbsland Regular Expression Library is designed to be used as a static library that you link directly into your C++ application. How you integrate it depends on your existing build setup, of course — but for most projects, there is a simple and robust approach that works very well.
In this tutorial, you’ll include the library as a Git submodule. This keeps third-party code clearly separated from your own application, makes updates predictable, and integrates cleanly with modern build systems like CMake.
By the end of this step, your project directory will look like this:
htmlstats # The project root directory
├── erbsland-cpp-re # The Erbsland RE library (Git submodule)
│ └── (...)
├── htmlstats # The application built in this tutorial
│ ├── src # Application source files
│ │ ├── main.cpp # Program entry point
│ │ └── (...)
│ └── CMakeLists.txt # CMake configuration for the application
└── CMakeLists.txt # Top-level CMake configuration
This layout scales well as your project grows and is easy to understand for anyone new joining your codebase.
Getting Started: Creating the Structure
Let’s begin by creating the project directory and adding the regular expression library as a submodule.
Open a terminal and run the following commands:
$ cd ~
$ mkdir htmlstats
$ cd htmlstats
$ git init
Initialized empty Git repository in ~/htmlstats/.git/
$ git submodule add https://github.com/erbsland-dev/erbsland-cpp-re.git erbsland-cpp-re
Cloning into '~/htmlstats/erbsland-cpp-re'...
...
$ git submodule init erbsland-cpp-re
At this point, Git is tracking your project, and the Erbsland library is available locally as a pinned dependency.
Next, create the directory structure for your application code:
$ mkdir htmlstats
$ mkdir htmlstats/src
The Current Project State
Right now, your project tree should look like this. Newly created components are highlighted:
htmlstats
├── erbsland-cpp-re # [new] Erbsland RE library submodule
└── htmlstats # [new] Application directory
└── src # [new] C++ source files live here
You now have a clean foundation: one directory for third-party code, one for your own application, and a structure that works naturally with CMake and version control.
Throughout this tutorial, you’ll see short command-line examples for tasks such as:
Adding Git submodules
Creating directories with
mkdirEditing files using tools like
nano
These commands are intentionally simple and easy to reproduce. If you prefer different tools, shells, or IDEs, feel free to adapt the steps — the concepts remain the same.