mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-29 07:51:01 +00:00
More fuzzing progress
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <optional>
|
||||
|
||||
namespace utils
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace utils
|
||||
class buffer_deserializer;
|
||||
|
||||
template <typename T>
|
||||
concept Serializable = requires(T a, const T ac, buffer_serializer & serializer, buffer_deserializer & deserializer)
|
||||
concept Serializable = requires(T a, const T ac, buffer_serializer& serializer, buffer_deserializer& deserializer)
|
||||
{
|
||||
{ ac.serialize(serializer) } -> std::same_as<void>;
|
||||
{ a.deserialize(deserializer) } -> std::same_as<void>;
|
||||
@@ -100,7 +101,7 @@ namespace utils
|
||||
|
||||
this->offset_ += sizeof(old_size);
|
||||
#endif
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -148,6 +149,19 @@ namespace utils
|
||||
return object;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_optional(std::optional<T>& val)
|
||||
{
|
||||
if (this->read<bool>())
|
||||
{
|
||||
val = this->read<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
val = {};
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_vector(std::vector<T>& result)
|
||||
{
|
||||
@@ -294,6 +308,17 @@ namespace utils
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void write_optional(const std::optional<T>& val)
|
||||
{
|
||||
this->write(val.has_value());
|
||||
|
||||
if (val.has_value())
|
||||
{
|
||||
this->write(*val);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void write_span(const std::span<T> vec)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user