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

Add fmtlib dependency #1070

Closed
Tracked by #997
feltech opened this issue Sep 4, 2023 · 2 comments · Fixed by #1079
Closed
Tracked by #997

Add fmtlib dependency #1070

feltech opened this issue Sep 4, 2023 · 2 comments · Fixed by #1079
Assignees

Comments

@feltech
Copy link
Member

feltech commented Sep 4, 2023

What

Add fmtlib (private) dependency.

Why

fmt allows for easy, safe string substitution in C++, adding advanced formatting functionality (e.g. rounding), and reducing bloat, e.g.

    std::string message = "Parameter lists must be of the same length: ";
    message += std::to_string(entityReferences.size());
    message += " entity references vs. ";
    message += std::to_string(traitsHints.size());
    message += " traits hints.";
    throw std::out_of_range{message};

Formatting user-defined types can be added in a variety of ways with fmt. Perhaps most portable is operator<< support.

However, fmt already supports several types, including container types, out of the box, so hooks for custom types might not be necessary at this point.

ACs

  • fmtlib installed via Conan.
  • fmtlib as a private, header-only dependency in CMake
  • Brief check of the out-of-the box support for printing our types (e.g. TraitSet)
  • Update a single string somewhere to prove it works

Out of scope

  • Updating existing string formatting
  • Implementing complex user-defined type formatting hooks.
@feltech feltech changed the title Add libfmt dependency and implement custom type formatters Add fmtlib dependency and implement custom type formatters Sep 4, 2023
@feltech feltech changed the title Add fmtlib dependency and implement custom type formatters Add fmtlib dependency Sep 5, 2023
@feltech
Copy link
Member Author

feltech commented Sep 5, 2023

Added #1075 make broader use of fmtlib

@feltech feltech self-assigned this Sep 5, 2023
feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 5, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
@feltech feltech mentioned this issue Sep 5, 2023
1 task
feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 5, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 5, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 5, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 5, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
@feltech
Copy link
Member Author

feltech commented Sep 5, 2023

Posted upstream re. unexpected forcibly exported symbol: fmtlib/fmt#3626

feltech added a commit to feltech/OpenAssetIO that referenced this issue Sep 7, 2023
Closes OpenAssetIO#1070. fmtlib allows for easy, safe string substitution in C++,
adding advanced formatting functionality (e.g. rounding), and reducing
bloat.

So add as a new private build-only header-only dependency.

Using header-only increases compile times, but subjectively it's not
noticeable, and has the benefit of avoiding a possible public library
dependency (if OpenAssetIO is built as a static library).

Tweak a single existing, tested, log string to make use of libfmt, to
ensure basic usage is validated.

Signed-off-by: David Feltell <david.feltell@foundry.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant