ARROW-13296: [C++] Provide a reflection compatible enum replacement#10691
ARROW-13296: [C++] Provide a reflection compatible enum replacement#10691bkietz wants to merge 13 commits into
Conversation
lidavidm
left a comment
There was a problem hiding this comment.
I left some comments, but functionally, this looks good, and we can file a followup to simplify FunctionOptions with this.
|
I recommend avoiding macros whenever possible, but for completeness I'll note that we could replace // color.h
struct Color : EnumType<Color> {
using EnumType::EnumType;
static constexpr const char* kValues = R"(red green blue)";
};
// color.cc
constexpr const char* Color::kValues;with ARROW_ENUM(Color, red green blue); |
|
Quick question, why did 'try replacing an enum' ultimately stay reverted? Did you just mean to leave it as a followup? |
|
I can certainly replace one in this PR but I wasn't sure that'd be preferred. I was mostly using it as a test to ensure that the C++ builds could all pass with the replacement- if we want to include a replacement here then I'll need to repair the bindings as well |
|
Ah nah just wanted to make sure of the intent. Let's merge this? I'll file a JIRA to adjust the bindings and definitions. |
|
I want to provide one more tweak to make it easier to enable_if and provide a doccomment |
|
but I can just append that to the follow up |
|
If you wanna do that here that's no problem |
lidavidm
left a comment
There was a problem hiding this comment.
Thanks for working this out.
Provides an enum replacement with minimal reflection capabilities. These can be declared by inheriting from a helper with CRTP, including a static string literal data member containing the enum's values:
Values of enumerations declared in this way can be constructed from their string representations at compile time, and can be converted to their string representation for easier debugging/logging/and less repetitive boilerplate in the bindings and elsewhere mapping to/from user provided string values.
For example: