aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authormattpetersepic <[email protected]>2022-01-25 06:57:47 -0700
committerGitHub <[email protected]>2022-01-25 06:57:47 -0700
commitbd85a74a9d15fd676a6677fbd4d5ab4e3dcb0d42 (patch)
treee59bd4eccbc667088e74e989f2cfbbf82c6926c0 /zencore/include
parentFixed unexpected abort() call when joining an unjoinable thread (diff)
downloadzen-bd85a74a9d15fd676a6677fbd4d5ab4e3dcb0d42.tar.xz
zen-bd85a74a9d15fd676a6677fbd4d5ab4e3dcb0d42.zip
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<const Foo*> A = std::move(RefPtr<Foo*>()) 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
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/refcount.h17
-rw-r--r--zencore/include/zencore/string.h22
2 files changed, 39 insertions, 0 deletions
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<typename OtherType>
+ inline RefPtr& operator=(RefPtr<OtherType>&& 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<typename OtherType>
+ explicit inline RefPtr(RefPtr<OtherType>&& 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<size_t N>
+class WriteToString : public ExtendableStringBuilder<N>
+{
+public:
+ template<typename... ArgTypes>
+ explicit WriteToString(ArgTypes&&... Args)
+ {
+ (*this << ... << std::forward<ArgTypes>(Args));
+ }
+};
+
//////////////////////////////////////////////////////////////////////////
extern template class StringBuilderImpl<wchar_t>;
@@ -454,6 +465,17 @@ private:
wchar_t m_Buffer[N];
};
+template<size_t N>
+class WriteToWideString : public ExtendableWideStringBuilder<N>
+{
+public:
+ template<typename... ArgTypes>
+ explicit WriteToWideString(ArgTypes&&... Args)
+ {
+ (*this << ... << Forward<ArgTypes>(Args));
+ }
+};
+
//////////////////////////////////////////////////////////////////////////
void Utf8ToWide(const char8_t* str, WideStringBuilderBase& out);