C++17ification.
C++17ification! - Filesystem interaction now uses std::filesystem::path. - Usage of const char*, std::string have been changed to std::string_view where appropriate. - Usage of printf-style functions changed to use fmt.
This commit is contained in:
@@ -117,8 +117,8 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
const bool wide) {
|
||||
int32_t count = 0;
|
||||
|
||||
char work[512];
|
||||
wchar_t wwork[4];
|
||||
char work8[512];
|
||||
char16_t work16[4];
|
||||
|
||||
struct {
|
||||
const void* buffer;
|
||||
@@ -339,13 +339,13 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
auto value = args.get32();
|
||||
|
||||
if (!is_wide) {
|
||||
work[0] = (uint8_t)value;
|
||||
text.buffer = &work[0];
|
||||
work8[0] = (uint8_t)value;
|
||||
text.buffer = &work8[0];
|
||||
text.length = 1;
|
||||
text.is_wide = false;
|
||||
} else {
|
||||
wwork[0] = (uint16_t)value;
|
||||
text.buffer = &wwork[0];
|
||||
work16[0] = (uint16_t)value;
|
||||
text.buffer = &work16[0];
|
||||
text.length = 1;
|
||||
text.is_wide = true;
|
||||
text.swap_wide = false;
|
||||
@@ -378,7 +378,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
}
|
||||
|
||||
if (precision >= 0) {
|
||||
precision = std::min(precision, (int32_t)xe::countof(work));
|
||||
precision = std::min(precision, (int32_t)xe::countof(work8));
|
||||
} else {
|
||||
precision = 1;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
prefix.length = 0;
|
||||
}
|
||||
|
||||
char* end = &work[xe::countof(work) - 1];
|
||||
char* end = &work8[xe::countof(work8) - 1];
|
||||
char* start = end;
|
||||
start[0] = '\0';
|
||||
|
||||
@@ -471,9 +471,9 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
|
||||
auto s = format_double(value, precision, c, flags);
|
||||
auto length = (int32_t)s.size();
|
||||
assert_true(length < xe::countof(work));
|
||||
assert_true(length < xe::countof(work8));
|
||||
|
||||
auto start = &work[0];
|
||||
auto start = &work8[0];
|
||||
auto end = &start[length];
|
||||
|
||||
std::memcpy(start, s.c_str(), length);
|
||||
@@ -637,7 +637,7 @@ int32_t format_core(PPCContext* ppc_context, FormatData& data, ArgList& args,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// it's a const wchar_t*
|
||||
// it's a const char16_t*
|
||||
auto b = (const uint16_t*)text.buffer;
|
||||
if (text.swap_wide) {
|
||||
while (remaining-- > 0) {
|
||||
@@ -768,15 +768,15 @@ class WideStringFormatData : public FormatData {
|
||||
}
|
||||
|
||||
bool put(uint16_t c) {
|
||||
output_ << (wchar_t)c;
|
||||
output_ << (char16_t)c;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring wstr() const { return output_.str(); }
|
||||
std::u16string wstr() const { return output_.str(); }
|
||||
|
||||
private:
|
||||
const uint16_t* input_;
|
||||
std::wostringstream output_;
|
||||
std::basic_stringstream<char16_t> output_;
|
||||
};
|
||||
|
||||
class WideCountFormatData : public FormatData {
|
||||
|
||||
Reference in New Issue
Block a user