// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable : 4365 4987) #endif #include #ifdef _MSC_VER #pragma warning(pop) #endif namespace terse { template class Archive { public: explicit Archive(ArchiveImpl* impl_) : impl{impl_}, userData{nullptr} { } bool isOk() { return impl->isOk(); } void sync() { impl->sync(); } void label(const char* value) { impl->label(value); } template void operator()(Args&& ... args) { dispatch(std::forward(args)...); } template ArchiveImpl& operator<<(TSerializable& source) { dispatch(source); return *impl; } template ArchiveImpl& operator>>(TSerializable& dest) { dispatch(dest); return *impl; } void* getUserData() const { return userData; } void setUserData(void* data) { userData = data; } protected: template void dispatch(Head&& head) { impl->process(std::forward(head)); } template void dispatch(Head&& head, Tail&& ... tail) { dispatch(std::forward(head)); dispatch(std::forward(tail)...); } private: ArchiveImpl* impl; void* userData; }; } // namespace terse