From 3e2ef78aec8e974fc1cc61db967f7a91fd08e55d Mon Sep 17 00:00:00 2001 From: Krzysztof Jakubowski Date: Sun, 6 Oct 2024 14:39:03 +0200 Subject: [PATCH] AnyConfig: added empty(), conversion to bool --- include/fwk/any_config.h | 3 +++ src/any_config.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/fwk/any_config.h b/include/fwk/any_config.h index 9ca33a4d..04e1985d 100644 --- a/include/fwk/any_config.h +++ b/include/fwk/any_config.h @@ -52,6 +52,9 @@ class AnyConfig { return default_value; } + bool empty() const; + explicit operator bool() const { return !empty(); } + CSpan> loadingErrors() const { return m_loading_errors; } void printErrors() const; diff --git a/src/any_config.cpp b/src/any_config.cpp index db2fdd9e..70ab82b3 100644 --- a/src/any_config.cpp +++ b/src/any_config.cpp @@ -51,6 +51,8 @@ void AnyConfig::set(string name, Any value) { m_elements[name] = std::move(value vector AnyConfig::keys() const { return m_elements.keys(); } +bool AnyConfig::empty() const { return m_elements.empty(); } + void AnyConfig::printErrors() const { for(auto &[name, err] : m_loading_errors) { print("Error while loading AnyConfig element: %\n", name);