From 876688e1aab536f5dc5af0c16aab99ad84c2c345 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 14:54:42 +0200 Subject: Fixed up bit scan logic for clang-cl --- zencore/include/zencore/intmath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/intmath.h b/zencore/include/zencore/intmath.h index 85447c17a..814a03df4 100644 --- a/zencore/include/zencore/intmath.h +++ b/zencore/include/zencore/intmath.h @@ -9,7 +9,7 @@ ////////////////////////////////////////////////////////////////////////// -#if ZEN_COMPILER_MSC +#if ZEN_COMPILER_MSC || ZEN_PLATFORM_WINDOWS # pragma intrinsic(_BitScanReverse) # pragma intrinsic(_BitScanReverse64) #else -- cgit v1.2.3 From 7fa42126867b0c2e87eac035179250bf51a3f5c4 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 14:56:47 +0200 Subject: Handle absence of std::source_location somewhat more gracefully (relies on client code also checking) --- zencore/include/zencore/except.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zencore/include') diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h index 486f3e380..36cca895f 100644 --- a/zencore/include/zencore/except.h +++ b/zencore/include/zencore/except.h @@ -54,7 +54,11 @@ ZENCORE_API void ThrowSystemException(HRESULT hRes, std::string_view Message); #endif // ZEN_PLATFORM_WINDOWS ZENCORE_API void ThrowLastError(std::string_view Message); + +#if __cpp_lib_source_location ZENCORE_API void ThrowLastError(std::string_view Message, const std::source_location& Location); +#endif + ZENCORE_API std::string GetLastErrorAsString(); ZENCORE_API std::string GetWindowsErrorAsString(uint32_t Win32ErrorCode); -- cgit v1.2.3 From ffd45d6a5bd1e95065da71f00b6a9107b805c3ae Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 15:22:36 +0200 Subject: Made logging macros always append `sv` string_view literal suffix Fixed up the few instances of explicit string_view arguments to make sure they compile properly with the new macros --- zencore/include/zencore/logging.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index eefed4efa..4996463fd 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -31,9 +31,11 @@ using zen::Log; // Helper macros for logging -#define ZEN_TRACE(...) Log().trace(__VA_ARGS__) -#define ZEN_DEBUG(...) Log().debug(__VA_ARGS__) -#define ZEN_INFO(...) Log().info(__VA_ARGS__) -#define ZEN_WARN(...) Log().warn(__VA_ARGS__) -#define ZEN_ERROR(...) Log().error(__VA_ARGS__) -#define ZEN_CRITICAL(...) Log().critical(__VA_ARGS__) +using namespace std::literals; + +#define ZEN_TRACE(fmtstr, ...) Log().trace(fmtstr##sv, __VA_ARGS__) +#define ZEN_DEBUG(fmtstr, ...) Log().debug(fmtstr##sv, __VA_ARGS__) +#define ZEN_INFO(fmtstr, ...) Log().info(fmtstr##sv, __VA_ARGS__) +#define ZEN_WARN(fmtstr, ...) Log().warn(fmtstr##sv, __VA_ARGS__) +#define ZEN_ERROR(fmtstr, ...) Log().error(fmtstr##sv, __VA_ARGS__) +#define ZEN_CRITICAL(fmtstr, ...) Log().critical(fmtstr##sv, __VA_ARGS__) -- cgit v1.2.3 From 2fc15e320c934424bc03601551f34f26a38e40a3 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 16:17:22 +0200 Subject: Tweaked logging to streamline access, and simplified setup code for new loggers --- zencore/include/zencore/logging.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 4996463fd..4eee20414 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -13,6 +13,7 @@ namespace zen::logging { spdlog::logger& Default(); +void SetDefault(std::shared_ptr NewDefaultLogger); spdlog::logger& ConsoleLog(); spdlog::logger& Get(std::string_view Name); @@ -22,7 +23,14 @@ void ShutdownLogging(); } // namespace zen::logging namespace zen { -spdlog::logger& Log(); +extern spdlog::logger* TheDefaultLogger; + +inline spdlog::logger& +Log() +{ + return *TheDefaultLogger; +} + using logging::ConsoleLog; } // namespace zen -- cgit v1.2.3 From 5f53b41dd7438906a43fb8ebf6984efe89862970 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 17:33:33 +0200 Subject: Fixed logging.h so it doesn't leak `using namespace std::literals` declaration --- zencore/include/zencore/logging.h | 49 ++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 4eee20414..8e6b3a244 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -39,11 +39,44 @@ using zen::Log; // Helper macros for logging -using namespace std::literals; - -#define ZEN_TRACE(fmtstr, ...) Log().trace(fmtstr##sv, __VA_ARGS__) -#define ZEN_DEBUG(fmtstr, ...) Log().debug(fmtstr##sv, __VA_ARGS__) -#define ZEN_INFO(fmtstr, ...) Log().info(fmtstr##sv, __VA_ARGS__) -#define ZEN_WARN(fmtstr, ...) Log().warn(fmtstr##sv, __VA_ARGS__) -#define ZEN_ERROR(fmtstr, ...) Log().error(fmtstr##sv, __VA_ARGS__) -#define ZEN_CRITICAL(fmtstr, ...) Log().critical(fmtstr##sv, __VA_ARGS__) +#define ZEN_TRACE(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().trace(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_DEBUG(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().debug(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_INFO(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().info(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_WARN(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().warn(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_ERROR(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().error(fmtstr##sv, __VA_ARGS__); \ + } while (false) + +#define ZEN_CRITICAL(fmtstr, ...) \ + do \ + { \ + using namespace std::literals; \ + Log().critical(fmtstr##sv, __VA_ARGS__); \ + } while (false) -- cgit v1.2.3 From 9443c3a44741b192e4c57cb1157fbd260974fd10 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 19:46:34 +0200 Subject: Added GetSize/GetData functions to reduce cognitive load and bridge the gap between UE-style accessors and c++ style accessors --- zencore/include/zencore/iobuffer.h | 2 ++ zencore/include/zencore/stream.h | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'zencore/include') diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 034c3566f..28772e219 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -321,7 +321,9 @@ public: [[nodiscard]] void* MutableData() const { return m_Core->MutableDataPointer(); } void MakeImmutable() { m_Core->SetIsImmutable(true); } [[nodiscard]] const void* Data() const { return m_Core->DataPointer(); } + [[nodiscard]] const void* GetData() const { return m_Core->DataPointer(); } [[nodiscard]] size_t Size() const { return m_Core->DataBytes(); } + [[nodiscard]] size_t GetSize() const { return m_Core->DataBytes(); } inline void SetContentType(ZenContentType ContentType) { m_Core->SetContentType(ContentType); } [[nodiscard]] inline ZenContentType GetContentType() const { return m_Core->GetContentType(); } [[nodiscard]] ZENCORE_API bool GetFileReference(IoBufferFileReference& OutRef) const; diff --git a/zencore/include/zencore/stream.h b/zencore/include/zencore/stream.h index 4e8c58382..a0e165bdc 100644 --- a/zencore/include/zencore/stream.h +++ b/zencore/include/zencore/stream.h @@ -36,6 +36,7 @@ class InStream : public RefCounted public: virtual void Read(void* DataPtr, size_t ByteCount, uint64_t Offset) = 0; virtual uint64_t Size() const = 0; + uint64_t GetSize() const { return Size(); } }; /** @@ -50,7 +51,9 @@ public: virtual void Write(const void* DataPtr, size_t ByteCount, uint64_t Offset) override; virtual void Flush() override; inline const uint8_t* Data() const { return m_Buffer.data(); } + inline const uint8_t* GetData() const { return m_Buffer.data(); } inline uint64_t Size() const { return m_Buffer.size(); } + inline uint64_t GetSize() const { return m_Buffer.size(); } private: RwLock m_Lock; @@ -76,6 +79,7 @@ public: virtual void Read(void* DataPtr, size_t ByteCount, uint64_t ReadOffset) override; virtual uint64_t Size() const override { return m_Buffer.size(); } inline const uint8_t* Data() const { return m_Buffer.data(); } + inline const uint8_t* GetData() const { return m_Buffer.data(); } private: RwLock m_Lock; -- cgit v1.2.3 From 2f28b9bee4da0ddebe0f6de9419e3b3f80ca0911 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 21:39:53 +0200 Subject: Added session id generation and code to include it in HttpClient HTTP requests --- zencore/include/zencore/session.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 zencore/include/zencore/session.h (limited to 'zencore/include') diff --git a/zencore/include/zencore/session.h b/zencore/include/zencore/session.h new file mode 100644 index 000000000..e66794704 --- /dev/null +++ b/zencore/include/zencore/session.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace zen { + +struct Oid; + +ZENCORE_API Oid GetSessionId(); + +} -- cgit v1.2.3 From 629462da1a74c760b966f30a3f0e038b1ad270bb Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 15 Sep 2021 22:12:08 +0200 Subject: Made ZenContentType enum members have fixed value (for persistence), and added kCOUNT for iteration over the members --- zencore/include/zencore/iobuffer.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h index 28772e219..c3860f2b0 100644 --- a/zencore/include/zencore/iobuffer.h +++ b/zencore/include/zencore/iobuffer.h @@ -13,14 +13,16 @@ struct IoBufferExtendedCore; enum class ZenContentType : uint8_t { - kBinary, // Note that since this is zero, this will be the default value in IoBuffer - kText, - kJSON, - kCbObject, - kCbPackage, - kYAML, - kCbPackageOffer, - kUnknownContentType + kBinary = 0, // Note that since this is zero, this will be the default value in IoBuffer + kText = 1, + kJSON = 2, + kCbObject = 3, + kCbPackage = 4, + kYAML = 5, + kCbPackageOffer = 6, + kCompressedBinary = 7, + kUnknownContentType = 8, + kCOUNT }; struct IoBufferFileReference -- cgit v1.2.3