feat(reflect-cpp): Switched from glaze -> reflect cpp

A bug was discovered in glaze which prevented valid toml output. We have
switched to toml++ and reflect-cpp. The interface has remained the same
so this should not break any code
This commit is contained in:
2025-12-06 10:55:46 -05:00
parent 2b5abeae58
commit ec13264050
365 changed files with 63946 additions and 357 deletions

View File

@@ -0,0 +1,21 @@
#ifndef RFL_PARSING_SCHEMA_DEFINITION_HPP_
#define RFL_PARSING_SCHEMA_DEFINITION_HPP_
#include <map>
#include <string>
#include "Type.hpp"
namespace rfl::parsing::schema {
struct Definition {
/// Contains the root element of the schema definition.
Type root_;
/// Contains the definitions to be referenced by Type::Reference.
std::map<std::string, Type> definitions_;
};
} // namespace rfl::parsing::schema
#endif

View File

@@ -0,0 +1,111 @@
#ifndef RFL_PARSING_SCHEMA_TYPE_HPP_
#define RFL_PARSING_SCHEMA_TYPE_HPP_
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
#include "../../Object.hpp"
#include "../../Ref.hpp"
#include "../../Variant.hpp"
#include "ValidationType.hpp"
#include "../../common.hpp"
namespace rfl::parsing::schema {
struct RFL_API Type {
struct Boolean {};
struct Bytestring {};
struct Vectorstring {};
struct Int32 {};
struct Int64 {};
struct UInt32 {};
struct UInt64 {};
struct Integer {};
struct Float {};
struct Double {};
struct String {};
struct AnyOf {
std::vector<Type> types_;
};
struct Description {
std::string description_;
Ref<Type> type_;
};
struct FixedSizeTypedArray {
size_t size_;
Ref<Type> type_;
};
struct Literal {
std::vector<std::string> values_;
};
struct Object {
rfl::Object<Type> types_;
std::shared_ptr<Type> additional_properties_;
};
/// All values are assumed to be required unless explicitly stated otherwise
/// using this wrapper.
struct Optional {
Ref<Type> type_;
};
/// The is necessary to resolve circular definitions. Refers to something in
/// Definitions.
struct Reference {
std::string name_;
};
// A map with key type string.
struct StringMap {
Ref<Type> value_type_;
};
struct Tuple {
std::vector<Type> types_;
};
struct TypedArray {
Ref<Type> type_;
};
struct Validated {
Ref<Type> type_;
ValidationType validation_;
};
using VariantType =
rfl::Variant<Boolean, Bytestring, Vectorstring, Int32, Int64, UInt32, UInt64, Integer,
Float, Double, String, AnyOf, Description,
FixedSizeTypedArray, Literal, Object, Optional, Reference,
StringMap, Tuple, TypedArray, Validated>;
Type();
Type(const VariantType& _variant);
~Type();
/// A type can be determined to be any of the above.
VariantType variant_;
};
} // namespace rfl::parsing::schema
#endif

View File

@@ -0,0 +1,67 @@
#ifndef RFL_PARSING_SCHEMA_VALIDATIONTYPE_HPP_
#define RFL_PARSING_SCHEMA_VALIDATIONTYPE_HPP_
#include <string>
#include <vector>
#include "../../Ref.hpp"
#include "../../Variant.hpp"
namespace rfl::parsing::schema {
struct ValidationType {
struct AllOf {
std::vector<ValidationType> types_;
};
struct AnyOf {
std::vector<ValidationType> types_;
};
struct EqualTo {
rfl::Variant<double, int> value_;
};
struct ExclusiveMaximum {
rfl::Variant<double, int> value_;
};
struct ExclusiveMinimum {
rfl::Variant<double, int> value_;
};
struct Maximum {
rfl::Variant<double, int> value_;
};
struct Minimum {
rfl::Variant<double, int> value_;
};
struct NotEqualTo {
rfl::Variant<double, int> value_;
};
struct OneOf {
std::vector<ValidationType> types_;
};
struct Regex {
std::string pattern_;
};
struct Size {
Ref<ValidationType> size_limit_;
};
using VariantType =
rfl::Variant<AllOf, AnyOf, EqualTo, ExclusiveMaximum, ExclusiveMinimum,
Maximum, Minimum, OneOf, NotEqualTo, Regex, Size>;
/// A type can be determined to be any of the above.
VariantType variant_;
};
} // namespace rfl::parsing::schema
#endif

View File

@@ -0,0 +1,21 @@
#ifndef RFL_PARSING_SCHEMA_MAKE_HPP_
#define RFL_PARSING_SCHEMA_MAKE_HPP_
#include <map>
#include "../Parser.hpp"
#include "Definition.hpp"
#include "Type.hpp"
namespace rfl::parsing::schema {
template <class R, class W, class T, class ProcessorsType>
Definition make() {
std::map<std::string, Type> definitions;
auto root = Parser<R, W, T, ProcessorsType>::to_schema(&definitions);
return Definition{.root_ = root, .definitions_ = definitions};
}
} // namespace rfl::parsing::schema
#endif