Releases: stephenberry/glaze
2.5.1
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
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
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
See release v2.4.3 for the new time tracing/profiling support.
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
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)
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
2.4.1
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
- Reducing asio latency by @stephenberry in #894
Full Changelog: v2.4.0...v2.4.1
2.4.0
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 underglaze/hardware/volatile_array.hpp
glz::volatile_array
has the same API asstd::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
- binary support for glz::merge by @stephenberry in #889 (thanks @fregate)
- support for std::filesystem::path by @stephenberry in #892 (thanks @dbraeckelmann)
Full Changelog: v2.3.3...v2.4.0
2.3.3
User Facing Change
- Removed trailing new line from glz::format_error by @stephenberry in #881
It is convention and more flexible to not force a new line at the end of the error report string.
Improvements
- Faster compilation from internal cleanup
- Support for custom specialization on enumerations #874 by @arturbac in #875, #876, #880
- Handling tabs in error formatting context by @stephenberry in #877
Full Changelog: v2.3.2...v2.3.3
2.3.2
New Feature
- BEVE to JSON converter by @stephenberry in #859
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