Skip to content

Releases: stephenberry/glaze

2.5.1

15 Apr 20:52
Compare
Choose a tag to compare

Improvements

  • Smarter bucket size and larger struct support for naive_map by @stephenberry in #918
  • Other minor performance improvements

Fixes

  • Fixed a compile error on some versions of GCC with respect to the new glz::prettify_json

Full Changelog: v2.5.0...v2.5.1

2.5.0

11 Apr 23:05
Compare
Choose a tag to compare

Much faster Minify and Prettify

Important

The old glz::prettify and glz::minify functions are now deprecated. Instead use the new glz::prettify_json and glz::minify_json.

In most cases you can just replace glz::prettify with glz::prettify_json in your code. If you used a custom indentation width this is supported through the optional template parameter with glz::opts.

  • The new prettify method is over three times faster than the old one
  • The function names have been changed to support prettifying other formats in glaze
  • glz::opts as an optional template argument is now supported, changing formatting options to compile time
  • A compile time option new_lines_in_arrays turns off and on new line prettification in JSON arrays.

Full Changelog: v2.4.5...v2.5.0

2.4.5

10 Apr 14:11
Compare
Choose a tag to compare

C style array support

  • Support for writing/reading C style arrays with JSON and BEVE by @stephenberry in #910

Example unit tests:

struct struct_c_arrays
{
   uint16_t ints[2]{1, 2};
   float floats[1]{3.14f};
};

struct struct_c_arrays_meta
{
   uint16_t ints[2]{1, 2};
   float floats[1]{3.14f};
};

template <>
struct glz::meta<struct_c_arrays_meta>
{
   using T = struct_c_arrays_meta;
   static constexpr auto value = object(&T::ints, &T::floats);
};

suite c_style_arrays = [] {
   "uint32_t c array"_test = [] {
      uint32_t arr[4] = {1, 2, 3, 4};
      std::string s{};
      glz::write_json(arr, s);
      expect(s == "[1,2,3,4]") << s;
      std::memset(arr, 0, 4 * sizeof(uint32_t));
      expect(arr[0] == 0);
      expect(!glz::read_json(arr, s));
      expect(arr[0] == 1);
      expect(arr[1] == 2);
      expect(arr[2] == 3);
      expect(arr[3] == 4);
   };

   "const double c array"_test = [] {
      const double arr[4] = {1.1, 2.2, 3.3, 4.4};
      std::string s{};
      glz::write_json(arr, s);
      expect(s == "[1.1,2.2,3.3,4.4]") << s;
   };

   "double c array"_test = [] {
      double arr[4] = {1.1, 2.2, 3.3, 4.4};
      std::string s{};
      glz::write_json(arr, s);
      expect(s == "[1.1,2.2,3.3,4.4]") << s;
      std::memset(arr, 0, 4 * sizeof(double));
      expect(arr[0] == 0.0);
      expect(!glz::read_json(arr, s));
      expect(arr[0] == 1.1);
      expect(arr[1] == 2.2);
      expect(arr[2] == 3.3);
      expect(arr[3] == 4.4);
   };

   "struct_c_arrays"_test = [] {
      struct_c_arrays obj{};
      std::string s{};
      glz::write_json(obj, s);
      expect(s == R"({"ints":[1,2],"floats":[3.14]})") << s;

      obj.ints[0] = 0;
      obj.ints[1] = 1;
      obj.floats[0] = 0.f;
      expect(!glz::read_json(obj, s));
      expect(obj.ints[0] == 1);
      expect(obj.ints[1] == 2);
      expect(obj.floats[0] == 3.14f);
   };

   "struct_c_arrays_meta"_test = [] {
      struct_c_arrays_meta obj{};
      std::string s{};
      glz::write_binary(obj, s);

      obj.ints[0] = 0;
      obj.ints[1] = 1;
      obj.floats[0] = 0.f;
      expect(!glz::read_binary(obj, s));
      expect(obj.ints[0] == 1);
      expect(obj.ints[1] == 2);
      expect(obj.floats[0] == 3.14f);
   };
};

Full Changelog: v2.4.4...v2.4.5

2.4.4

03 Apr 22:07
Compare
Choose a tag to compare

See release v2.4.3 for the new time tracing/profiling support.

time tracing documentation

This update adds global tracing helpers for an alternative API:

It can be bothersome to pass around a glz::trace instance. A global instance is available with a separate API to avoid needing to pass a trace instance around.

glz::disable_trace() - Turns off the global tracing.
glz::enable_trace() - Turns on the global tracing if it had been disabled (enabled by default).
glz::trace_begin("my event") - Add a begin event for "my event"
glz::trace_end("my event") - Add an end event for "my event"
glz::trace_async_begin("my event") - Add an async_begin event for "my event"
glz::trace_async_end("my event") - Add an aysnc_end event for "my event"

Two structs are also provided that will automatically add the end events when they leave scope:
glz::duration_trace
glz::async_trace

Example:

void my_function_to_profile()
{
   glz::duration_trace trace{"my function to profile"};
   // do stuff here
   // glz::duration_trace will automatically add the end event when it goes out of scope.
}

Then, somewhere at the end of your program, write your global trace to file:

const auto ec = glz::write_file_trace("trace.json", std::string{});
if (ec) {
  std::cerr << "trace output failed\n";
}

by @stephenberry in #906

Full Changelog: v2.4.3...v2.4.4

2.4.3

03 Apr 18:43
Compare
Choose a tag to compare

New top level read/write concepts

  • Concepts are used higher up in API to reduce the length of compilation errors when a type is not supported and requires a glz::meta
    by @stephenberry in #904

New: Time trace, profiling (visualize with Perfetto)

Time trace documentation

glz::trace trace{};
trace.begin("my event name");
// run computations here
trace.end("my event name");

auto ec = glz::write_file_json(trace, "trace.json", std::string{});

by @stephenberry in #905

Improvements

  • Adding glz::help to allow developers to provide users with cli_menu input help by @stephenberry in #893
  • static_assert asio header when using glaze_asio.hpp by @stephenberry in #902
  • glz::beve_to_json support for matrices and complex numbers by @stephenberry in #903

Full Changelog: v2.4.2...v2.4.3

2.4.2

01 Apr 19:26
Compare
Choose a tag to compare

Much faster file reading

Full Changelog: v2.4.1...v2.4.2

2.4.1

01 Apr 17:14
Compare
Choose a tag to compare

Significant std::vector initial load performance improvement

  • When reading into a std::vector we now use an intermediate buffer when reading beyond the current capacity. This ensure that we don't continue to reallocate our vector and move data.
  • This also results in less long term memory used, because we now only allocate the capacity used.
    by @stephenberry in #898

Improvements

Full Changelog: v2.4.0...v2.4.1

2.4.0

27 Mar 21:35
Compare
Choose a tag to compare

Major Feature: Volatile Support

  • Glaze now supports volatile qualifiers. This was added for proper serialization/deserialization of hardware registers.
  • This volatile support includes glz::meta reflection and pure reflection.
  • glz::volatile_array has been added under glaze/hardware/volatile_array.hpp
    • glz::volatile_array has the same API as std::array, but uses volatile memory and provides volatile methods
  • JSON pointer syntax access also supports volatile.

When reading into arithmetic types, we parse into a temporary and then assign, this ensures that side affects from hardware looking at variables will not occur until the parse has completed and the assignment is made.

by @stephenberry in #885, #886, #890, #891

More New Features

Full Changelog: v2.3.3...v2.4.0

2.3.3

26 Mar 15:13
Compare
Choose a tag to compare

User Facing Change

It is convention and more flexible to not force a new line at the end of the error report string.

Improvements

Full Changelog: v2.3.2...v2.3.3

2.3.2

21 Mar 22:38
Compare
Choose a tag to compare

New Feature

Added initial glz::beve_to_json, which will directly convert BEVE into JSON, which is helpful for inspecting binary data. This is not yet fully featured, but it already supports most types.

Unit test sample of feature:

std::map<std::string, int> v = {{"first", 1}, {"second", 2}, {"third", 3}};
std::string buffer{};
glz::write_binary(v, buffer);

std::string json{};
expect(!glz::beve_to_json(buffer, json));
expect(json == R"({"first":1,"second":2,"third":3})") << json;

expect(!glz::beve_to_json<glz::opts{.prettify = true}>(buffer, json));
expect(json == //
R"({
 "first": 1,
 "second": 2,
 "third": 3
})") << json;

Fixes

  • Fix for necessary <algorithm> include in string_literal.hpp by @stephenberry in #856

Full Changelog: v2.3.1...v2.3.2