Repository: conan-io/conan-center-index

Issue:
[request] <wise_enum>/3.0.0
### Package Details
  * Package Name/Version: **wise_enum/3.0.0**
  * Website: **https://github.com/quicknir/wise_enum#readme**
  * Source code: **https://github.com/quicknir/wise_enum*


### Description Of The Library / Tool
A small header only c++ library for reflective enum. simular to magic enum, but supports C++ 14/11


Discussion:
[wise_enum.zip](https://github.com/conan-io/conan-center-index/files/7110297/wise_enum.zip)


Resolving patch:
diff --git a/recipes/wise_enum/all/conanfile.py b/recipes/wise_enum/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wise_enum/all/conanfile.py
@@ -0,0 +1,69 @@
+from conans import ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+import os
+import sys
+
+required_conan_version = ">=1.33.0"
+
+class WiseEnumConan(ConanFile):
+    name = "wise_enum"
+    description = "Header-only C++11/14/17 library provides static reflection for enums, work with any enum type without any boilerplate code."
+    topics = (
+        "cplusplus",
+        "enum-to-string",
+        "string-to-enum"
+        "serialization",
+        "reflection",
+        "header-only",
+        "compile-time"
+    )
+    homepage = "https://github.com/quicknir/wise_enum"
+    url = "https://github.com/conan-io/conan-center-index"
+    license = "BSL-1.0"
+    settings = "compiler"
+    no_copy_source = True
+    
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def validate(self):
+        if self.settings.compiler.get_safe("cppstd"):
+            tools.check_min_cppstd(self, "11")
+        
+        compiler = str(self.settings.compiler)
+        compiler_version = tools.Version(self.settings.compiler.version)
+
+        minimal_version = {
+           "gcc": "5"
+        }
+        unsupported = {"Visual Studio"}
+        if compiler in unsupported:
+            raise ConanInvalidConfiguration(
+                "{} does not support  {} compiler".format(self.name, compiler)
+            )
+
+        if compiler in minimal_version and compiler_version < minimal_version[compiler]:
+            raise ConanInvalidConfiguration(
+                "{} requires {} compiler {} or newer [is: {}]".format(self.name, compiler, minimal_version[compiler], compiler_version)
+            )
+        
+
+    def package_id(self):
+        self.info.header_only()
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version],
+                  destination=self._source_subfolder, strip_root=True)
+        
+    def package(self):
+        self.copy("*.h", dst="include", src=self._source_subfolder)
+        self.copy("LICENSE", dst="licenses" , src=self._source_subfolder)
+        
+    def package_info(self):
+        self.cpp_info.names["cmake_find_package"] = "WiseEnum"
+        self.cpp_info.names["cmake_find_package_multi"] = "WiseEnum"
+        self.cpp_info.names["pkg_config"] = "WiseEnum"
+        self.cpp_info.components["_wise_enum"].names["cmake_find_package"] = "wise_enum"
+        self.cpp_info.components["_wise_enum"].names["cmake_find_package_multi"] = "wise_enum"
+        self.cpp_info.components["_wise_enum"].names["pkg_config"] = "WiseEnum"


Test patch:
diff --git a/recipes/wise_enum/all/test_package/CMakeLists.txt b/recipes/wise_enum/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/wise_enum/all/test_package/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.8)
+project(test_package CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup(TARGETS)
+
+find_package(WiseEnum REQUIRED CONFIG)
+
+add_executable(${PROJECT_NAME} test_package.cpp)
+set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
+target_link_libraries(${PROJECT_NAME} WiseEnum::wise_enum)
diff --git a/recipes/wise_enum/all/test_package/conanfile.py b/recipes/wise_enum/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/wise_enum/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package_multi"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/wise_enum/all/test_package/test_package.cpp b/recipes/wise_enum/all/test_package/test_package.cpp
new file mode 100644
--- /dev/null
+++ b/recipes/wise_enum/all/test_package/test_package.cpp
@@ -0,0 +1,79 @@
+#include <wise_enum.h>
+
+#include <cassert>
+#include <iostream>
+
+// Equivalent to enum Color {GREEN = 2, RED};
+namespace my_lib {
+WISE_ENUM(Color, (GREEN, 2), RED)
+}
+
+// Equivalent to enum class MoreColor : int64_t {BLUE, BLACK = 1};
+WISE_ENUM_CLASS((MoreColor, int64_t), BLUE, (BLACK, 1))
+
+// Inside a class, must use a different macro, but still works
+struct Bar {
+  WISE_ENUM_MEMBER(Foo, BUZ)
+};
+
+// Adapt an existing enum you don't control so it works with generic code
+namespace another_lib {
+enum class SomebodyElse { FIRST, SECOND };
+}
+WISE_ENUM_ADAPT(another_lib::SomebodyElse, FIRST, SECOND)
+
+struct Blub {
+    struct Flub {
+
+        int x = 0;
+
+    };
+};
+
+int main() {
+
+  // Number of enumerations:
+  static_assert(wise_enum::enumerators<my_lib::Color>::size == 2, "");
+  std::cerr << "Number of enumerators: "
+            << wise_enum::enumerators<my_lib::Color>::size << "\n";
+
+  // Iterate over enums
+  std::cerr << "Enum values and names:\n";
+  for (auto e : wise_enum::enumerators<my_lib::Color>::range) {
+    std::cerr << static_cast<int>(e.value) << " " << e.name << "\n";
+  }
+  std::cerr << "\n";
+
+  // Convert any enum to a string
+  std::cerr << wise_enum::to_string(my_lib::Color::RED) << "\n";
+
+  // Convert any string to an optional enum
+  auto x1 = wise_enum::from_string<my_lib::Color>("GREEN");
+  auto x2 = wise_enum::from_string<my_lib::Color>("Greeeeeeen");
+
+  assert(x1.value() == my_lib::Color::GREEN);
+  assert(!x2);
+
+  // Everything is constexpr, and a type trait is made available for easy use in
+  // enable_if/tag dispatch
+  static_assert(wise_enum::is_wise_enum<my_lib::Color>::value, "");
+  static_assert(!wise_enum::is_wise_enum<int>::value, "");
+  enum flub { blub, glub };
+  static_assert(!wise_enum::is_wise_enum<flub>::value, "");
+  // We made a regular enum wise!
+  static_assert(wise_enum::is_wise_enum<another_lib::SomebodyElse>::value, "");
+
+  // Assert underlying type
+  static_assert(
+      std::is_same<int64_t,
+                   typename std::underlying_type<MoreColor>::type>::value,
+      "");
+
+  // Full API available for adapted wise enums
+  for (auto e : wise_enum::enumerators<another_lib::SomebodyElse>::range) {
+    std::cerr << static_cast<int>(e.value) << " "
+              << wise_enum::to_string(e.value) << "\n";
+  }
+
+  return 0;
+}