From 27a80b121415aa287d4f7c39e7c1121f43c3bc3b Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Thu, 13 Dec 2018 02:00:13 +0900 Subject: [PATCH] rename get(table, key) to find() --- tests/test_get_related_func.cpp | 16 ++++++++-------- toml/get.hpp | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test_get_related_func.cpp b/tests/test_get_related_func.cpp index 70ba1ab..2feebdd 100644 --- a/tests/test_get_related_func.cpp +++ b/tests/test_get_related_func.cpp @@ -12,14 +12,14 @@ #include #include -BOOST_AUTO_TEST_CASE(test_find_and_get) +BOOST_AUTO_TEST_CASE(test_find) { { toml::value v(true); bool thrown = false; try { - toml::get(v, "key"); + toml::find(v, "key"); } catch(toml::type_error const& te) { @@ -30,16 +30,16 @@ BOOST_AUTO_TEST_CASE(test_find_and_get) { toml::table v{{"num", 42}}; - BOOST_CHECK_EQUAL(42, toml::get(v, "num")); - toml::get(v, "num") = 54; - BOOST_CHECK_EQUAL(54, toml::get(v, "num")); + BOOST_CHECK_EQUAL(42, toml::find(v, "num")); + toml::find(v, "num") = 54; + BOOST_CHECK_EQUAL(54, toml::find(v, "num")); } { toml::value v = toml::table{{"num", 42}}; - BOOST_CHECK_EQUAL(42, toml::get(v, "num")); - toml::get(v, "num") = 54; - BOOST_CHECK_EQUAL(54, toml::get(v, "num")); + BOOST_CHECK_EQUAL(42, toml::find(v, "num")); + toml::find(v, "num") = 54; + BOOST_CHECK_EQUAL(54, toml::find(v, "num")); } } diff --git a/toml/get.hpp b/toml/get.hpp index 69c7c0f..13d32d7 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -270,8 +270,8 @@ T get(const toml::value& v) template decltype(::toml::get(std::declval())) -get(const toml::table& tab, const toml::key& ky, - std::string tablename = "unknown table") +find(const toml::table& tab, const toml::key& ky, + std::string tablename = "unknown table") { if(tab.count(ky) == 0) { @@ -282,8 +282,8 @@ get(const toml::table& tab, const toml::key& ky, } template decltype(::toml::get(std::declval<::toml::value&>())) -get(toml::table& tab, const toml::key& ky, - std::string tablename = "unknown table") +find(toml::table& tab, const toml::key& ky, + std::string tablename = "unknown table") { if(tab.count(ky) == 0) { @@ -294,8 +294,8 @@ get(toml::table& tab, const toml::key& ky, } template decltype(::toml::get(std::declval<::toml::value&&>())) -get(toml::table&& tab, const toml::key& ky, - std::string tablename = "unknown table") +find(toml::table&& tab, const toml::key& ky, + std::string tablename = "unknown table") { if(tab.count(ky) == 0) { @@ -307,7 +307,7 @@ get(toml::table&& tab, const toml::key& ky, template decltype(::toml::get(std::declval())) -get(const toml::value& v, const toml::key& ky) +find(const toml::value& v, const toml::key& ky) { const auto& tab = ::toml::get(v); if(tab.count(ky) == 0) @@ -320,7 +320,7 @@ get(const toml::value& v, const toml::key& ky) } template decltype(::toml::get(std::declval<::toml::value&>())) -get(toml::value& v, const toml::key& ky) +find(toml::value& v, const toml::key& ky) { auto& tab = ::toml::get(v); if(tab.count(ky) == 0) @@ -333,7 +333,7 @@ get(toml::value& v, const toml::key& ky) } template decltype(::toml::get(std::declval<::toml::value&&>())) -get(toml::value&& v, const toml::key& ky) +find(toml::value&& v, const toml::key& ky) { auto tab = ::toml::get(std::move(v)); if(tab.count(ky) == 0)