This commit is contained in:
Mars 2024-06-09 18:55:00 -04:00
parent 05451841e8
commit 94d08a02d6
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
60 changed files with 610 additions and 299 deletions

View file

@ -71,7 +71,9 @@ namespace rfl {
yyjson_arr_iter_init(_arr.val_, &iter);
while ((val = yyjson_arr_iter_next(&iter))) {
const auto err = _array_reader.read(InputVarType(val));
if (err) { return err; }
if (err) {
return err;
}
}
return std::nullopt;
}
@ -95,7 +97,9 @@ namespace rfl {
rfl::Result<T> to_basic_type(const InputVarType _var) const noexcept {
if constexpr (std::is_same<std::remove_cvref_t<T>, std::string>()) {
const auto r = yyjson_get_str(_var.val_);
if (r == NULL) { return rfl::Error("Could not cast to string."); }
if (r == NULL) {
return rfl::Error("Could not cast to string.");
}
return std::string(r);
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
if (!yyjson_is_bool(_var.val_)) {

View file

@ -28,7 +28,9 @@ namespace rfl {
Result<internal::wrap_in_rfl_array_t<T>> read(const std::string& _json_str
) {
yyjson_doc* doc = yyjson_read(_json_str.c_str(), _json_str.size(), 0);
if (!doc) { return Error("Could not parse document"); }
if (!doc) {
return Error("Could not parse document");
}
yyjson_val* root = yyjson_doc_get_root(doc);
const auto r = Reader();
auto res = Parser<T, Processors<Ps...>>::read(r, InputVarType(root));

View file

@ -225,7 +225,9 @@ namespace rfl::json {
auto required = std::vector<std::string>();
for (const auto& [k, v] : _t.types_) {
properties[k] = type_to_json_schema_type(v);
if (!is_optional(v)) { required.push_back(k); }
if (!is_optional(v)) {
required.push_back(k);
}
}
return schema::Type {
.value =