aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-09-16 10:13:28 +0200
committerMartin Ridgers <[email protected]>2021-09-16 10:13:58 +0200
commit7aa3ceabe4254479bd066ae3ea941396fdc6733c (patch)
treea7d0a7fde0a5a3c42302238965c25c665fc28005 /zencore/include
parentMissing include (diff)
parentAdded some placeholder HttpClient functions to be fleshed out (diff)
downloadzen-7aa3ceabe4254479bd066ae3ea941396fdc6733c.tar.xz
zen-7aa3ceabe4254479bd066ae3ea941396fdc6733c.zip
Merge from main
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/except.h4
-rw-r--r--zencore/include/zencore/intmath.h2
-rw-r--r--zencore/include/zencore/iobuffer.h20
-rw-r--r--zencore/include/zencore/logging.h57
-rw-r--r--zencore/include/zencore/session.h11
-rw-r--r--zencore/include/zencore/stream.h4
6 files changed, 82 insertions, 16 deletions
diff --git a/zencore/include/zencore/except.h b/zencore/include/zencore/except.h
index 5b4a49364..90f7d45db 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 GetErrorAsString(uint32_t ErrorCode);
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
diff --git a/zencore/include/zencore/iobuffer.h b/zencore/include/zencore/iobuffer.h
index 034c3566f..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
@@ -321,7 +323,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/logging.h b/zencore/include/zencore/logging.h
index eefed4efa..8e6b3a244 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<spdlog::logger> 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
@@ -31,9 +39,44 @@ 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__)
+#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)
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 <zencore/zencore.h>
+
+namespace zen {
+
+struct Oid;
+
+ZENCORE_API Oid GetSessionId();
+
+}
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;