Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fmtlib instead of tinyformat #914

Merged
merged 8 commits into from Jul 29, 2020
Merged

Use fmtlib instead of tinyformat #914

merged 8 commits into from Jul 29, 2020

Conversation

JonnyH
Copy link
Collaborator

@JonnyH JonnyH commented Jul 24, 2020

This is a step towards using fmt's new indexed format string API (e.g. "thing: {1} {2}" instead of "thing: %s %s"). Though it still uses the printf-compatible formats for now, at least the fmt library can support both in parallel, allowing us to phase over.

This then is more consistent with boost::locale's formatting API, which is the longterm goal to allow reorder-able translate-able strings in code.

Plus, fmt is proposed to be in c++20 (and accepted - for now :) - so likely to be more 'standard' and 'expected' in c++ going forward (and may even allow us to drop a non-standard-library dependency eventually)

Use version 7.0.1, as that's the latest tag at this time
In some places (e.g. the sound backend) we have more useful paths, in
others cast to void* first, so avoid possible confusion with custom
typed formatters
TODO: Move to the indexed formatting strings for fmtlib
This works around things (E.g. the fmtlib api) that expect UniChar to be
an encoded character, while we always just treat it as an integer
codepoint

Hopefully this can be removed completely (along with much of the UString
class itself) when c++20 char8_t and std::basic_string<char8_t> actually
define a 'utf8 encoded string'.
%I format specifier isn't supported by 'fmt'
"%s" should only be used for string-like types, %d for integers and %f
for floats.

Causes exceptions when fmt is being used instead of tinyformat (which
would silently ignore these?)
@JonnyH JonnyH merged commit 0d7d954 into OpenApoc:master Jul 29, 2020
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.

None yet

1 participant