mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-10-06 04:03:27 +03:00
cmSystemTools: Simplify string case conversion methods
Take advantage of KWSys SystemTools' new move semantics.
This commit is contained in:
1 parent
bc89442828
commit
51e3b1b4b2
2 files changed
+10
-32
No files matched your search
@@ -457,30 +457,6 @@ void cmSystemTools::ExpandRegistryValues(std::string& source,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return a lower case string
|
||||
std::string cmSystemTools::LowerCase(cm::string_view s)
|
||||
{
|
||||
std::string n;
|
||||
n.resize(s.size());
|
||||
for (size_t i = 0; i < s.size(); i++) {
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
tolower(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// Return an upper case string
|
||||
std::string cmSystemTools::UpperCase(cm::string_view s)
|
||||
{
|
||||
std::string n;
|
||||
n.resize(s.size());
|
||||
for (size_t i = 0; i < s.size(); i++) {
|
||||
n[i] = static_cast<std::string::value_type>(
|
||||
toupper(static_cast<unsigned char>(s[i])));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
std::string cmSystemTools::HelpFileName(cm::string_view str)
|
||||
{
|
||||
std::string name(str);
|
||||
|
||||
+10
-8
@@ -40,20 +40,22 @@ public:
|
||||
using Superclass = cmsys::SystemTools;
|
||||
using Encoding = cmProcessOutput::Encoding;
|
||||
|
||||
/**
|
||||
* Return a lower case string
|
||||
*/
|
||||
static std::string LowerCase(cm::string_view);
|
||||
/** Return a lower-case string. */
|
||||
static std::string LowerCase(cm::string_view s)
|
||||
{
|
||||
return cmsys::SystemTools::LowerCase(std::string(s));
|
||||
}
|
||||
static std::string LowerCase(char const* s)
|
||||
{
|
||||
return LowerCase(cm::string_view{ s });
|
||||
}
|
||||
using cmsys::SystemTools::LowerCase;
|
||||
|
||||
/**
|
||||
* Return an upper case string
|
||||
*/
|
||||
static std::string UpperCase(cm::string_view);
|
||||
/** Return an upper-case string. */
|
||||
static std::string UpperCase(cm::string_view s)
|
||||
{
|
||||
return cmsys::SystemTools::UpperCase(std::string(s));
|
||||
}
|
||||
static std::string UpperCase(char const* s)
|
||||
{
|
||||
return UpperCase(cm::string_view{ s });
|
||||
|
||||
Reference in new issue
Block a user