diff options
author | Shauren <shauren.trinity@gmail.com> | 2024-10-16 18:58:45 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-10-17 21:44:13 +0200 |
commit | 03312d4aa47995f5e9e48609b6dea5b385e2199e (patch) | |
tree | c6dbcc09e4e8ea2a910ec52a89c41588bfd28030 /src/common/DataStores/DB2FileLoader.cpp | |
parent | fa5ba783853cb640a810be7c3d1e10d77cd53708 (diff) |
Core/Misc: Replace std::ostringstream based formatting with Trinity::StringFormat where possible in common and database projects
(cherry picked from commit 1a41281e37efdc4be602066dc3fdba12b24d1d0f)
Diffstat (limited to 'src/common/DataStores/DB2FileLoader.cpp')
-rw-r--r-- | src/common/DataStores/DB2FileLoader.cpp | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index a0cc609250e..12df8086a45 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -19,12 +19,13 @@ #include "ByteConverter.h" #include "DB2Meta.h" #include "Errors.h" -#include "Log.h" +#include "StringFormat.h" #include <fmt/ranges.h> #include <limits> -#include <sstream> #include <system_error> +#include <unordered_map> #include <utility> +#include <vector> #include <cstring> enum class DB2ColumnCompression : uint32 @@ -514,19 +515,14 @@ char* DB2FileLoaderRegularImpl::AutoProduceStrings(char** indexTable, uint32 ind { if (!(_header->Locale & (1 << locale))) { - char const* sep = ""; - std::ostringstream str; + std::array<char const*, TOTAL_LOCALES> detectedLocales; + auto itr = detectedLocales.begin(); for (uint32 i = 0; i < TOTAL_LOCALES; ++i) - { if (_header->Locale & (1 << i)) - { - str << sep << localeNames[i]; - sep = ", "; - } - } + *itr++ = localeNames[i]; - TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]); - return nullptr; + throw DB2FileLoadException(Trinity::StringFormat("Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", + _fileName, fmt::join(detectedLocales.begin(), itr, ", "), localeNames[locale])); } if (!_loadInfo->GetStringFieldCount(false)) @@ -1172,19 +1168,14 @@ char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 inde if (!(_header->Locale & (1 << locale))) { - char const* sep = ""; - std::ostringstream str; + std::array<char const*, TOTAL_LOCALES> detectedLocales; + auto itr = detectedLocales.begin(); for (uint32 i = 0; i < TOTAL_LOCALES; ++i) - { if (_header->Locale & (1 << i)) - { - str << sep << localeNames[i]; - sep = ", "; - } - } + *itr++ = localeNames[i]; - TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]); - return nullptr; + throw DB2FileLoadException(Trinity::StringFormat("Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", + _fileName, fmt::join(detectedLocales.begin(), itr, ", "), localeNames[locale])); } uint32 records = _catalog.size(); |