Commits


Benjamin Kietzman authored and David Li committed 975f4597992
ARROW-13296: [C++] Provide a reflection compatible enum replacement 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: ```c++ struct Color : EnumType<Color> { using EnumType::EnumType; static constexpr char* kValues = "red green blue"; }; ``` 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: ```c++ int get_hex_value() { std::string input; std::cin >> input; switch (*Color(repr)) { case *Color("red"): return 0xff0000; case *Color("green"): return 0x00ff00; case *Color("blue"): return 0x0000ff; default: std::cout << "Don't know that one; input hex value\n"; std::cin >> std::hex >> input; return std::stoi(input); } } ``` Closes #10691 from bkietz/13296-Provide-reflection-compat Authored-by: Benjamin Kietzman <bengilgit@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>