Use std::stringstream when building deprecation text.

This commit is contained in:
Miku AuahDark
2022-03-01 22:33:33 +08:00
parent 0fa00e0bdc
commit 7b3e2182aa
+13 -12
View File
@@ -24,6 +24,7 @@
#include <atomic> #include <atomic>
#include <map> #include <map>
#include <sstream>
namespace love namespace love
{ {
@@ -97,32 +98,32 @@ bool isDeprecationOutputEnabled()
std::string getDeprecationNotice(const DeprecationInfo &info, bool usewhere) std::string getDeprecationNotice(const DeprecationInfo &info, bool usewhere)
{ {
std::string notice; std::stringstream notice;
if (usewhere) if (usewhere)
notice += info.where; notice << info.where;
notice += "Using deprecated "; notice << "Using deprecated ";
if (info.apiType == API_FUNCTION) if (info.apiType == API_FUNCTION)
notice += "function "; notice << "function ";
else if (info.apiType == API_METHOD) else if (info.apiType == API_METHOD)
notice += "method "; notice << "method ";
else if (info.apiType == API_CALLBACK) else if (info.apiType == API_CALLBACK)
notice += "callback "; notice << "callback ";
else if (info.apiType == API_FIELD) else if (info.apiType == API_FIELD)
notice += "field "; notice << "field ";
else if (info.apiType == API_CONSTANT) else if (info.apiType == API_CONSTANT)
notice += "constant "; notice << "constant ";
notice += info.name; notice << info.name;
if (info.type == DEPRECATED_REPLACED && !info.replacement.empty()) if (info.type == DEPRECATED_REPLACED && !info.replacement.empty())
notice += " (replaced by " + info.replacement + ")"; notice << " (replaced by " << info.replacement << ")";
else if (info.type == DEPRECATED_RENAMED && !info.replacement.empty()) else if (info.type == DEPRECATED_RENAMED && !info.replacement.empty())
notice += " (renamed to " + info.replacement + ")"; notice << " (renamed to " << info.replacement << ")";
return notice; return notice.str();
} }
GetDeprecated::GetDeprecated() GetDeprecated::GetDeprecated()