summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-06-28 11:42:33 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-06-28 11:42:33 +0200
commite41b18d6aee90a3e7c50d580836dc1211e5842ee (patch)
tree4fd423af0137407a19fb0411e6fa2cb58cd6a984 /src
parenteb80393224cc7073eb93bd27085691c51467288c (diff)
c++,codec-json: Fixed exception handling
Diffstat (limited to 'src')
-rw-r--r--src/codec-json/json.tmpl.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/codec-json/json.tmpl.h b/src/codec-json/json.tmpl.h
index 4ef8676..8fb01a9 100644
--- a/src/codec-json/json.tmpl.h
+++ b/src/codec-json/json.tmpl.h
@@ -459,14 +459,26 @@ struct json_decode<schema::String, RootSchema, ToDecode> {
}
};
-// The whole std::vector approach is hacky af
+template<typename... T, string_literal... Lits, typename RootSchema, typename ToDecode>
+struct json_decode<schema::Struct<schema::Member<T,Lits>...>, RootSchema, ToDecode> {
+ static error_or<void> decode(buffer_view& buff, data<schema::Struct<schema::Member<T,Lits>...>, ToDecode>& to){
+
+ return make_error<err::not_implemented>();
+ }
+};
+
+// The whole std::vector approach is hacky af. ToDo change it maybe?
template<typename T, size_t D, typename RootSchema, typename ToDecode>
struct json_decode<schema::Array<T,D>, RootSchema, ToDecode> {
template<size_t Level>
static error_or<void> decode_flat_level(buffer_view& buff, std::vector<data<T, encode::Native>>& to, std::array<std::size_t, D>& index, std::array<std::size_t, D>& dims, bool log_dim){
if constexpr (Level == D) {
json_helper::skip_whitespace(buff);
- to.push_back({});
+ try {
+ to.push_back({});
+ }catch(std::exception& e){
+ return make_error<err::out_of_memory>();
+ }
auto eov = json_decode<T, RootSchema, ToDecode>::decode(buff, to.back());
if(eov.is_error()){
return eov;