2#include "ser20/access.hpp"
3#include "ser20/ser20.hpp"
4#include "ser20/types/polymorphic.hpp"
5#include "ser20/types/vector.hpp"
6#include <hpp/source_location.hpp>
13#define SERIALIZE_FUNCTION_NAME SER20_SERIALIZE_FUNCTION_NAME
14#define SAVE_FUNCTION_NAME SER20_SAVE_FUNCTION_NAME
15#define LOAD_FUNCTION_NAME SER20_LOAD_FUNCTION_NAME
16#define SAVE_MINIMAL_FUNCTION_NAME SER20_SAVE_MINIMAL_FUNCTION_NAME
17#define LOAD_MINIMAL_FUNCTION_NAME SER20_LOAD_MINIMAL_FUNCTION_NAME
18#define SERIALIZE_REGISTER_TYPE_WITH_NAME(T, Name) SER20_REGISTER_TYPE_WITH_NAME(T, Name)
23using log_callback_t = std::function<void(
const std::string&,
const hpp::source_location& loc)>;
25void log_warning(
const std::string& log_msg,
const hpp::source_location& loc = hpp::source_location::current());
35 void push_segment(
const std::string& segment,
bool ignore_next =
false);
72 bool was_pushed_ =
false;
77#define SERIALIZABLE(T) \
80 friend class serialization::access; \
81 template<typename Archive> \
82 friend void SAVE_FUNCTION_NAME(Archive& ar, T const&); \
83 template<typename Archive> \
84 friend void LOAD_FUNCTION_NAME(Archive& ar, T&);
86#define SERIALIZE_INLINE(cls) \
87 template<typename Archive> \
88 inline void SERIALIZE_FUNCTION_NAME(Archive& ar, cls& obj)
90#define SAVE_INLINE(cls) \
91 template<typename Archive> \
92 inline void SAVE_FUNCTION_NAME(Archive& ar, cls const& obj)
94#define LOAD_INLINE(cls) \
95 template<typename Archive> \
96 inline void LOAD_FUNCTION_NAME(Archive& ar, cls& obj)
98#define SERIALIZE_EXTERN(cls) \
99 template<typename Archive> \
100 extern void SERIALIZE_FUNCTION_NAME(Archive& ar, cls& obj)
102#define SAVE_EXTERN(cls) \
103 template<typename Archive> \
104 extern void SAVE_FUNCTION_NAME(Archive& ar, cls const& obj)
106#define LOAD_EXTERN(cls) \
107 template<typename Archive> \
108 extern void LOAD_FUNCTION_NAME(Archive& ar, cls& obj)
110#define SERIALIZE(cls) \
111 template<typename Archive> \
112 void SERIALIZE_FUNCTION_NAME(Archive& ar, cls& obj)
115 template<typename Archive> \
116 void SAVE_FUNCTION_NAME(Archive& ar, cls const& obj)
119 template<typename Archive> \
120 void LOAD_FUNCTION_NAME(Archive& ar, cls& obj)
122#define SERIALIZE_INSTANTIATE(cls, Archive) template void SERIALIZE_FUNCTION_NAME(Archive& archive, cls& obj)
124#define SAVE_INSTANTIATE(cls, Archive) template void SAVE_FUNCTION_NAME(Archive& archive, cls const& obj)
126#define LOAD_INSTANTIATE(cls, Archive) template void LOAD_FUNCTION_NAME(Archive& archive, cls& obj)
128template<
typename Archive>
134template<
typename Archive,
typename T>
136 ser20::NameValuePair<T>&& t,
137 const hpp::source_location& loc = hpp::source_location::current()) ->
bool
141 ar(std::forward<ser20::NameValuePair<T>>(t));
143 catch(
const ser20::Exception& e)
161 auto path = path_ctx->get_current_path();
162 if(!path_ctx->should_serialize_property(path))
166 return serialize_callback();
168 return serialize_callback();
172template<
typename Archive,
typename T>
174 ser20::NameValuePair<T>&& t,
175 const hpp::source_location& loc = hpp::source_location::current()) ->
bool
179 return try_serialize_direct(ar, std::forward<ser20::NameValuePair<T>>(t), loc);
186template<
typename Archive,
typename T>
188 ser20::NameValuePair<T>&& t,
189 const hpp::source_location& loc = hpp::source_location::current()) ->
bool
191 return try_serialize(ar, std::forward<ser20::NameValuePair<T>>(t), loc);
194template<
typename Archive,
typename T>
196 ser20::NameValuePair<T>&& t,
197 const hpp::source_location& loc = hpp::source_location::current()) ->
bool
199 return try_serialize(ar, std::forward<ser20::NameValuePair<T>>(t), loc);
void log_warning(const std::string &log_msg, const hpp::source_location &loc)
auto get_current_deserialization_path() -> std::string
std::function< void(const std::string &, const hpp::source_location &loc)> log_callback_t
void set_path_context(path_context *ctx)
auto get_path_context() -> path_context *
void set_warning_logger(const std::function< void(const std::string &, const hpp::source_location &loc)> &logger)
auto try_serialize(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
auto try_serialize_direct(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
auto serialize_check(const std::string &name, F &&serialize_callback) -> bool
constexpr auto is_binary_archive() -> bool
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
auto get_current_path() const -> std::string
void push_segment(const std::string &segment, bool ignore_next=false)
auto should_serialize_property(const std::string &property_path) const -> bool
std::function< bool(const std::string &)> should_serialize_property_callback
auto is_recording() const -> bool
std::vector< std::string > path_segments
path_segment_guard(const std::string &segment, bool ignore_next_push=false)
path_segment_guard & operator=(const path_segment_guard &)=delete
path_segment_guard(const path_segment_guard &)=delete
path_segment_guard(path_segment_guard &&)=delete
path_segment_guard & operator=(path_segment_guard &&)=delete