Releases: stephenberry/glaze
2.3.1
New std::expected
Support
- Support for glz/std::expected with JSON by @stephenberry in #851
The expected value will be directly written/read as JSON. The unexpected value will be written/read as an object with the key "unexpected"
.
Example of a string error from an expected (e.g. std::expected<MyStruct, std::string>
):
{"unexpected":"my error"}
Improvements
- Adding support for glz::custom in repe registry by @stephenberry in #844
- Simplifying and cleaning up includes by @stephenberry in #849
Fixes
- Fix for std::complex reading with whitespace by @stephenberry in #852
Full Changelog: v2.3.0...v2.3.1
2.3.0
Breaking JSON Schema glz::schema
Member Name Updates
- Matching glz::schema names to JSON schema specification by @stephenberry in #841
In C++ we are now matching our
glz::schema
variable names to their corresponding JSON schema keys. This makes the code easier to follow and matches the generated JSON.
glz::json_schema compile time validation
- Compile time validation of JSON schema fields by @stephenberry in #842
Variant JSON Schema Improvements
- Variant cleanup and code de-duplication by @stephenberry in #835
- JSON schema fix for reflected objects in variants by @stephenberry in #836
- Properly limiting variant scope in JSON schema by @stephenberry in #838
- Removed unnecessary string ref in variant schema by @stephenberry in #839
- Requiring variant tag by @stephenberry in #840
Full Changelog: v2.2.5...v2.3.0
2.2.5
Fixes
- Added back support for glz::expected return in jsonrpc by @stephenberry in #834
Example:
server.on<"foo">([](const foo_params& params) -> glz::expected<foo_result, glz::rpc::error> {
if (params.foo_a == 10)
{
return glz::unexpected(glz::rpc::error{glz::rpc::error_e::invalid_params, "my error"});
}
else {
return foo_result{.foo_c = true, .foo_d = "new world"};
}
});
Full Changelog: v2.2.4...v2.2.5
2.2.4
Hotfix for error when parsing unknown key prefixed by known key
- by @stephenberry in #831
REPE RPC (unstable) development breaking changes
- Removed direct function registration in repe registry by @stephenberry in #829
After testing and experimenting with registry handling, I've decided to remove the direct function registration in lieu of the struct (JSON-like) registration.
Why?
- I want as few as possible means of setting up the registry, to simplify the code and make it more straightforward for users.
JSON pointer syntax from object hierarchy will enable intelligent thread locking when multiple clients are making calls asynchronously. - Using direct registration gives less information than the object hierarchy and JSON pointer syntax, which will limit the performance and thread lock reduction.
- Using structs is how the rest of Glaze works, and enables glz::meta to be used with the RPC system. This makes setting compile time handling much more flexible and powerful.
Full Changelog: v2.2.3...v2.2.4
2.2.3
Improvements
- JSON schema now validates custom tag and ids (for variants) @stephenberry in #822
Minor Improvements
- Added glz::validate_jsonc by @stephenberry in #817
- Added void(void) client.call(header) by @stephenberry in #818
- Adding support for reflectable wrappers with REPE registry by @stephenberry in #820
Fixes
- Adding const to std::exception catching by @stephenberry in #821
Full Changelog: v2.2.2...v2.2.3
2.2.2
Breaking Change
glaze/json/study.hpp
must now be explicitly included. It is not included by default inglaze/json.hpp
orglaze/glaze.hpp
, in order to remove threading dependencies for most users.- This only affects users implementing the study tools, which is not common.
- by @stephenberry in #811
Improvements
- cli_menu provides more help about the expected type by @stephenberry in #810
- Faster and cleaner code for naming std types by @stephenberry in #813
- Adding partial write support for JSON like binary by @stephenberry in #815
Example of partial writing:
struct animals_t
{
std::string lion = "Lion";
std::string tiger = "Tiger";
std::string panda = "Panda";
struct glaze
{
using T = animals_t;
static constexpr auto value = glz::object(&T::lion, &T::tiger, &T::panda);
};
};
struct zoo_t
{
animals_t animals{};
std::string name{"My Awesome Zoo"};
struct glaze
{
using T = zoo_t;
static constexpr auto value = glz::object(&T::animals, &T::name);
};
};
"partial write"_test = [] {
static constexpr auto partial = glz::json_ptrs("/name", "/animals/tiger");
zoo_t obj{};
std::string s{};
const auto ec = glz::write_json<partial>(obj, s);
expect(!ec);
expect(s == R"({"animals":{"tiger":"Tiger"},"name":"My Awesome Zoo"})") << s;
};
Fixes
- Using native path for LoadLibraryW by @stephenberry in #814
Full Changelog: v2.2.1...v2.2.2
2.2.1
glz::raw_or_file
glz::raw_or_file is somewhat like a glz::file_include, but also handles serialization. The purpose is to allow JSON files to be optionally referred to within higher level configuration files, but once loaded, the files behave as glz::raw_json, where the format does not need to be understood until deserialized.
How glz::raw_or_file behaves:
If the input is a valid file path within a string, the entire file will be read into a std::string within the glz::raw_or_file member. The internal buffer does not escape characters, as it is handled like glz::raw_json.
If the input is not a valid file path or not a string, the value is simply validated and stored like glz::raw_json
When serialized, the value is dumped like glz::raw_json, which means it will look like the input file was copied and pasted into the higher level document.
Benefits of this approach include:
- The layout for the file loaded into glz::raw_or_file does not need to be known by the program. As long as it is valid JSON it can be passed along.
- The serialized output after loading the file looks like a combined file, which is easier to read and format than an escaped string version of the file. It is also more efficient because escaping/unescaping doesn't need to be performed, only validation.
by @stephenberry in #808
glz::asio_server improvements
- API changes make it work more like
glz::asio_client
, which allows setup from a JSON read separate from initialization init
for initializing the registry has been renamed toinit_registry
- The port can now be set by the user. It was hardcoded before <face slap!>
by @stephenberry in #809
Full Changelog: v2.2.0...v2.2.1
2.2.0
Improvements
- Adding
get
function that returns an expected forglz::asio_client
by @stephenberry in #805 - Supporting member function pointer reflection and handling in
repe::registry
by @stephenberry in #806
Full Changelog: v2.1.9...v2.2.0
2.1.9
Major improvements and changes to REPE and glz::asio
RPC code
The new REPE RPC code is under active development. This release improves the API for glz::asio_client
and glz::asio_server
, and allows structs to be registered with the RPC registry. RPC functions will be automatically generated for all fields in your struct, where read or write calls can be made by using a method name that matches the JSON pointer to your member.
- Changes made in: #803
Improvements
- glz::opts support for write_json_schema by @stephenberry in #802
Full Changelog: v2.1.8...v2.1.9
2.1.8
- Reduced unnecessary or duplicate includes to help improve compile times.
CLI Menu Improvements
-
Only serialize structs as menus if they are non-invocable by @stephenberry in #795
-
Supporting user code throwing exceptions in cli_menu by @stephenberry in #797
-
Default pretty printing from cli_menu and support for glz::opts by @stephenberry in #800
-
Support non-const inputs to cli_menu and std::cin in user functions by @stephenberry in #801
Full Changelog: v2.1.7...v2.1.8