v2.9.1
Initial Mustache support
- Added
glz::mustache
in #1102
Given a struct:
struct person
{
std::string first_name{};
std::string last_name{};
uint32_t age{};
bool hungry{};
};
Apply the struct to a template (layout) to replace mustaches with content:
std::string_view layout = R"({{first_name}} {{last_name}}, age: {{age}})";
person p{"Henry", "Foster", 34};
auto result = glz::mustache(p, layout).value_or("error");
expect(result == "Henry Foster, age: 34");
- Located at:
#include "glaze/mustache/mustache.hpp"
More advanced features of the mustache specification will be added in the future.
JSON concepts
- Added in #1105
Example:
static_assert(glz::json_string<std::string>);
static_assert(glz::json_string<std::string_view>);
static_assert(glz::json_object<my_struct>);
static_assert(glz::json_array<std::array<float, 3>>);
static_assert(glz::json_boolean<bool>);
static_assert(glz::json_number<float>);
static_assert(glz::json_integer<uint64_t>);
static_assert(glz::json_null<std::nullptr_t>);
glz::read_directory and glz::write_directory
- Adds the ability to read and write maps as directories of files
std::map<std::filesystem::path, my_struct> files{{"./dir/alpha.json", {}}, {"./dir/beta.json", {.i = 0}}};
expect(not glz::write_directory(files, "./dir"));
std::map<std::filesystem::path, my_struct> input{};
expect(not glz::read_directory(input, "./dir"));
expect(input.size() == 2);
expect(input.contains("./dir/alpha.json"));
expect(input.contains("./dir/beta.json"));
expect(input["./dir/beta.json"].i == 0);
- Added in #1109
Other Features
- glz::format_to for numbers by @stephenberry in #1106
Full Changelog: v2.9.0...v2.9.1