2026-02-02 08:42:30 -05:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
< meta name = "generator" content = "Doxygen 1.13.2" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > libconfig: libconfig< / title >
< link rel = "icon" href = "logo.png" type = "image/x-icon" / >
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "jquery.js" > < / script >
< script type = "text/javascript" src = "dynsections.js" > < / script >
< script type = "text/javascript" src = "clipboard.js" > < / script >
< link href = "navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "navtreedata.js" > < / script >
< script type = "text/javascript" src = "navtree.js" > < / script >
< script type = "text/javascript" src = "resize.js" > < / script >
< script type = "text/javascript" src = "cookie.js" > < / script >
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/searchdata.js" > < / script >
< script type = "text/javascript" src = "search/search.js" > < / script >
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
2026-02-02 08:47:02 -05:00
< link href = "doxygen-awesome.css" rel = "stylesheet" type = "text/css" / >
< link href = "doxygen-awesome-sidebar-only.css" rel = "stylesheet" type = "text/css" / >
2026-02-02 08:42:30 -05:00
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr id = "projectrow" >
< td id = "projectlogo" > < img alt = "Logo" src = "logo.png" / > < / td >
< td id = "projectalign" >
< div id = "projectname" > libconfig< span id = "projectnumber" >   v2.1.0< / span >
< / div >
< div id = "projectbrief" > Reflection based C++ configuration library< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
< / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
< / script >
< script type = "text/javascript" src = "menudata.js" > < / script >
< script type = "text/javascript" src = "menu.js" > < / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function(){initNavTree('index.html',''); initResizable(true); });
/* @license-end */
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< div id = "MSearchResults" >
< div class = "SRPage" >
< div id = "SRIndex" >
< div id = "SRResults" > < / div >
< div class = "SRStatus" id = "Loading" > Loading...< / div >
< div class = "SRStatus" id = "Searching" > Searching...< / div >
< div class = "SRStatus" id = "NoMatches" > No Matches< / div >
< / div >
< / div >
< / div >
< / div >
< div > < div class = "header" >
< div class = "headertitle" > < div class = "title" > libconfig < / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
< div class = "textblock" > < p > < a class = "anchor" id = "md_docs_2static_2mainpage" > < / a > < img src = "logo.png" alt = "img" class = "inline" / > < / p >
< h1 > < a class = "anchor" id = "autotoc_md0" > < / a >
libconfig< / h1 >
< p > libconfig is the unified configuration module for SERiF and related projects< / p >
< p > This has been broken out of the main serif project to allow for more modularity< / p >
< h2 > < a class = "anchor" id = "autotoc_md1" > < / a >
Building< / h2 >
< p > In order to build libconfig you need < code > meson> =1.5.0< / code > . This can be installed with < code > pip< / code > < / p >
< div class = "fragment" > < div class = "line" > pip install " meson> =1.5.0" < / div >
< / div > <!-- fragment --> < p > Then from the root libconfig directory it is as simple as< / p >
< div class = "fragment" > < div class = "line" > meson setup build --buildtype=release< / div >
< div class = "line" > meson compile -C build< / div >
< div class = "line" > meson test -C build< / div >
< / div > <!-- fragment --> < p > this will auto generate a pkg-config file for you so that linking other libraries to libconfig is easy.< / p >
< h2 > < a class = "anchor" id = "autotoc_md2" > < / a >
Usage< / h2 >
< p > libconfig makes use of < a href = "https://github.com/getml/reflect-cpp" > reflect-cpp< / a > to provide compile time reflection and serialization/deserialization of configuration structs. This allows for config options to be defined in code and strongly typed.< / p >
< h3 > < a class = "anchor" id = "autotoc_md3" > < / a >
Basic Usage< / h3 >
< div class = "fragment" > < div class = "line" > < span class = "preprocessor" > #include " < a class = "code" href = "config_8h.html" > fourdst/config/config.h< / a > " < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < string> < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include < print> < / span > < / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keyword" > struct < / span > MyPhysicsOptions {< / div >
< div class = "line" > < span class = "keywordtype" > int< / span > gravity = 10;< / div >
< div class = "line" > < span class = "keywordtype" > float< / span > friction = 0.5f;< / div >
< div class = "line" > < span class = "keywordtype" > bool< / span > enable_wind = < span class = "keyword" > false< / span > ;< / div >
< div class = "line" > };< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keyword" > struct < / span > MyControlOptions {< / div >
< div class = "line" > < span class = "keywordtype" > double< / span > time_step = 0.01;< / div >
< div class = "line" > < span class = "keywordtype" > double< / span > max_time = 100.0;< / div >
< div class = "line" > };< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keyword" > struct < / span > MySimulationConfig {< / div >
< div class = "line" > std::string name = < span class = "stringliteral" > " my_simulation" < / span > ;< / div >
< div class = "line" > MyPhysicsOptions physics;< / div >
< div class = "line" > MyControlOptions control;< / div >
< div class = "line" > };< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > int< / span > main() {< / div >
< div class = "line" > < a class = "code hl_class" href = "classfourdst_1_1config_1_1_config.html" > fourdst::config::Config< MySimulationConfig> < / a > cfg;< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // You can save the default config to a file< / span > < / div >
< div class = "line" > cfg.< a class = "code hl_function" href = "classfourdst_1_1config_1_1_config.html#a91fa54016e231a8361142b51807f047d" > save< / a > (< span class = "stringliteral" > " default_config.toml" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // You can save the json schema for the config< / span > < / div >
< div class = "line" > < span class = "comment" > // This allows editors like VS Code to provide autocompletion< / span > < / div >
< div class = "line" > < a class = "code hl_function" href = "classfourdst_1_1config_1_1_config.html#ae698328f4cf5b175bf113b0d8dbc7937" > fourdst::config::Config< MySimulationConfig> ::save_schema< / a > (< span class = "stringliteral" > " config.schema.json" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // You can load a config from a file< / span > < / div >
< div class = "line" > < span class = "keywordflow" > try< / span > {< / div >
< div class = "line" > cfg.< a class = "code hl_function" href = "classfourdst_1_1config_1_1_config.html#ae0097a0c728ad24a5d03f9a8580eac74" > load< / a > (< span class = "stringliteral" > " my_config.toml" < / span > );< / div >
< div class = "line" > } < span class = "keywordflow" > catch< / span > (< span class = "keyword" > const< / span > < a class = "code hl_class" href = "classfourdst_1_1config_1_1exceptions_1_1_config_error.html" > fourdst::config::exceptions::ConfigError< / a > & e) {< / div >
< div class = "line" > std::println(< span class = "stringliteral" > " Error loading config: {}" < / span > , e.< a class = "code hl_function" href = "classfourdst_1_1config_1_1exceptions_1_1_config_error.html#aed6ae63fbbc9cb7e1d372904638b1fe6" > what< / a > ());< / div >
< div class = "line" > }< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // You can access the config values< / span > < / div >
< div class = "line" > std::println(< span class = "stringliteral" > " My Simulation Name: {}, My Simulation Gravity: {}" < / span > , cfg-> name, cfg-> physics.gravity);< / div >
< div class = "line" > }< / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1_config_html" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1_config.html" > fourdst::config::Config< / a > < / div > < div class = "ttdoc" > Wrapper class for managing strongly-typed configuration structures.< / div > < div class = "ttdef" > < b > Definition< / b > base.h:113< / div > < / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1_config_html_a91fa54016e231a8361142b51807f047d" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1_config.html#a91fa54016e231a8361142b51807f047d" > fourdst::config::Config::save< / a > < / div > < div class = "ttdeci" > void save(std::string_view path) const< / div > < div class = "ttdoc" > Saves the current configuration to a TOML file.< / div > < div class = "ttdef" > < b > Definition< / b > base.h:164< / div > < / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1_config_html_ae0097a0c728ad24a5d03f9a8580eac74" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1_config.html#ae0097a0c728ad24a5d03f9a8580eac74" > fourdst::config::Config::load< / a > < / div > < div class = "ttdeci" > void load(const std::string_view path)< / div > < div class = "ttdoc" > Loads configuration from a TOML file.< / div > < div class = "ttdef" > < b > Definition< / b > base.h:249< / div > < / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1_config_html_ae698328f4cf5b175bf113b0d8dbc7937" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1_config.html#ae698328f4cf5b175bf113b0d8dbc7937" > fourdst::config::Config::save_schema< / a > < / div > < div class = "ttdeci" > static void save_schema(const std::string & path)< / div > < div class = "ttdoc" > Generates and saves a JSON schema for the configuration structure.< / div > < div class = "ttdef" > < b > Definition< / b > base.h:300< / div > < / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1exceptions_1_1_config_error_html" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1exceptions_1_1_config_error.html" > fourdst::config::exceptions::ConfigError< / a > < / div > < div class = "ttdoc" > Base exception class for all configuration-related errors.< / div > < div class = "ttdef" > < b > Definition< / b > exceptions.h:20< / div > < / div >
< div class = "ttc" id = "aclassfourdst_1_1config_1_1exceptions_1_1_config_error_html_aed6ae63fbbc9cb7e1d372904638b1fe6" > < div class = "ttname" > < a href = "classfourdst_1_1config_1_1exceptions_1_1_config_error.html#aed6ae63fbbc9cb7e1d372904638b1fe6" > fourdst::config::exceptions::ConfigError::what< / a > < / div > < div class = "ttdeci" > const char * what() const noexcept override< / div > < div class = "ttdoc" > Returns the error message.< / div > < div class = "ttdef" > < b > Definition< / b > exceptions.h:32< / div > < / div >
< div class = "ttc" id = "aconfig_8h_html" > < div class = "ttname" > < a href = "config_8h.html" > config.h< / a > < / div > < div class = "ttdoc" > Main entry point for the fourdst::config library.< / div > < / div >
< / div > <!-- fragment --> < h3 > < a class = "anchor" id = "autotoc_md4" > < / a >
CLI Integration< / h3 >
< p > libconfig integrates with < a href = "https://github.com/CLIUtils/CLI11" > CLI11< / a > to automatically expose configuration fields as command-line arguments.< / p >
< div class = "fragment" > < div class = "line" > < span class = "preprocessor" > #include " CLI/CLI.hpp" < / span > < / div >
< div class = "line" > < span class = "preprocessor" > #include " < a class = "code" href = "config_8h.html" > fourdst/config/config.h< / a > " < / span > < / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "keywordtype" > int< / span > main(< span class = "keywordtype" > int< / span > argc, < span class = "keywordtype" > char< / span > ** argv) {< / div >
< div class = "line" > < a class = "code hl_class" href = "classfourdst_1_1config_1_1_config.html" > fourdst::config::Config< MySimulationConfig> < / a > cfg;< / div >
< div class = "line" > CLI::App app(< span class = "stringliteral" > " My Application" < / span > );< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // Automatically registers:< / span > < / div >
< div class = "line" > < span class = "comment" > // --name< / span > < / div >
< div class = "line" > < span class = "comment" > // --physics.gravity< / span > < / div >
< div class = "line" > < span class = "comment" > // --physics.friction< / span > < / div >
< div class = "line" > < span class = "comment" > // --physics.enable_wind< / span > < / div >
< div class = "line" > < span class = "comment" > // ... and so on< / span > < / div >
< div class = "line" > < a class = "code hl_function" href = "namespacefourdst_1_1config.html#aeca53bef637c1b60bf5fbccc8526a7a0" > fourdst::config::register_as_cli< / a > (cfg, app);< / div >
< div class = "line" > < / div >
< div class = "line" > CLI11_PARSE(app, argc, argv);< / div >
< div class = "line" > < / div >
< div class = "line" > < span class = "comment" > // cfg is now populated with values from CLI arguments< / span > < / div >
< div class = "line" > < span class = "keywordflow" > return< / span > 0;< / div >
< div class = "line" > }< / div >
< div class = "ttc" id = "anamespacefourdst_1_1config_html_aeca53bef637c1b60bf5fbccc8526a7a0" > < div class = "ttname" > < a href = "namespacefourdst_1_1config.html#aeca53bef637c1b60bf5fbccc8526a7a0" > fourdst::config::register_as_cli< / a > < / div > < div class = "ttdeci" > void register_as_cli(T & config, CliApp & app, const std::string & prefix=" " )< / div > < div class = "ttdoc" > Registers configuration structure fields as CLI options.< / div > < div class = "ttdef" > < b > Definition< / b > cli.h:114< / div > < / div >
< / div > <!-- fragment --> < h2 > < a class = "anchor" id = "autotoc_md5" > < / a >
Example output TOML< / h2 >
< div class = "fragment" > < div class = "line" > [main]< / div >
< div class = "line" > name = " my_simulation" < / div >
< div class = "line" > [main.physics]< / div >
< div class = "line" > gravity = 10< / div >
< div class = "line" > friction = 0.5< / div >
< div class = "line" > enable_wind = false< / div >
< div class = "line" > [main.control]< / div >
< div class = "line" > time_step = 0.01< / div >
< div class = "line" > max_time = 100.0< / div >
< / div > <!-- fragment --> < / div > < / div > <!-- PageDoc -->
< a href = "doxygen_crawl.html" > < / a >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
< li class = "footer" > Generated by < a href = "https://www.doxygen.org/index.html" > < img class = "footer" src = "doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.13.2 < / li >
< / ul >
< / div >
< / body >
< / html >