diff options
| author | Stefan Boberg <[email protected]> | 2023-12-19 12:06:13 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-19 12:06:13 +0100 |
| commit | 519d942d809e740a3b1fe5a1f6a57a4cfe43408b (patch) | |
| tree | 9b3c084e21bb7fd5e6bb3335e890647062d0703b /src/zencore/include | |
| parent | added mimalloc_hooks (diff) | |
| parent | ensure we can build without trace (#619) (diff) | |
| download | zen-273-integrated-memory-tracking.tar.xz zen-273-integrated-memory-tracking.zip | |
Merge branch 'main' into 273-integrated-memory-tracking273-integrated-memory-tracking
Diffstat (limited to 'src/zencore/include')
| -rw-r--r-- | src/zencore/include/zencore/compactbinary.h | 36 | ||||
| -rw-r--r-- | src/zencore/include/zencore/compactbinarybuilder.h | 1 | ||||
| -rw-r--r-- | src/zencore/include/zencore/compactbinaryvalidation.h | 1 | ||||
| -rw-r--r-- | src/zencore/include/zencore/iobuffer.h | 17 | ||||
| -rw-r--r-- | src/zencore/include/zencore/string.h | 7 | ||||
| -rw-r--r-- | src/zencore/include/zencore/trace.h | 1 |
6 files changed, 51 insertions, 12 deletions
diff --git a/src/zencore/include/zencore/compactbinary.h b/src/zencore/include/zencore/compactbinary.h index cb032e34a..675e2a8d4 100644 --- a/src/zencore/include/zencore/compactbinary.h +++ b/src/zencore/include/zencore/compactbinary.h @@ -26,12 +26,13 @@ namespace zen { -class CbObjectView; class CbArrayView; +class CbObjectView; +class CbValue; +class CompressedBuffer; class BinaryReader; class BinaryWriter; -class CompressedBuffer; -class CbValue; +class TimeSpan; class DateTime { @@ -58,7 +59,11 @@ public: void GetDate(int& Year, int& Month, int& Day) const; inline bool operator==(const DateTime& Rhs) const { return Ticks == Rhs.Ticks; } - inline auto operator<=>(const DateTime& Rhs) const { return Ticks - Rhs.Ticks; } + inline auto operator<=>(const DateTime& Rhs) const = default; + + friend inline TimeSpan operator-(const DateTime& Lhs, const DateTime& Rhs); + friend inline DateTime operator+(const DateTime& Lhs, const TimeSpan& Rhs); + friend inline DateTime operator+(const TimeSpan& Lhs, const DateTime& Rhs); std::string ToString(const char* Format) const; std::string ToIso8601() const; @@ -78,7 +83,7 @@ public: inline uint64_t GetTicks() const { return Ticks; } inline bool operator==(const TimeSpan& Rhs) const { return Ticks == Rhs.Ticks; } - inline auto operator<=>(const TimeSpan& Rhs) const { return Ticks - Rhs.Ticks; } + inline auto operator<=>(const TimeSpan& Rhs) const = default; /** * Time span related constants. @@ -136,12 +141,33 @@ public: ZENCORE_API std::string ToString(const char* Format) const; ZENCORE_API std::string ToString() const; + friend inline DateTime operator+(const DateTime& Lhs, const TimeSpan& Rhs); + friend inline DateTime operator+(const TimeSpan& Lhs, const DateTime& Rhs); + private: void Set(int Days, int Hours, int Minutes, int Seconds, int FractionNano); uint64_t Ticks; }; +inline TimeSpan +operator-(const DateTime& Lhs, const DateTime& Rhs) +{ + return TimeSpan(Lhs.Ticks - Rhs.Ticks); +} + +inline DateTime +operator+(const DateTime& Lhs, const TimeSpan& Rhs) +{ + return DateTime(Lhs.Ticks + Rhs.Ticks); +} + +inline DateTime +operator+(const TimeSpan& Lhs, const DateTime& Rhs) +{ + return DateTime(Lhs.Ticks + Rhs.Ticks); +} + ////////////////////////////////////////////////////////////////////////// /** diff --git a/src/zencore/include/zencore/compactbinarybuilder.h b/src/zencore/include/zencore/compactbinarybuilder.h index dcb767d96..9c81cf490 100644 --- a/src/zencore/include/zencore/compactbinarybuilder.h +++ b/src/zencore/include/zencore/compactbinarybuilder.h @@ -10,7 +10,6 @@ #include <zencore/enumflags.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> -#include <zencore/sha1.h> #include <atomic> #include <memory> diff --git a/src/zencore/include/zencore/compactbinaryvalidation.h b/src/zencore/include/zencore/compactbinaryvalidation.h index b23c6d51d..ddecc8a38 100644 --- a/src/zencore/include/zencore/compactbinaryvalidation.h +++ b/src/zencore/include/zencore/compactbinaryvalidation.h @@ -9,7 +9,6 @@ #include <zencore/enumflags.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> -#include <zencore/sha1.h> #include <gsl/gsl-lite.hpp> diff --git a/src/zencore/include/zencore/iobuffer.h b/src/zencore/include/zencore/iobuffer.h index d891ed55b..b9e503354 100644 --- a/src/zencore/include/zencore/iobuffer.h +++ b/src/zencore/include/zencore/iobuffer.h @@ -337,11 +337,20 @@ public: BorrowedFile }; - inline IoBuffer() = default; - inline IoBuffer(IoBuffer&& Rhs) noexcept = default; - inline IoBuffer(const IoBuffer& Rhs) = default; + inline IoBuffer() = default; + inline IoBuffer(IoBuffer&& Rhs) noexcept + { + m_Core.Swap(Rhs.m_Core); + Rhs.m_Core = NullBufferCore; + } + inline IoBuffer(const IoBuffer& Rhs) = default; inline IoBuffer& operator=(const IoBuffer& Rhs) = default; - inline IoBuffer& operator=(IoBuffer&& Rhs) noexcept = default; + inline IoBuffer& operator =(IoBuffer&& Rhs) noexcept + { + m_Core.Swap(Rhs.m_Core); + Rhs.m_Core = NullBufferCore; + return *this; + } /** Create an uninitialized buffer of the given size */ diff --git a/src/zencore/include/zencore/string.h b/src/zencore/include/zencore/string.h index 3aec1647d..b0232d883 100644 --- a/src/zencore/include/zencore/string.h +++ b/src/zencore/include/zencore/string.h @@ -638,7 +638,12 @@ ToHexNumber(UnsignedIntegral auto Value, char* OutString) bool ParseHexNumber(const std::string_view HexString, UnsignedIntegral auto& OutValue) { - return ParseHexNumber(HexString.data(), sizeof(OutValue) * 2, (uint8_t*)&OutValue); + size_t ExpectedCharacterCount = sizeof(OutValue) * 2; + if (HexString.size() != ExpectedCharacterCount) + { + return false; + } + return ParseHexNumber(HexString.data(), ExpectedCharacterCount, (uint8_t*)&OutValue); } ////////////////////////////////////////////////////////////////////////// diff --git a/src/zencore/include/zencore/trace.h b/src/zencore/include/zencore/trace.h index 2d4c1e610..89e4b76bf 100644 --- a/src/zencore/include/zencore/trace.h +++ b/src/zencore/include/zencore/trace.h @@ -35,6 +35,7 @@ bool TraceStop(); #else #define ZEN_TRACE_CPU(x) +#define ZEN_TRACE_CPU_FLUSH(x) #endif // ZEN_WITH_TRACE |