loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 12 forks source link

Migrate from using boost::format to std::format (via fmt) #89

Closed Ortham closed 1 year ago

Ortham commented 1 year ago

C++20 gained a standard formatting library that's inspired by/based on the fmt library, and while I'm not planning to move to C++20 yet, it would be good to be forward-compatible. libloot already uses fmt indirectly through spdlog, but it uses Boost Format for formatting metadata messages that contain placeholders.

Unfortunately, Boost Format uses a different syntax for placeholders, so masterlists (and possibly userlists, though it's not possible to create messages that use substitutions through LOOT's UI) will need to be migrated. Fortunately a quick scan of the skyrimse masterlist suggests this should be a simple search/replace, as I didn't see any usage that didn't match the regex %[1-3]%. However, Boost Format is 1-indexed, fmt allows optional 0-indexed placeholders or named arguments, and std::format only optionally allows 0-indexed placeholders, so e.g. %1% becomes {0}.

Since this is a backward-incompatible change to the masterlists, it would be good to batch it up with other future syntax changes.

Ortham commented 1 year ago

Done as of dc8bb0f854f521874762e7930358c8827d058251. I've decided to keep support for the old syntax for backwards-compatibility, it'll get converted to the new syntax when the masterlist/userlist is parsed. That'll simplify upgrading to the new version of libloot and transitioning to the new syntax. I'll probably remove that code for the release after next.