Integrate Validation Rules as a Submodule
This page extends the parser-only setup from Integrate the Parser as Submodule. The parser target is still the base dependency, while validation rules are added by linking one of the dedicated validation-rules targets.
Validation-rules targets are excluded from the default build and are only compiled when explicitly requested by linking or by building the target directly.
Choose a Validation-Rules Target
Select exactly one variant:
erbsland-configuration-vr-re-disabled: validation rules withoutmatchessupport.erbsland-configuration-vr-re-std: validation rules withmatchesusingstd::regex.erbsland-configuration-vr-re-erbsland: validation rules withmatchesusingerbsland-re(the Erbsland Regular Expression library).
If you plan to use matches constraints with regular expressions, we recommend using the Erbsland Regular Expression library for stability and safety. To reduce dependencies, using std::regex is an option, but the support and stability of this regular expression implementation strongly depends on the used platform, compiler and standard library.
If you do not plan to use the matches constraint, disabling this functionality is a safe choice.
Update Your CMake Target
Keep your top-level setup from Integrate the Parser as Submodule and only extend the application target link libraries:
cmake_minimum_required(VERSION 3.25)
project(Example)
add_executable(example
src/main.cpp
)
target_compile_features(example PRIVATE cxx_std_20)
target_link_libraries(example PRIVATE
erbsland-configuration-parser
erbsland-configuration-vr-re-std
)
How to Compile
The build flow stays the same:
$ mkdir cmake-build
$ cmake . -B cmake-build
$ cmake --build cmake-build
For faster and more reliable incremental builds, we recommend using Ninja as your build tool on all platforms.
$ mkdir cmake-build
$ cmake . -G Ninja -B cmake-build
$ cmake -B cmake-build -j 8
Minimal Usage Example
#include <erbsland/all_conf.hpp>
#include <erbsland/all_conf_vr.hpp>
int main() {
using namespace el::conf;
Parser parser;
const auto configDoc = parser.parseFileOrThrow(String{"config.elcl"});
const auto rulesDoc = parser.parseFileOrThrow(String{"validation-rules.elcl"});
const auto rules = vr::Rules::createFromDocument(rulesDoc);
rules->validate(configDoc, 1); // validate for version 1
}
For practical examples, continue with:
For API details, see Validation Rules.