Skip to content

Releases: arturbac/simple_enum

v0.8.4

23 Nov 14:53
Compare
Choose a tag to compare

What's Changed since v0.8.3

  • fixed version number definition

v0.8.3

17 Nov 14:51
f6c076e
Compare
Choose a tag to compare

What's Changed since v0.8.1

v0.8.1

25 Sep 21:16
3ef005c
Compare
Choose a tag to compare

What's Changed

v0.8.0

20 Jul 13:09
Compare
Choose a tag to compare

v0.8.0 Release Notes

  • features dual support for glaze 2.9 and 3.x: by default 3.x with ability of cmake option to switch to old 2.x
  • adds simpilified declaration of error enums: using only adl_enum_bounds function

v0.7.9

04 Apr 04:48
Compare
Choose a tag to compare

v0.7.9 Release Notes

  • Update: Update for latest glaze concepts update v2.4.3 glaze for enumeration handling with json/json rpc v2

v0.7.8

28 Mar 13:58
Compare
Choose a tag to compare

v0.7.8 Release Notes

  • Improvements: Cleaned up some warnings in tests
  • Bug fixes: fixed invalid calculation in enum_index for non 0 based enum

v0.7.6

26 Mar 20:34
Compare
Choose a tag to compare

v0.7.6 Release Notes

  • New feature: integration of simple_enum with glaze for enumeration handling with json/json rpc v2

For detailed information, visit documentation.

glaze JSON-RPC v2 example with schema support powered by simple enum names without any additional declarations than only defining bounds for enum.

The following example illustrates how to use the JSON RPC implementation with a defined schema including enumeration fields:

enum class Color
  {
  Red,
  Green,
  Blue
  };

consteval auto adl_enum_bounds(Color)
  {
  using enum Color;
  return simple_enum::adl_info{Red, Blue};
  }

struct test_struct
  {
  Color color_field;
  };
static void json_rpc_w_schema_example()
  {
  static constexpr glz::string_literal method1_name = "method";
  using rpc_method1 = glz::rpc::method<method1_name, request_t, response_t>;

  glz::rpc::server<rpc_method1> server;
  glz::rpc::client<rpc_method1> client;

  server.on<method1_name>([](request_t const & params) { return response_t{.response_color = params.color}; });

  std::string uuid{"42"};
  auto [request_str, inserted] = client.request<method1_name>(
    uuid,
    request_t{.color = Color::Green, .value ={}},
    [](glz::expected<response_t, glz::rpc::error> value, glz::rpc::id_t id) -> void {}
  );
  
  std::cout << "request :"  << request_str << std::endl;  // prints request JSON string
  std::string response = server.call(request_str);
  
  std::cout << "response :" << response << std::endl;  // prints response JSON string
  
  std::cout << "request schema :" << glz::write_json_schema<request_t>() << std::endl;
  }

schema returned

{
  "type": [
    "object"
  ],
  "properties": {
    "color": {
      "$ref": "#/$defs/Color"
    },
    "value": {
      "$ref": "#/$defs/int32_t"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "Color": {
      "type": [
        "string"
      ],
      "oneOf": [
        {
          "const": "Red"
        },
        {
          "const": "Green"
        },
        {
          "const": "Blue"
        }
      ]
    },
    "int32_t": {
      "type": [
        "integer"
      ]
    }
  }
}

Special Thanks

for collaborative effort on making this whole functionality possible

v0.7.3

23 Mar 09:28
Compare
Choose a tag to compare

v0.7.3 Release Notes

  • Improvements: added adl_decl_error_code functionality that allows you to declare enums as std::error_code using argument-dependent lookup (ADL) instead of std::is_error_code_enum specialization. This enhancement simplifies the process of using enums for error representation, making your code cleaner and more intuitive.
  • Improvements: Helpers for expected/unexpected with std::error_code: To further aid in error handling, I've introduced helper function and typedefs for working with expected and unexpected in conjunction with std::error_code.

For detailed information, visit documentation.

v0.7.0

19 Mar 23:55
Compare
Choose a tag to compare

v0.7.0 Release Notes

  • Improvements: Simplified error_category declaration by automatically deducing the category name from the type name.
  • Improvements: Added support for custom category names in generic_error_category.
  • Breaking Changes: Introduced namespace v0_7 due to non-backward-compatible API and ABI updates in generic_error_category.

For detailed updates and migration guide, visit our documentation.

v0.6.4

19 Mar 22:10
Compare
Choose a tag to compare

v0.6.4 Release Notes

New Features

Added enumeration_name_v

  • An addition in this version is the introduction of enumeration_name_v. Compile time constant that provides a way to obtain the name of an enumeration type as a std::string_view.
template<concepts::strong_enum enum_type>
inline constexpr std::string_view enumeration_name_v;

Improvements

Core Functionalities Separation

  • The core functionalities of Simple Enum have been separated from the main header file into a new core.hpp. This means you can now declare consteval auto adl_enum_bounds(enum_type_name) or simple_enum::info<enum_type_name>, or use concepts from simple_enum by including just this core header.

Tuning

  • I've made a small tuning adjustment by adding the [[clang::no_destroy]] attribute for the generic_error_category singleton. This attribute prevents the static de-initialization of the object, which can improve the termination performance of applications using Simple Enum, particularly in environments where clean-up time is critical.