SmallString: fmt -> format, format -> sprintf
This commit is contained in:
@ -66,7 +66,7 @@ void CubebAudioStream::LogCallback(const char* fmt, ...)
|
||||
LargeString str;
|
||||
std::va_list ap;
|
||||
va_start(ap, fmt);
|
||||
str.format_va(fmt, ap);
|
||||
str.vsprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
Log_DevPrint(str);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ void CueParser::File::SetError(u32 line_number, Error* error, const char* format
|
||||
std::va_list ap;
|
||||
SmallString str;
|
||||
va_start(ap, format);
|
||||
str.format_va(format, ap);
|
||||
str.vsprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
Log_ErrorPrintf("Cue parse error at line %u: %s", line_number, str.c_str());
|
||||
|
||||
@ -408,17 +408,17 @@ TinyString DInputSource::ConvertKeyToString(InputBindingKey key)
|
||||
{
|
||||
const char* modifier =
|
||||
(key.modifier == InputModifier::FullAxis ? "Full" : (key.modifier == InputModifier::Negate ? "-" : "+"));
|
||||
ret.fmt("DInput-{}/{}Axis{}{}", u32(key.source_index), modifier, u32(key.data), key.invert ? "~" : "");
|
||||
ret.format("DInput-{}/{}Axis{}{}", u32(key.source_index), modifier, u32(key.data), key.invert ? "~" : "");
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerButton && key.data >= MAX_NUM_BUTTONS)
|
||||
{
|
||||
const u32 hat_num = (key.data - MAX_NUM_BUTTONS) / NUM_HAT_DIRECTIONS;
|
||||
const u32 hat_dir = (key.data - MAX_NUM_BUTTONS) % NUM_HAT_DIRECTIONS;
|
||||
ret.fmt("DInput-{}/Hat{}{}", u32(key.source_index), hat_num, s_hat_directions[hat_dir]);
|
||||
ret.format("DInput-{}/Hat{}{}", u32(key.source_index), hat_num, s_hat_directions[hat_dir]);
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerButton)
|
||||
{
|
||||
ret.fmt("DInput-{}/Button{}", u32(key.source_index), u32(key.data));
|
||||
ret.format("DInput-{}/Button{}", u32(key.source_index), u32(key.data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -318,7 +318,7 @@ void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version)
|
||||
if (m_features.pipeline_cache)
|
||||
{
|
||||
const std::string pc_filename =
|
||||
Path::Combine(base_path, TinyString::from_fmt("{}.bin", GetShaderCacheBaseName("pipelines")));
|
||||
Path::Combine(base_path, TinyString::from_format("{}.bin", GetShaderCacheBaseName("pipelines")));
|
||||
if (FileSystem::FileExists(pc_filename.c_str()))
|
||||
{
|
||||
Log_InfoPrintf("Removing old pipeline cache '%s'", pc_filename.c_str());
|
||||
@ -337,7 +337,7 @@ void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version)
|
||||
if (m_features.pipeline_cache && !base_path.empty())
|
||||
{
|
||||
const std::string basename = GetShaderCacheBaseName("pipelines");
|
||||
const std::string filename = Path::Combine(base_path, TinyString::from_fmt("{}.bin", basename));
|
||||
const std::string filename = Path::Combine(base_path, TinyString::from_format("{}.bin", basename));
|
||||
if (ReadPipelineCache(filename))
|
||||
s_pipeline_cache_path = std::move(filename);
|
||||
else
|
||||
|
||||
@ -761,10 +761,10 @@ struct GLAutoPop
|
||||
#define GL_INS(msg) g_gpu_device->InsertDebugMessage(msg)
|
||||
#define GL_OBJECT_NAME(obj, name) (obj)->SetDebugName(name)
|
||||
|
||||
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__)), 0))
|
||||
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_fmt(__VA_ARGS__))
|
||||
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_fmt(__VA_ARGS__))
|
||||
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_fmt(__VA_ARGS__))
|
||||
#define GL_SCOPE_FMT(...) GLAutoPop gl_auto_pop((g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__)), 0))
|
||||
#define GL_PUSH_FMT(...) g_gpu_device->PushDebugGroup(SmallString::from_format(__VA_ARGS__))
|
||||
#define GL_INS_FMT(...) g_gpu_device->InsertDebugMessage(SmallString::from_format(__VA_ARGS__))
|
||||
#define GL_OBJECT_NAME_FMT(obj, ...) (obj)->SetDebugName(SmallString::from_format(__VA_ARGS__))
|
||||
#else
|
||||
#define GL_SCOPE(name) (void)0
|
||||
#define GL_PUSH(name) (void)0
|
||||
|
||||
@ -2435,7 +2435,7 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
|
||||
dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (box_end.x - pos.x), box_end.y),
|
||||
ImGui::GetColorU32(UISecondaryColor));
|
||||
|
||||
const auto text = TinyString::from_fmt("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
const auto text = TinyString::from_format("{}%", static_cast<int>(std::round(fraction * 100.0f)));
|
||||
const ImVec2 text_size(ImGui::CalcTextSize(text));
|
||||
const ImVec2 text_pos(pos.x + ((box_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f),
|
||||
pos.y + ((box_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f));
|
||||
|
||||
@ -1840,7 +1840,7 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
|
||||
if (bnum >= std::size(button_mapping))
|
||||
continue;
|
||||
|
||||
new_bind.fmt("SDL-{}/{}", cnum, button_mapping[bnum]);
|
||||
new_bind.format("SDL-{}/{}", cnum, button_mapping[bnum]);
|
||||
si.SetStringValue(new_section.c_str(), new_key, new_bind);
|
||||
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
|
||||
num_changes++;
|
||||
@ -1850,14 +1850,14 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
|
||||
if (bnum >= std::size(axis_mapping))
|
||||
continue;
|
||||
|
||||
new_bind.fmt("SDL-{}/{}{}", cnum, dir, axis_mapping[bnum]);
|
||||
new_bind.format("SDL-{}/{}{}", cnum, dir, axis_mapping[bnum]);
|
||||
si.SetStringValue(new_section.c_str(), new_key, new_bind);
|
||||
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
|
||||
num_changes++;
|
||||
}
|
||||
else if (StringUtil::StartsWith(old_bind.c_str(), "Keyboard/Keypad+"))
|
||||
{
|
||||
new_bind.fmt("Keyboard/Numpad{}", old_bind.substr(16));
|
||||
new_bind.format("Keyboard/Numpad{}", old_bind.substr(16));
|
||||
si.SetStringValue(new_section.c_str(), new_key, new_bind);
|
||||
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
|
||||
num_changes++;
|
||||
@ -1890,9 +1890,9 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
|
||||
if (bnum >= std::size(axis_mapping))
|
||||
continue;
|
||||
|
||||
new_bind.fmt("SDL-{}/-{}", cnum, axis_mapping[bnum]);
|
||||
new_bind.format("SDL-{}/-{}", cnum, axis_mapping[bnum]);
|
||||
si.SetStringValue(new_section.c_str(), new_neg_key, new_bind);
|
||||
new_bind.fmt("SDL-{}/+{}", cnum, axis_mapping[bnum]);
|
||||
new_bind.format("SDL-{}/+{}", cnum, axis_mapping[bnum]);
|
||||
si.SetStringValue(new_section.c_str(), new_pos_key, new_bind);
|
||||
|
||||
Log_DevPrintf("%s -> %s", old_bind.c_str(), new_bind.c_str());
|
||||
@ -1906,9 +1906,9 @@ bool InputManager::MigrateBindings(SettingsInterface& si)
|
||||
unsigned cnum;
|
||||
if (std::sscanf(rumble_source.c_str(), "Controller%u", &cnum) == 1)
|
||||
{
|
||||
new_bind.fmt("SDL-{}/LargeMotor", cnum);
|
||||
new_bind.format("SDL-{}/LargeMotor", cnum);
|
||||
si.SetStringValue(new_section.c_str(), "LargeMotor", new_bind);
|
||||
new_bind.fmt("SDL-{}/SmallMotor", cnum);
|
||||
new_bind.format("SDL-{}/SmallMotor", cnum);
|
||||
si.SetStringValue(new_section.c_str(), "SmallMotor", new_bind);
|
||||
num_changes++;
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
else
|
||||
{
|
||||
glBindAttribLocation(program_id, i,
|
||||
TinyString::from_fmt("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())],
|
||||
TinyString::from_format("{}{}", semantic_vars[static_cast<u8>(va.semantic.GetValue())],
|
||||
static_cast<u8>(va.semantic_index)));
|
||||
}
|
||||
}
|
||||
@ -420,7 +420,7 @@ void OpenGLDevice::PostLinkProgram(const GPUPipeline::GraphicsConfig& plconfig,
|
||||
const u32 num_textures = std::max<u32>(GetActiveTexturesForLayout(plconfig.layout), 1);
|
||||
for (u32 i = 0; i < num_textures; i++)
|
||||
{
|
||||
location = glGetUniformLocation(program_id, TinyString::from_fmt("samp{}", i));
|
||||
location = glGetUniformLocation(program_id, TinyString::from_format("samp{}", i));
|
||||
if (location >= 0)
|
||||
glUniform1i(location, i);
|
||||
}
|
||||
|
||||
@ -127,11 +127,11 @@ TinyString PostProcessing::ValueToString(ShaderOption::Type type, u32 vector_siz
|
||||
break;
|
||||
|
||||
case ShaderOption::Type::Int:
|
||||
ret.append_fmt("{}", value[i].int_value);
|
||||
ret.append_format("{}", value[i].int_value);
|
||||
break;
|
||||
|
||||
case ShaderOption::Type::Float:
|
||||
ret.append_fmt("{}", value[i].float_value);
|
||||
ret.append_format("{}", value[i].float_value);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -210,7 +210,7 @@ std::vector<std::pair<std::string, std::string>> PostProcessing::GetAvailableSha
|
||||
|
||||
TinyString PostProcessing::GetStageConfigSection(u32 index)
|
||||
{
|
||||
return TinyString::from_fmt("PostProcessing/Stage{}", index + 1);
|
||||
return TinyString::from_format("PostProcessing/Stage{}", index + 1);
|
||||
}
|
||||
|
||||
void PostProcessing::CopyStageConfig(SettingsInterface& si, u32 old_index, u32 new_index)
|
||||
|
||||
@ -455,11 +455,11 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
|
||||
(key.modifier == InputModifier::FullAxis ? "Full" : (key.modifier == InputModifier::Negate ? "-" : "+"));
|
||||
if (key.data < std::size(s_sdl_axis_names))
|
||||
{
|
||||
ret.fmt("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
|
||||
ret.format("SDL-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_sdl_axis_names[key.data]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.fmt("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier,
|
||||
ret.format("SDL-{}/{}Axis{}{}", static_cast<u32>(key.source_index), modifier,
|
||||
key.data - static_cast<u32>(std::size(s_sdl_axis_names)), key.invert ? "~" : "");
|
||||
}
|
||||
}
|
||||
@ -467,11 +467,11 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
|
||||
{
|
||||
if (key.data < std::size(s_sdl_button_names))
|
||||
{
|
||||
ret.fmt("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
|
||||
ret.format("SDL-{}/{}", static_cast<u32>(key.source_index), s_sdl_button_names[key.data]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.fmt("SDL-{}/Button{}", static_cast<u32>(key.source_index),
|
||||
ret.format("SDL-{}/Button{}", static_cast<u32>(key.source_index),
|
||||
key.data - static_cast<u32>(std::size(s_sdl_button_names)));
|
||||
}
|
||||
}
|
||||
@ -479,16 +479,16 @@ TinyString SDLInputSource::ConvertKeyToString(InputBindingKey key)
|
||||
{
|
||||
const u32 hat_index = key.data / static_cast<u32>(std::size(s_sdl_hat_direction_names));
|
||||
const u32 hat_direction = key.data % static_cast<u32>(std::size(s_sdl_hat_direction_names));
|
||||
ret.fmt("SDL-{}/Hat{}{}", static_cast<u32>(key.source_index), hat_index,
|
||||
ret.format("SDL-{}/Hat{}{}", static_cast<u32>(key.source_index), hat_index,
|
||||
s_sdl_hat_direction_names[hat_direction]);
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerMotor)
|
||||
{
|
||||
ret.fmt("SDL-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
|
||||
ret.format("SDL-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerHaptic)
|
||||
{
|
||||
ret.fmt("SDL-{}/Haptic", static_cast<u32>(key.source_index));
|
||||
ret.format("SDL-{}/Haptic", static_cast<u32>(key.source_index));
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,14 +505,14 @@ TinyString SDLInputSource::ConvertKeyToIcon(InputBindingKey key)
|
||||
{
|
||||
if (key.data < std::size(s_sdl_axis_icons) && key.modifier != InputModifier::FullAxis)
|
||||
{
|
||||
ret.fmt("SDL-{} {}", static_cast<u32>(key.source_index),
|
||||
ret.format("SDL-{} {}", static_cast<u32>(key.source_index),
|
||||
s_sdl_axis_icons[key.data][key.modifier == InputModifier::None]);
|
||||
}
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerButton)
|
||||
{
|
||||
if (key.data < std::size(s_sdl_button_icons))
|
||||
ret.fmt("SDL-{} {}", static_cast<u32>(key.source_index), s_sdl_button_icons[key.data]);
|
||||
ret.format("SDL-{} {}", static_cast<u32>(key.source_index), s_sdl_button_icons[key.data]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -700,7 +700,7 @@ bool VulkanDevice::CreateCommandBuffers()
|
||||
LOG_VULKAN_ERROR(res, "vkCreateCommandPool failed: ");
|
||||
return false;
|
||||
}
|
||||
Vulkan::SetObjectName(m_device, resources.command_pool, TinyString::from_fmt("Frame Command Pool {}", frame_index));
|
||||
Vulkan::SetObjectName(m_device, resources.command_pool, TinyString::from_format("Frame Command Pool {}", frame_index));
|
||||
|
||||
VkCommandBufferAllocateInfo buffer_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr,
|
||||
resources.command_pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY,
|
||||
@ -715,7 +715,7 @@ bool VulkanDevice::CreateCommandBuffers()
|
||||
for (u32 i = 0; i < resources.command_buffers.size(); i++)
|
||||
{
|
||||
Vulkan::SetObjectName(m_device, resources.command_buffers[i],
|
||||
TinyString::from_fmt("Frame {} {}Command Buffer", frame_index, (i == 0) ? "Init" : ""));
|
||||
TinyString::from_format("Frame {} {}Command Buffer", frame_index, (i == 0) ? "Init" : ""));
|
||||
}
|
||||
|
||||
VkFenceCreateInfo fence_info = {VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT};
|
||||
@ -726,7 +726,7 @@ bool VulkanDevice::CreateCommandBuffers()
|
||||
LOG_VULKAN_ERROR(res, "vkCreateFence failed: ");
|
||||
return false;
|
||||
}
|
||||
Vulkan::SetObjectName(m_device, resources.fence, TinyString::from_fmt("Frame Fence {}", frame_index));
|
||||
Vulkan::SetObjectName(m_device, resources.fence, TinyString::from_format("Frame Fence {}", frame_index));
|
||||
|
||||
if (!m_optional_extensions.vk_khr_push_descriptor)
|
||||
{
|
||||
@ -745,7 +745,7 @@ bool VulkanDevice::CreateCommandBuffers()
|
||||
return false;
|
||||
}
|
||||
Vulkan::SetObjectName(m_device, resources.descriptor_pool,
|
||||
TinyString::from_fmt("Frame Descriptor Pool {}", frame_index));
|
||||
TinyString::from_format("Frame Descriptor Pool {}", frame_index));
|
||||
}
|
||||
|
||||
++frame_index;
|
||||
|
||||
@ -325,15 +325,15 @@ TinyString XInputSource::ConvertKeyToString(InputBindingKey key)
|
||||
if (key.source_subtype == InputSubclass::ControllerAxis && key.data < std::size(s_axis_names))
|
||||
{
|
||||
const char modifier = key.modifier == InputModifier::Negate ? '-' : '+';
|
||||
ret.fmt("XInput-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_axis_names[key.data]);
|
||||
ret.format("XInput-{}/{}{}", static_cast<u32>(key.source_index), modifier, s_axis_names[key.data]);
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerButton && key.data < std::size(s_button_names))
|
||||
{
|
||||
ret.fmt("XInput-{}/{}", static_cast<u32>(key.source_index), s_button_names[key.data]);
|
||||
ret.format("XInput-{}/{}", static_cast<u32>(key.source_index), s_button_names[key.data]);
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerMotor)
|
||||
{
|
||||
ret.fmt("XInput-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
|
||||
ret.format("XInput-{}/{}Motor", static_cast<u32>(key.source_index), key.data ? "Large" : "Small");
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,14 +350,14 @@ TinyString XInputSource::ConvertKeyToIcon(InputBindingKey key)
|
||||
{
|
||||
if (key.data < std::size(s_axis_icons) && key.modifier != InputModifier::FullAxis)
|
||||
{
|
||||
ret.fmt("XInput-{} {}", static_cast<u32>(key.source_index),
|
||||
ret.format("XInput-{} {}", static_cast<u32>(key.source_index),
|
||||
s_axis_icons[key.data][key.modifier == InputModifier::None]);
|
||||
}
|
||||
}
|
||||
else if (key.source_subtype == InputSubclass::ControllerButton)
|
||||
{
|
||||
if (key.data < std::size(s_button_icons))
|
||||
ret.fmt("XInput-{} {}", static_cast<u32>(key.source_index), s_button_icons[key.data]);
|
||||
ret.format("XInput-{} {}", static_cast<u32>(key.source_index), s_button_icons[key.data]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user