Skip to content

Modernize Poco::Util and clean up some code duplications#5153

Merged
matejk merged 20 commits intomainfrom
util-cleanup
Jan 6, 2026
Merged

Modernize Poco::Util and clean up some code duplications#5153
matejk merged 20 commits intomainfrom
util-cleanup

Conversation

@frwilckens
Copy link
Copy Markdown
Member

@frwilckens frwilckens commented Jan 5, 2026

This PR modernizes the code in Poco::Util by using more C++ 11 and later idioms such as

  • type aliases
  • deleted and defaulted special member functions
  • override annotations
  • auto variables
  • range-for loops
  • default member initializers
  • constructor delegation
  • initializer lists
  • lambdas

It also does some refactoring to reduce duplicated code:

  • In classes Application and ServerApplication, arguments of form int argc, char** argv or int argc, wchar_t** argv are now immediately transformed into a canonical ArgVec before doing anything substantial. No longer
    is there duplicated code in (for example) int ServerApplication::run(int argc, char** argv),
    int ServerApplication::run(const ArgVec& args), and int ServerApplication::run(int argc, wchar_t** argv).

  • Since ConfigurationView and LocalConfigurationView have almost identical code, they now derive from an intermediate class AbstractConfigurationView that provides the common methods.

SystemConfiguration now uses an explicit map of functions instead of long if-else chains. Since all tags
are used only once, we no longer need to define them in a list of static const std::string variables.

AbstractConfiguration::keys, Application::getApplicationPath and Application::getApplicationDirectory
got overloads that return the requested information instead of filling a provided data structure. The old
versions still exist for downward compatibility. (I assume they exist because it was expensive before C++11 to return a large data structure from a function.)

Overall the PR reduces the code size by about 500 lines and makes it more maintainable and easier to read.

@frwilckens
Copy link
Copy Markdown
Member Author

I also added a template to Poco::Util::Units:

template <typename V, typename U> Value<V, U> abs(const Value<V, U>& a) { return Value<V, U>(std::abs(a.get())); }
It is analogous to the sqrt template and the provided arithmetic operators. Without it, even std::abs(val) does not compile when val is a value with unit.

frwilckens and others added 2 commits January 4, 2026 22:56
…rfaces

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@frwilckens frwilckens marked this pull request as ready for review January 5, 2026 17:11
@frwilckens frwilckens requested review from aleks-f and matejk January 5, 2026 17:11


Keys keys(const std::string& key = std::string()) const;
// Returns the names of all subkeys under the given key.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be /// instead of //

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sure, I fixed that.

Copy link
Copy Markdown
Contributor

@matejk matejk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just one minor comment about function documentation.

@matejk
Copy link
Copy Markdown
Contributor

matejk commented Jan 6, 2026

@frwilckens , is the PR ready to be merged?

@frwilckens
Copy link
Copy Markdown
Member Author

Yes, it' ready.

@matejk matejk added this to the Release 1.15.0 milestone Jan 6, 2026
@matejk matejk merged commit 7f03ba5 into main Jan 6, 2026
92 checks passed
@matejk matejk deleted the util-cleanup branch January 6, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants