Releases: arturbac/simple_enum
v0.8.1
v0.8.0
v0.7.9
v0.7.8
v0.7.6
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
- Stephen Berry @stephenberry for great glaze library
- My best friend Jón Bjarni @jbbjarnason for awesome json rpc extension to glaze
v0.7.3
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
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 ingeneric_error_category
.
For detailed updates and migration guide, visit our documentation.
v0.6.4
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 astd::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 declareconsteval auto adl_enum_bounds(enum_type_name)
orsimple_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 thegeneric_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.
v0.6.1
v0.6.1 Release Notes
This update introduces a significant new feature aimed at enhancing error handling capabilities when working with std::expected<T, std::error_code>
.
New Features
- Generic Error Category Template: The new
generic_error_category
template is now available, providing a robust mechanism for defining error categories for use withexpected<T, std::error_code>
.
For more detailed information on how to utilize the generic_error_category
in your projects, please refer to documentation with detailed example instructions: generic_error_category
v0.6.0
v0.6.0 Release Notes
I am excited to announce the first release of simple_enum
v0.6.0! This initial launch introduces a robust enumeration library designed to enhance code clarity and efficiency.
What's New
- Initial release featuring core functionality for easy enum management.
- Designed for high performance and compatibility with various compilers.
- Comprehensive testing to ensure reliability and stability.
Documentation
For detailed information on simple_enum
and how to integrate it into your projects, please refer to the API documentation.
For feedback, issues, or contributions, feel free to visit the project on GitHub: simple_enum on GitHub.