Add toml++ and it's example program

This commit is contained in:
Toast 2025-04-17 13:19:35 +02:00
parent 2209bda83f
commit f69cd94c53
4 changed files with 23 additions and 0 deletions

View file

@ -7,4 +7,6 @@ project(
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
set(CMAKE_CXX_STANDARD 23)
find_package(tomlplusplus REQUIRED)
add_subdirectory(src)

View file

@ -10,6 +10,7 @@
clang-tools
cmake
cmake-language-server
tomlplusplus
];
};
};

View file

@ -1 +1,2 @@
add_executable(Hello helloWorld.cpp)
add_executable(tomlParse tomlParse.cpp)

19
src/tomlParse.cpp Normal file
View file

@ -0,0 +1,19 @@
#include <iostream>
#include <toml++/toml.hpp>
int main(int argc, char** argv)
{
toml::table tbl;
try
{
tbl = toml::parse_file(argv[1]);
std::cout << tbl << "\n";
}
catch (const toml::parse_error& err)
{
std::cerr << "Parsing failed:\n" << err << "\n";
return 1;
}
return 0;
}