Introduce magic_enum for enum <--> string conversion#3275
Introduce magic_enum for enum <--> string conversion#3275
Conversation
|
Looks nice 👍 Left a few small suggestions.
Some cases could be dealt with via interface design rather than software engineering. Eg. This functionality could easily be changed from |
Going through all the commands, the only other two places where I saw this problem were: peaksconvert.cpp and mtnormalise.cpp. |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
Proposal to change command-line interfaces for better compatibility with
Given the list is small, changes are non-intrusive, and it would facilitate making |
How about |
|
That's probably what I subconsciously meant, but my conscious somehow landed on the wrong word 😅 |
Rename format_t::unit3vector -> format_t::unitcartesian and format_t::3vector -> format_t::cartesian
|
Bikeshedding question: lots of places in the CLI options now use |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
Somewhat inconsistent across the code base. I'd probably opt for including a space myself: it's intended for human reading, not parsing (anything wanting to parse that information should instead be invoking |
|
All feedback has been addressed, documentation rebuilt to follow CLI changes and all tests are now passing. This should be ready to be merged. |
|
clang-tidy review says "All clean, LGTM! 👍" |
|
Thoughts on removing |
|
Yes, that is the end result I would like to see too. From a quick grep, I can see there are still 26 instances of using the old overload of |
|
clang-tidy review says "All clean, LGTM! 👍" |
This PR addresses the issue raised in #3264. It adds
magic_enum, a C++17 header-only library for enum to string conversions, as a dependency. The changes include the addition of new templated wrapper functions to perform enum <--> string inmrtrix.h. As an initial step (and to limit the scope of this PR), I have replaced several existing string-based usages with enums. These changes are limited tocpp/cmd; no code incpp/coreis affected at this stage, although that could be considered in a future PR.One issue I encountered is that some existing string values begin with a number. Since C++ identifiers cannot start with a digit, cases such as "2d" and "3d" in
mrdegibbscannot be mapped directly to enum names. Handling these cases would require either custom parsing logic or changes to the CLI options. I have not made any changes for those cases in this PR.