Skip to content

Commit

Permalink
feat(schema): support binary, ref #149
Browse files Browse the repository at this point in the history
  • Loading branch information
iboB committed Dec 3, 2024
1 parent 0f0e265 commit 74f76ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions schema/code/ac/schema/IOVisitors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ struct ToDictVisitor {
out = astl::move(value);
}

template <typename T>
static void writeToDict(Dict& out, Blob& value) {
out = ac::Dict::binary(std::move(Blob));
}

template <typename T>
static void writeToDict(Dict& out, std::vector<T>& value) {
out = Dict::array();
Expand Down Expand Up @@ -88,6 +93,10 @@ struct FromDictVisitor {
value = astl::move(in.get_ref<std::string&>());
}

static void readFromDict(Dict& in, Blob& value) {
value = Blob{std::move(in.get_binary())};
}

template <typename T>
static void readFromDict(Dict& in, std::vector<T>& value) {
value.clear();
Expand Down
3 changes: 3 additions & 0 deletions schema/code/ac/schema/SchemaVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct SchemaVisitor {
T schema;
schema.visitFields(v);
}
else if constexpr (std::same_as<T, Blob>) {
obj["type"] = "binary";
}
else {
// assume array
obj["type"] = "array";
Expand Down

0 comments on commit 74f76ac

Please sign in to comment.