diff --git a/CMakeLists.txt b/CMakeLists.txt index 53cd6a9..95a8ec1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.18) -project(figcone VERSION 3.1.0) +project(figcone VERSION 3.2.0) include(external/seal_lake) SealLake_IsInstallEnabled(INSTALL_FIGCONE_TREE) @@ -101,7 +101,7 @@ if (FIGCONE_USE_ALL OR FIGCONE_USE_JSON OR FIGCONE_USE_YAML OR FIGCONE_USE_TOML figcone::figcone_formats ) SealLake_AddDependencies( - figcone_formats 1.1.0 + figcone_formats 1.2.0 ) endif () diff --git a/formats/CMakeLists.txt b/formats/CMakeLists.txt index 40a50b1..80ec182 100644 --- a/formats/CMakeLists.txt +++ b/formats/CMakeLists.txt @@ -1,4 +1,4 @@ -project(figcone_formats VERSION 1.1.0) +project(figcone_formats VERSION 1.2.0) option(FIGCONE_USE_ALL "Enable all supported config formats" ON) option(FIGCONE_USE_JSON "Enable JSON config format" OFF) @@ -64,9 +64,9 @@ endif() if(FIGCONE_USE_ALL OR FIGCONE_USE_XML) SealLake_Import( - figcone_xml 1.1.0 + figcone_xml 1.2.0 GIT_REPOSITORY https://github.com/kamchatka-volcano/figcone_xml.git - GIT_TAG v1.1.0 + GIT_TAG v1.2.0 ) SealLake_Copy( WILDCARDS ${figcone_xml_SOURCE_DIR}/include/figcone_xml/* diff --git a/include/figcone/detail/dict.h b/include/figcone/detail/dict.h index 7d97a8f..085c4f1 100644 --- a/include/figcone/detail/dict.h +++ b/include/figcone/detail/dict.h @@ -38,11 +38,11 @@ class Dict : public INode { { hasValue_ = true; position_ = node.position(); + dictMap_ = {}; if (!node.isItem()) throw ConfigError{"Dictionary '" + name_ + "': config node can't be a list.", node.position()}; if constexpr (sfun::is_optional_v) dictMap_.emplace(); - maybeOptValue(dictMap_).clear(); for (const auto& paramName : node.asItem().paramNames()) { const auto& paramValue = node.asItem().param(paramName); diff --git a/include/figcone/detail/nodelist.h b/include/figcone/detail/nodelist.h index 039c569..8a74df7 100644 --- a/include/figcone/detail/nodelist.h +++ b/include/figcone/detail/nodelist.h @@ -42,6 +42,7 @@ class NodeList : public detail::INode { { hasValue_ = true; position_ = nodeList.position(); + nodeList_ = {}; if (!nodeList.isList()) throw ConfigError{"Node list '" + name_ + "': config node must be a list.", nodeList.position()}; if constexpr (sfun::is_optional::value) diff --git a/include/figcone/detail/paramlist.h b/include/figcone/detail/paramlist.h index 32cd997..18b6601 100644 --- a/include/figcone/detail/paramlist.h +++ b/include/figcone/detail/paramlist.h @@ -38,6 +38,7 @@ class ParamList : public IParam { { position_ = paramList.position(); hasValue_ = true; + paramListValue_ = {}; if constexpr (sfun::is_optional_v) paramListValue_.emplace(); diff --git a/tests/test_paramlist.cpp b/tests/test_paramlist.cpp index 25544ae..9c55b4f 100644 --- a/tests/test_paramlist.cpp +++ b/tests/test_paramlist.cpp @@ -406,4 +406,21 @@ TEST(TestParamList, DefaultValue) EXPECT_EQ(cfg.testIntList.at(2), 3); } +TEST(TestParamList, OverwriteDefaultValue) +{ + ///testStrList = [] + /// + auto tree = figcone::makeTreeRoot(); + tree->asItem().addParamList("testStrList", std::vector{}, {1, 1}); + tree->asItem().addParamList("testIntList", std::vector{"42", "43"}, {1, 1}); + auto parser = TreeProvider{std::move(tree)}; + auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase}; + auto cfg = cfgReader.read("", parser); + + ASSERT_EQ(cfg.testStrList.size(), 0); + ASSERT_EQ(cfg.testIntList.size(), 2); + EXPECT_EQ(cfg.testIntList.at(0), 42); + EXPECT_EQ(cfg.testIntList.at(1), 43); +} + } //namespace test_paramlist diff --git a/tests_static_refl/test_paramlist_cpp20.cpp b/tests_static_refl/test_paramlist_cpp20.cpp index a657add..d85f058 100644 --- a/tests_static_refl/test_paramlist_cpp20.cpp +++ b/tests_static_refl/test_paramlist_cpp20.cpp @@ -266,4 +266,21 @@ TEST(StaticReflTestParamList, DefaultValue) EXPECT_EQ(cfg.testIntList.at(2), 3); } +TEST(TestParamList, OverwriteDefaultValue) +{ + ///testStrList = [] + /// + auto tree = figcone::makeTreeRoot(); + tree->asItem().addParamList("testStrList", std::vector{}, {1, 1}); + tree->asItem().addParamList("testIntList", std::vector{"42", "43"}, {1, 1}); + auto parser = TreeProvider{std::move(tree)}; + auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase}; + auto cfg = cfgReader.read("", parser); + + ASSERT_EQ(cfg.testStrList.size(), 0); + ASSERT_EQ(cfg.testIntList.size(), 2); + EXPECT_EQ(cfg.testIntList.at(0), 42); + EXPECT_EQ(cfg.testIntList.at(1), 43); +} + } //namespace test_paramlist