-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.txt
More file actions
132 lines (97 loc) · 4.2 KB
/
todo.txt
File metadata and controls
132 lines (97 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
20211224 : 5:41
20211230 : 4:55
20220217 : 19:01
20220623 : 7:27
20240502 : 10:07
20240506 : 22:30
vide: polymorphic with proxy archives?
\ only if proxy opt-ins for it
vide: ar.peek<T>() (load without progressing the input it (binary)/array index (text))
vide: archive.eof() or some API to check if the whole of the buffer was consumed
vide: Make sure binary_data does not swap bytes for floating points numbers
vide: Archive.reset() (close archive, and clear every state in the archive, but keep allocated memory, make it reusable)
vide: Archive.finish() or .flush() similar to reset()
vide: archive.binary_data(ptr, size) and archive.binary_data(name, ptr, size) dependent name or function for BinaryData, cleanup BinaryData
vide: archive.enable_trace(): detailed exception (try-catch and append debug info in every serializer), as this might be heavy it might need to be a compile time flag not runtime
vide: visiting_archive
vide: force inlines
Better document:
validate_read_size
safe_to_reserve
is_binary_archive
maximumBinaryReadSize
cleanup SizeTag
vide: std::vector<std::byte> should be base64 serialized in JSON/XML
(any std::ranges::contiguous_range of std::byte)
Merge/Implement the following PRs:
https://github.com/USCiLab/cereal/pull/641 Use unordered containers and remove std::function from polymorphic_impl.hpp
Think about it:
https://github.com/USCiLab/cereal/pull/321 Json/XML Archive improvement (basically only the stack info is relevant improvement)
| it will be implemented differently, but there should be a full error stack
------
Helpers for smart pointers, currently their serializer functions
are pretty rough
"traits" class could help
| OR, we might be able to remap onto a single type
like weak_ptr is just shared_ptr, type erasure could happen
before (its similar to "traits" but maybe less work, more generic)
struct Traits {
template <typename T>
using SmartPointer = std::shared_ptr<T>;
auto toStorage(auto var) {
return var;
}
const void* address(const auto& var) {
return var.get();
}
};
/// Saving std::shared_ptr for non-polymorphic types
template <class Archive, class T>
requires (!std::is_polymorphic_v<T>)
inline void VIDE_FUNCTION_NAME_SAVE(Archive& ar, const my::shared_ptr<T>& var) {
if (!var) {
ar.nvp("ref", std::uint32_t{0});
return;
}
const auto* objectAddress = Traits::address(var);
const auto [stored, ref, new_] = ar.registerSmartPointer(objectAddress);
ar.nvp("ref", ref);
if (new_) {
stored.assign(Traits::toStorage(var));
ar.nvp("data", *var);
}
}
/// Loading std::shared_ptr for non-polymorphic types
template <class Archive, class T>
requires (!std::is_polymorphic_v<T>)
inline void VIDE_FUNCTION_NAME_LOAD(Archive& ar, my::shared_ptr<T>& var) {
std::uint32_t ref;
ar.nvp("ref", ref);
if (ref == 0) {
var = nullptr;
return;
}
const auto [stored, new_] = ar.registerSmartPointer(ref);
if (new_) {
using NonConstT = std::remove_const_t<T>;
// TODO P2: switch to make_shared_for_overwrite
// auto realPtr = std::make_shared<Storage<NonConstT>>();
// ::vide::access::construct<T>(realPtr.get());
// auto ptr = std::shared_ptr<NonConstT>(realPtr, reinterpret_cast<NonConstT>(realPtr.get().data));
Traits::SmartPointer<NonConstT> ptr(::vide::access::construct<NonConstT>());
NonConstT* objectAddress = Traits::address(ptr);
stored.assign(Traits::toStorage(ptr), typeid(T), &type_tag_my_shared_ptr);
var = std::move(ptr);
ar.nvp("data", *objectAddress);
return;
}
if (stored.pointerType != &type_tag_my_shared_ptr)
throw vide::Exception(
"Type mismatch. Non-polymorphic pointer type '" + std::string(type_tag_my_shared_ptr.name) + "' referenced with ref [" + std::to_string(ref) + "] was previously loaded as a different '" +
std::string(stored.pointerType->name) + "' pointer type.");
if (stored.objectType != typeid(T)) // This check also handles any polymorphic mismatch
throw vide::Exception(
"Type mismatch. Non-polymorphic '" + std::string(type_tag_my_shared_ptr.name) + "' referenced with ref [" + std::to_string(ref) + "] was previously loaded as type '" +
vide::util::demangle(stored.objectType.name()) + "' is now requested as type '" + vide::util::demangledName<T>() + "'.");
stored.copyTo(&var);
}