From bd85a74a9d15fd676a6677fbd4d5ab4e3dcb0d42 Mon Sep 17 00:00:00 2001 From: mattpetersepic <58296718+mattpetersepic@users.noreply.github.com> Date: Tue, 25 Jan 2022 06:57:47 -0700 Subject: Cachepolicy (#36) * Copy CachePolicy implementation from UE5/Release-5.0. Add backwards compatability for clients and upstreams that are using the old protocol. * Add RefPtr templated move operator and constructor, so that RefPtr A = std::move(RefPtr()) will do a move. * Fix broken CachePolicy tests and add tests for new Save/Load. * Remove TODO comments * CachePolicy Save/Load Fixes from codereview * Fix comment to match code change. * Remove backwards compatibility for CachePolicy change. Convert policy string tokens to PascalCase. Fix tests for new policy text. Change ParseCachePolicy to assert string is non-empty and always succeed. * Fix release build: use ZEN_WITH_TESTS define --- zencore/include/zencore/refcount.h | 17 +++++++++++++++++ zencore/include/zencore/string.h | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'zencore/include') diff --git a/zencore/include/zencore/refcount.h b/zencore/include/zencore/refcount.h index 0324b94cc..afee8536f 100644 --- a/zencore/include/zencore/refcount.h +++ b/zencore/include/zencore/refcount.h @@ -94,10 +94,27 @@ public: } return *this; } + template + inline RefPtr& operator=(RefPtr&& Rhs) noexcept + { + if ((RefPtr*)&Rhs != this) + { + m_Ref && m_Ref->Release(); + m_Ref = Rhs.m_Ref; + Rhs.m_Ref = nullptr; + } + return *this; + } inline RefPtr(RefPtr&& Rhs) noexcept : m_Ref(Rhs.m_Ref) { Rhs.m_Ref = nullptr; } + template + explicit inline RefPtr(RefPtr&& Rhs) noexcept : m_Ref(Rhs.m_Ref) + { + Rhs.m_Ref = nullptr; + } private: T* m_Ref = nullptr; + friend class RefPtr; }; /** diff --git a/zencore/include/zencore/string.h b/zencore/include/zencore/string.h index 1e8907906..4c378730f 100644 --- a/zencore/include/zencore/string.h +++ b/zencore/include/zencore/string.h @@ -413,6 +413,17 @@ private: char m_StringBuffer[N]; }; +template +class WriteToString : public ExtendableStringBuilder +{ +public: + template + explicit WriteToString(ArgTypes&&... Args) + { + (*this << ... << std::forward(Args)); + } +}; + ////////////////////////////////////////////////////////////////////////// extern template class StringBuilderImpl; @@ -454,6 +465,17 @@ private: wchar_t m_Buffer[N]; }; +template +class WriteToWideString : public ExtendableWideStringBuilder +{ +public: + template + explicit WriteToWideString(ArgTypes&&... Args) + { + (*this << ... << Forward(Args)); + } +}; + ////////////////////////////////////////////////////////////////////////// void Utf8ToWide(const char8_t* str, WideStringBuilderBase& out); -- cgit v1.2.3 From 7025ea47e04a45c2d72c00dba3546617f323ec94 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Tue, 25 Jan 2022 15:23:40 +0100 Subject: Fixed missing template decorator on RefPtr friend class --- zencore/include/zencore/refcount.h | 1 + 1 file changed, 1 insertion(+) (limited to 'zencore/include') diff --git a/zencore/include/zencore/refcount.h b/zencore/include/zencore/refcount.h index afee8536f..254a22db5 100644 --- a/zencore/include/zencore/refcount.h +++ b/zencore/include/zencore/refcount.h @@ -114,6 +114,7 @@ public: private: T* m_Ref = nullptr; + template friend class RefPtr; }; -- cgit v1.2.3