Skip to content

Commit

Permalink
simple get, without templates
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Jan 24, 2023
1 parent 385c493 commit 4aa9550
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.16)

# set the project name
project(libmcfp VERSION 1.2.3 LANGUAGES CXX)
project(libmcfp VERSION 1.2.4 LANGUAGES CXX)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.2.4
- Simpler get (added a version without template arguments)

Version 1.2.3
- MSVC compatibility

Expand Down
10 changes: 10 additions & 0 deletions include/mcfp/mcfp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ class config
return result;
}

std::string get(std::string_view name) const
{
return get<std::string>(name);
}

std::string get(std::string_view name, std::error_code &ec) const
{
return get<std::string>(name, ec);
}

const std::vector<std::string> &operands() const
{
return m_impl->m_operands;
Expand Down
19 changes: 19 additions & 0 deletions test/unit-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,25 @@ BOOST_AUTO_TEST_CASE(t_12)
BOOST_CHECK(not ec);
}

BOOST_AUTO_TEST_CASE(t_13)
{
const char *const argv[] = {
"test", "--test=bla", nullptr
};
int argc = sizeof(argv) / sizeof(char*) - 1;

auto &config = mcfp::config::instance();

config.init(
"test [options]",
mcfp::make_option<std::string>("test", ""));

BOOST_CHECK_NO_THROW(config.parse(argc, argv));

BOOST_TEST(config.has("test"));
BOOST_TEST(config.get("test") == "bla");
}

// --------------------------------------------------------------------

BOOST_AUTO_TEST_CASE(file_1, * utf::tolerance(0.001))
Expand Down

0 comments on commit 4aa9550

Please sign in to comment.