Skip to content

Commit

Permalink
AnyConfig: added empty(), conversion to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
nadult committed Oct 6, 2024
1 parent 2dcf1b8 commit 3e2ef78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/fwk/any_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class AnyConfig {
return default_value;
}

bool empty() const;
explicit operator bool() const { return !empty(); }

CSpan<Pair<string, Error>> loadingErrors() const { return m_loading_errors; }
void printErrors() const;

Expand Down
2 changes: 2 additions & 0 deletions src/any_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void AnyConfig::set(string name, Any value) { m_elements[name] = std::move(value

vector<string> 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);
Expand Down

0 comments on commit 3e2ef78

Please sign in to comment.