diff options
| author | Per Larsson <[email protected]> | 2022-01-11 10:31:34 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-01-11 10:31:34 +0100 |
| commit | fa40b11e35f9791bd6ca472ef7bfc246eecbd696 (patch) | |
| tree | 058c1dcef54eb3c15eedc12b29f24d72db239d52 /zencore | |
| parent | Added option to disable Sentry crash handler. (diff) | |
| parent | Not all toolchains support C++20's atomic<double>::fetch_add() (diff) | |
| download | zen-fa40b11e35f9791bd6ca472ef7bfc246eecbd696.tar.xz zen-fa40b11e35f9791bd6ca472ef7bfc246eecbd696.zip | |
Merged main.
Diffstat (limited to 'zencore')
| -rw-r--r-- | zencore/compactbinary.cpp | 45 | ||||
| -rw-r--r-- | zencore/except.cpp | 3 | ||||
| -rw-r--r-- | zencore/filesystem.cpp | 20 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinarybuilder.h | 9 | ||||
| -rw-r--r-- | zencore/iobuffer.cpp | 6 | ||||
| -rw-r--r-- | zencore/thread.cpp | 9 |
6 files changed, 42 insertions, 50 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index 494b45581..cded378a1 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -197,8 +197,6 @@ DateTime::GetDate(int& Year, int& Month, int& Day) const std::string DateTime::ToString(const char* Format) const { - using namespace fmt::literals; - ExtendableStringBuilder<32> Result; int Year, Month, Day; @@ -215,32 +213,32 @@ DateTime::ToString(const char* Format) const // case 'a': Result.Append(IsMorning() ? TEXT("am") : TEXT("pm")); break; // case 'A': Result.Append(IsMorning() ? TEXT("AM") : TEXT("PM")); break; case 'd': - Result.Append("{:02}"_format(Day)); + Result.Append(fmt::format("{:02}", Day)); break; // case 'D': Result.Appendf(TEXT("%03i"), GetDayOfYear()); break; case 'm': - Result.Append("{:02}"_format(Month)); + Result.Append(fmt::format("{:02}", Month)); break; case 'y': - Result.Append("{:02}"_format(Year % 100)); + Result.Append(fmt::format("{:02}", Year % 100)); break; case 'Y': - Result.Append("{:04}"_format(Year)); + Result.Append(fmt::format("{:04}", Year)); break; case 'h': - Result.Append("{:02}"_format(GetHour12())); + Result.Append(fmt::format("{:02}", GetHour12())); break; case 'H': - Result.Append("{:02}"_format(GetHour())); + Result.Append(fmt::format("{:02}", GetHour())); break; case 'M': - Result.Append("{:02}"_format(GetMinute())); + Result.Append(fmt::format("{:02}", GetMinute())); break; case 'S': - Result.Append("{:02}"_format(GetSecond())); + Result.Append(fmt::format("{:02}", GetSecond())); break; case 's': - Result.Append("{:03}"_format(GetMillisecond())); + Result.Append(fmt::format("{:03}", GetMillisecond())); break; default: Result.Append(*Format); @@ -282,8 +280,6 @@ TimeSpan::Set(int Days, int Hours, int Minutes, int Seconds, int FractionNano) std::string TimeSpan::ToString(const char* Format) const { - using namespace fmt::literals; - StringBuilder<128> Result; Result.Append((int64_t(Ticks) < 0) ? '-' : '+'); @@ -295,31 +291,31 @@ TimeSpan::ToString(const char* Format) const switch (*Format) { case 'd': - Result.Append("{}"_format(GetDays())); + Result.Append(fmt::format("{}", GetDays())); break; case 'D': - Result.Append("{:08}"_format(GetDays())); + Result.Append(fmt::format("{:08}", GetDays())); break; case 'h': - Result.Append("{:02}"_format(GetHours())); + Result.Append(fmt::format("{:02}", GetHours())); break; case 'm': - Result.Append("{:02}"_format(GetMinutes())); + Result.Append(fmt::format("{:02}", GetMinutes())); break; case 's': - Result.Append("{:02}"_format(GetSeconds())); + Result.Append(fmt::format("{:02}", GetSeconds())); break; case 'f': - Result.Append("{:03}"_format(GetFractionMilli())); + Result.Append(fmt::format("{:03}", GetFractionMilli())); break; case 'u': - Result.Append("{:06}"_format(GetFractionMicro())); + Result.Append(fmt::format("{:06}", GetFractionMicro())); break; case 't': - Result.Append("{:07}"_format(GetFractionTicks())); + Result.Append(fmt::format("{:07}", GetFractionTicks())); break; case 'n': - Result.Append("{:09}"_format(GetFractionNano())); + Result.Append(fmt::format("{:09}", GetFractionNano())); break; default: Result.Append(*Format); @@ -1442,7 +1438,6 @@ public: void WriteField(CbFieldView Field) { - using namespace fmt::literals; using namespace std::literals; WriteOptionalComma(); @@ -1512,7 +1507,7 @@ public: const float Value = Accessor.AsFloat32(); if (std::isfinite(Value)) { - Builder.Append("{:.9g}"_format(Value)); + Builder.Append(fmt::format("{:.9g}", Value)); } else { @@ -1525,7 +1520,7 @@ public: const double Value = Accessor.AsFloat64(); if (std::isfinite(Value)) { - Builder.Append("{:.17g}"_format(Value)); + Builder.Append(fmt::format("{:.17g}", Value)); } else { diff --git a/zencore/except.cpp b/zencore/except.cpp index b4ad5acf2..2749d1984 100644 --- a/zencore/except.cpp +++ b/zencore/except.cpp @@ -79,9 +79,8 @@ GetSystemErrorAsString(uint32_t ErrorCode) void ThrowLastErrorImpl(std::string_view Message, const std::source_location& Location) { - using namespace fmt::literals; throw std::system_error(std::error_code(zen::GetLastError(), std::system_category()), - "{}({}): {}"_format(Location.file_name(), Location.line(), Message)); + fmt::format("{}({}): {}", Location.file_name(), Location.line(), Message)); } #else void diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 2507037ea..bed08b3f5 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -487,8 +487,6 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop &CancelFlag, /* dwCopyFlags */ 0); #else - using namespace fmt::literals; - struct ScopedFd { ~ScopedFd() { close(Fd); } @@ -499,7 +497,7 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop int FromFd = open(FromPath.c_str(), O_RDONLY | O_CLOEXEC); if (FromFd < 0) { - ThrowLastError("failed to open file {}"_format(FromPath)); + ThrowLastError(fmt::format("failed to open file {}", FromPath)); } ScopedFd $From = {FromFd}; @@ -507,7 +505,7 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop int ToFd = open(ToPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0644); if (ToFd < 0) { - ThrowLastError("failed to create file {}"_format(ToPath)); + ThrowLastError(fmt::format("failed to create file {}", ToPath)); } ScopedFd $To = {ToFd}; @@ -543,8 +541,6 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop void WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t BufferCount) { - using namespace fmt::literals; - #if ZEN_PLATFORM_WINDOWS CAtlFile Outfile; HRESULT hRes = Outfile.Create(Path.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS); @@ -557,7 +553,7 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer if (FAILED(hRes)) { - ThrowSystemException(hRes, "File open failed for '{}'"_format(Path).c_str()); + ThrowSystemException(hRes, fmt::format("File open failed for '{}'", Path).c_str()); } #else @@ -571,7 +567,7 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer if (Fd < 0) { - ThrowLastError("File open failed for '{}'"_format(Path)); + ThrowLastError(fmt::format("File open failed for '{}'", Path)); } #endif @@ -590,12 +586,12 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer hRes = Outfile.Write(DataPtr, gsl::narrow_cast<uint32_t>(WriteSize)); if (FAILED(hRes)) { - ThrowSystemException(hRes, "File write failed for '{}'"_format(Path).c_str()); + ThrowSystemException(hRes, fmt::format("File write failed for '{}'", Path).c_str()); } #else if (write(Fd, DataPtr, WriteSize) != int64_t(WriteSize)) { - ThrowLastError("File write failed for '{}'"_format(Path)); + ThrowLastError(fmt::format("File write failed for '{}'", Path)); } #endif // ZEN_PLATFORM_WINDOWS @@ -867,14 +863,12 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr } } #else - using namespace fmt::literals; - /* Could also implement this using Linux's getdents() syscall */ DIR* Dir = opendir(RootDir.c_str()); if (Dir == nullptr) { - ThrowLastError("Failed to open directory for traversal: {}"_format(RootDir.c_str())); + ThrowLastError(fmt::format("Failed to open directory for traversal: {}", RootDir.c_str())); } for (struct dirent* Entry; (Entry = readdir(Dir));) diff --git a/zencore/include/zencore/compactbinarybuilder.h b/zencore/include/zencore/compactbinarybuilder.h index 5f6d9fd0c..aee95ea5b 100644 --- a/zencore/include/zencore/compactbinarybuilder.h +++ b/zencore/include/zencore/compactbinarybuilder.h @@ -539,6 +539,15 @@ operator<<(CbWriter& Writer, std::nullptr_t) return Writer; } +#if defined(__clang__) +inline CbWriter& +operator<<(CbWriter& Writer, std::size_t Value) +{ + Writer.AddInteger(uint64_t(Value)); + return Writer; +} +#endif + inline CbWriter& operator<<(CbWriter& Writer, std::wstring_view Value) { diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index 30865068a..b6bbedc40 100644 --- a/zencore/iobuffer.cpp +++ b/zencore/iobuffer.cpp @@ -231,8 +231,6 @@ static RwLock g_MappingLock; void IoBufferExtendedCore::Materialize() const { - using namespace fmt::literals; - // The synchronization scheme here is very primitive, if we end up with // a lot of contention we can make it more fine-grained @@ -264,7 +262,7 @@ IoBufferExtendedCore::Materialize() const if (NewMmapHandle == nullptr) { throw std::system_error(std::error_code(::GetLastError(), std::system_category()), - "CreateFileMapping failed on file '{}'"_format(zen::PathFromHandle(m_FileHandle))); + fmt::format("CreateFileMapping failed on file '{}'", zen::PathFromHandle(m_FileHandle))); } NewFlags |= kOwnsMmap; @@ -291,7 +289,7 @@ IoBufferExtendedCore::Materialize() const { throw std::system_error( std::error_code(zen::GetLastError(), std::system_category()), - "MapViewOfFile failed (offset {:#x}, size {:#x}) file: '{}'"_format(MapOffset, MapSize, zen::PathFromHandle(m_FileHandle))); + fmt::format("MapViewOfFile failed (offset {:#x}, size {:#x}) file: '{}'", MapOffset, MapSize, zen::PathFromHandle(m_FileHandle))); } m_MappedPointer = MappedBase; diff --git a/zencore/thread.cpp b/zencore/thread.cpp index 358256b1d..97d44e733 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -310,8 +310,7 @@ NamedEvent::NamedEvent(std::string_view EventName) int Fd = open(EventPath.c_str(), O_RDWR|O_CREAT, 0644); if (Fd < 0) { - using namespace fmt::literals; - ThrowLastError("Failed to create '{}' for named event"_format(EventPath)); + ThrowLastError(fmt::format("Failed to create '{}' for named event", EventPath)); } // Use the file path to generate an IPC key @@ -631,8 +630,7 @@ ProcessHandle::Initialize(int Pid) if (!m_ProcessHandle) { - using namespace fmt::literals; - ThrowLastError("ProcessHandle::Initialize(pid: {}) failed"_format(Pid)); + ThrowLastError(fmt::format("ProcessHandle::Initialize(pid: {}) failed", Pid)); } m_Pid = Pid; @@ -1113,8 +1111,7 @@ IsProcessRunning(int pid) return false; } - using namespace fmt::literals; - ThrowSystemError(Error, "failed to open process with pid {}"_format(pid)); + ThrowSystemError(Error, fmt::format("failed to open process with pid {}", pid)); } CloseHandle(hProc); |