Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/saucer/include/glaze/api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace glz

auto tuple_args = std::forward_as_tuple(std::forward<Args>(args)...);

for_each<N>([&](auto I) { std::get<I>(arguments) = &std::get<I>(tuple_args); });
for_each<N>([&]<auto I>() { std::get<I>(arguments) = &std::get<I>(tuple_args); });

if constexpr (std::is_pointer_v<Ret>) {
void* ptr{};
Expand Down
4 changes: 0 additions & 4 deletions deps/saucer/include/glaze/api/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ namespace glz
static constexpr type value{};
static constexpr const std::string_view get() { return {value.data, num_digits(x)}; }
};

/* instantiate numeric_string::value as needed for different numbers */
template <uint64_t x>
constexpr typename numeric_string<x>::type numeric_string<x>::value;
}

template <class T, T Value>
Expand Down
33 changes: 16 additions & 17 deletions deps/saucer/include/glaze/api/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "glaze/api/std/vector.hpp"
#include "glaze/api/tuplet.hpp"
#include "glaze/api/type_support.hpp"
#include "glaze/binary/read.hpp"
#include "glaze/binary/write.hpp"
#include "glaze/beve/read.hpp"
#include "glaze/beve/write.hpp"
#include "glaze/glaze.hpp"
#include "glaze/json/read.hpp"
#include "glaze/json/write.hpp"
Expand All @@ -36,20 +36,19 @@ namespace glz

[[nodiscard]] bool contains(const sv path) noexcept override
{
return detail::seek_impl([&](auto&&) {}, user, path);
return seek([&](auto&&) {}, user, path);
}

bool read(const uint32_t format, const sv path, const sv data) noexcept override
{
error_ctx pe{};
bool success;

if (format == json) {
success = detail::seek_impl([&](auto&& val) { pe = glz::read<opts{}>(val, data); }, user, path);
if (format == JSON) {
success = seek([&](auto&& val) { pe = glz::read<opts{}>(val, data); }, user, path);
}
else {
success =
detail::seek_impl([&](auto&& val) { pe = glz::read<opts{.format = binary}>(val, data); }, user, path);
success = seek([&](auto&& val) { pe = glz::read<opts{.format = BEVE}>(val, data); }, user, path);
}

if (success) {
Expand All @@ -64,11 +63,11 @@ namespace glz
bool write(const uint32_t format, const sv path, std::string& data) noexcept override
{
// TODO: Support write errors when seeking
if (format == json) {
return detail::seek_impl([&](auto&& val) { std::ignore = glz::write_json(val, data); }, user, path);
if (format == JSON) {
return seek([&](auto&& val) { std::ignore = glz::write_json(val, data); }, user, path);
}
else {
return detail::seek_impl([&](auto&& val) { std::ignore = glz::write_binary(val, data); }, user, path);
return seek([&](auto&& val) { std::ignore = glz::write_beve(val, data); }, user, path);
}
}

Expand Down Expand Up @@ -106,11 +105,11 @@ namespace glz

bool found = false;

detail::seek_impl(
seek(
[&](auto&& parent) {
using P = std::decay_t<decltype(parent)>;

detail::seek_impl(
seek(
[&](auto&& val) {
using V = std::decay_t<decltype(val)>;
if constexpr (std::is_member_function_pointer_v<V>) {
Expand Down Expand Up @@ -174,7 +173,7 @@ namespace glz
decltype(auto) unwrap(T&& val)
{
using V = std::decay_t<T>;
if constexpr (detail::nullable_t<V>) {
if constexpr (nullable_t<V>) {
if (val) {
return unwrap(*val);
}
Expand All @@ -197,7 +196,7 @@ namespace glz

glz::hash_t type_hash{};

const auto success = detail::seek_impl(
const auto success = seek(
[&](auto&& val) {
using V = std::decay_t<decltype(*unwrap(val))>;
if constexpr (std::is_member_function_pointer_v<V>) {
Expand Down Expand Up @@ -231,11 +230,11 @@ namespace glz
const auto parent_ptr = p.first;
const auto last_ptr = p.second;

detail::seek_impl(
seek(
[&](auto&& parent) {
using P = std::decay_t<decltype(parent)>;

detail::seek_impl(
seek(
[&](auto&& val) {
using V = std::decay_t<decltype(val)>;
if constexpr (std::is_member_function_pointer_v<V>) {
Expand Down Expand Up @@ -303,7 +302,7 @@ namespace glz
using T = std::tuple<Args...>;

constexpr auto N = sizeof...(Args);
for_each<N>([&](auto I) {
for_each<N>([&]<auto I>() {
using V = glz::tuple_element_t<I, T>;
ptr->emplace(name_v<V>, make_api<V>);
});
Expand Down
2 changes: 1 addition & 1 deletion deps/saucer/include/glaze/api/lib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace glz

struct lib_loader final
{
using create = glz::iface_fn (*)(void);
using create = glz::iface_fn (*)(void) noexcept;

iface api_map{};
std::vector<lib_t> loaded_libs{};
Expand Down
20 changes: 13 additions & 7 deletions deps/saucer/include/glaze/api/trait.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "glaze/api/hash.hpp"
#include "glaze/core/common.hpp"
#include "glaze/core/meta.hpp"
#include "glaze/core/reflect.hpp"
#include "glaze/util/string_literal.hpp"

namespace glz
Expand All @@ -21,9 +22,9 @@ namespace glz

static constexpr sv type_size_hash = hash128_v<int_to_sv_v<size_t, sizeof(T)>>; // must hash for consistent length

static constexpr sv major_version = hash128_i_v<version<T>[0]>; // must hash for consistent length
static constexpr sv minor_version = hash128_i_v<version<T>[1]>; // must hash for consistent length
static constexpr sv revision = hash128_i_v<version<T>[2]>; // must hash for consistent length
static constexpr sv major_version = hash128_i_v<version_v<T>.major>; // must hash for consistent length
static constexpr sv minor_version = hash128_i_v<version_v<T>.minor>; // must hash for consistent length
static constexpr sv revision = hash128_i_v<version_v<T>.patch>; // must hash for consistent length

#define std_trait(x) static constexpr sv x = to_sv<std::x##_v<T>>()
std_trait(is_trivial);
Expand All @@ -50,8 +51,6 @@ namespace glz
std_trait(is_aggregate);
#undef std_trait

// static constexpr sv cplusplus = empty_if<std::is_standard_layout_v<T>>(to_sv<__cplusplus>());

#ifdef __clang__
static constexpr sv clang = "clang";
#endif
Expand All @@ -64,7 +63,14 @@ namespace glz

static constexpr sv blank = ""; // to end possible macros

static constexpr sv members = glz::name_v<glz::detail::member_tuple_t<T>>;
static constexpr sv members = [] {
if constexpr (glaze_object_t<T> || reflectable<T>) {
return glz::name_v<detail::member_tuple_t<T>>;
}
else {
return "";
}
}();

static constexpr sv to_hash =
join_v<type_name_hash,
Expand Down Expand Up @@ -106,7 +112,7 @@ namespace glz

public:
static constexpr sv version_sv = join_v<v, major_version, comma, minor_version, comma, revision>;
static constexpr version_t version = ::glz::version<T>;
static constexpr version_t version = ::glz::version_v<T>;

static constexpr sv hash = hash128_v<to_hash>;
};
Expand Down
4 changes: 2 additions & 2 deletions deps/saucer/include/glaze/api/tuplet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace glz
{
template <class... T>
struct meta<glz::tuplet::tuple<T...>>
struct meta<glz::tuple<T...>>
{
static constexpr std::string_view name = []<size_t... I>(std::index_sequence<I...>) {
return join_v<chars<"glz::tuplet::tuple<">,
return join_v<chars<"glz::tuple<">,
((I != sizeof...(T) - 1) ? join_v<name_v<T>, chars<",">> : join_v<name_v<T>>)..., chars<">">>;
}(std::make_index_sequence<sizeof...(T)>{});
};
Expand Down
65 changes: 65 additions & 0 deletions deps/saucer/include/glaze/base64/base64.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Glaze Library
// For the license information refer to glaze.hpp

#pragma once

#include <array>
#include <string>
#include <string_view>
#include <vector>

namespace glz
{
inline constexpr std::string_view base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";

inline std::string read_base64(const std::string_view input)
{
std::string decoded_data;
static constexpr std::array<int, 256> decode_table = [] {
std::array<int, 256> t;
t.fill(-1);
for (int i = 0; i < 64; ++i) {
t[base64_chars[i]] = i;
}
return t;
}();

int val = 0, valb = -8;
for (unsigned char c : input) {
if (decode_table[c] == -1) break; // Stop decoding at padding '=' or invalid characters
val = (val << 6) + decode_table[c];
valb += 6;
if (valb >= 0) {
decoded_data.push_back((val >> valb) & 0xFF);
valb -= 8;
}
}

return decoded_data;
}

inline std::string write_base64(const std::string_view input)
{
std::string encoded_data;

int val = 0, valb = -6;
for (unsigned char c : input) {
val = (val << 8) + c;
valb += 8;
while (valb >= 0) {
encoded_data.push_back(base64_chars[(val >> valb) & 0x3F]);
valb -= 6;
}
}
if (valb > -6) {
encoded_data.push_back(base64_chars[((val << 8) >> (valb + 8)) & 0x3F]);
}
while (encoded_data.size() % 4) {
encoded_data.push_back('=');
}
return encoded_data;
}
}
11 changes: 11 additions & 0 deletions deps/saucer/include/glaze/beve.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Glaze Library
// For the license information refer to glaze.hpp

#pragma once

#include "glaze/beve/header.hpp"
#include "glaze/beve/ptr.hpp"
#include "glaze/beve/read.hpp"
#include "glaze/beve/wrappers.hpp"
#include "glaze/beve/write.hpp"
#include "glaze/thread/atomic.hpp"
Loading