Skip to content

Releases: stephenberry/glaze

2.3.1

20 Mar 23:25
Compare
Choose a tag to compare

New std::expected Support

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

Fixes

Full Changelog: v2.3.0...v2.3.1

2.3.0

18 Mar 21:47
Compare
Choose a tag to compare

Breaking JSON Schema glz::schema Member Name Updates

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

Variant JSON Schema Improvements

Full Changelog: v2.2.5...v2.3.0

2.2.5

18 Mar 14:34
Compare
Choose a tag to compare

Fixes

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

13 Mar 20:15
Compare
Choose a tag to compare

Hotfix for error when parsing unknown key prefixed by known key


REPE RPC (unstable) development breaking changes

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

13 Mar 18:44
Compare
Choose a tag to compare

Improvements

Minor Improvements

Fixes

Full Changelog: v2.2.2...v2.2.3

2.2.2

11 Mar 13:03
Compare
Choose a tag to compare

Breaking Change

  • glaze/json/study.hpp must now be explicitly included. It is not included by default in glaze/json.hpp or glaze/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

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

Full Changelog: v2.2.1...v2.2.2

2.2.1

06 Mar 21:25
Compare
Choose a tag to compare

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 to init_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

04 Mar 21:29
Compare
Choose a tag to compare

Improvements

  • Adding get function that returns an expected for glz::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

29 Feb 17:21
Compare
Choose a tag to compare

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

Full Changelog: v2.1.8...v2.1.9

2.1.8

26 Feb 19:13
Compare
Choose a tag to compare
  • 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