CMake/Source/cmExternalMakefileProjectGenerator.cxx
Sebastian Holtermann 9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00

68 lines
1.7 KiB
C++

/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExternalMakefileProjectGenerator.h"
#include "cmStringAlgorithms.h"
#include <utility>
class cmMakefile;
void cmExternalMakefileProjectGenerator::EnableLanguage(
std::vector<std::string> const& /*unused*/, cmMakefile* /*unused*/,
bool /*unused*/)
{
}
std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
const std::string& globalGenerator, const std::string& extraGenerator)
{
std::string fullName;
if (!globalGenerator.empty()) {
if (!extraGenerator.empty()) {
fullName = cmStrCat(extraGenerator, " - ");
}
fullName += globalGenerator;
}
return fullName;
}
bool cmExternalMakefileProjectGenerator::Open(
const std::string& /*bindir*/, const std::string& /*projectName*/,
bool /*dryRun*/)
{
return false;
}
cmExternalMakefileProjectGeneratorFactory::
cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc)
: Name(std::move(n))
, Documentation(std::move(doc))
{
}
cmExternalMakefileProjectGeneratorFactory::
~cmExternalMakefileProjectGeneratorFactory() = default;
std::string cmExternalMakefileProjectGeneratorFactory::GetName() const
{
return this->Name;
}
std::string cmExternalMakefileProjectGeneratorFactory::GetDocumentation() const
{
return this->Documentation;
}
std::vector<std::string>
cmExternalMakefileProjectGeneratorFactory::GetSupportedGlobalGenerators() const
{
return this->SupportedGlobalGenerators;
}
void cmExternalMakefileProjectGeneratorFactory::AddSupportedGlobalGenerator(
const std::string& base)
{
this->SupportedGlobalGenerators.push_back(base);
}