mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-21 17:45:25 -04:00
a8559bfbbc
* Update all CMakeLists of extensions to use clang-format * Run clang-format on all Extensions * Update GDCore CMakeLists.txt to add clang-format * Run clang-format on GDCore files * Update GDJS and GDCpp CMakeLists.txt to add clang-format * Run clang-format on GDCpp and GDJS files
31 lines
834 B
C++
31 lines
834 B
C++
/*
|
|
* GDevelop Core
|
|
* Copyright 2008-2016 Florian Rival (Florian.Rival@gmail.com). All rights
|
|
* reserved. This project is released under the MIT License.
|
|
*/
|
|
#include "NewNameGenerator.h"
|
|
#include "GDCore/String.h"
|
|
|
|
namespace gd {
|
|
|
|
gd::String NewNameGenerator::Generate(
|
|
const gd::String &name,
|
|
const gd::String &prefix,
|
|
std::function<bool(const gd::String &)> exists) {
|
|
if (!exists(name)) return name;
|
|
|
|
gd::String potentialName = prefix + name;
|
|
for (unsigned int i = 2; exists(potentialName); ++i) {
|
|
potentialName = prefix + name + gd::String::From(i);
|
|
}
|
|
|
|
return potentialName;
|
|
}
|
|
|
|
gd::String NewNameGenerator::Generate(
|
|
const gd::String &name, std::function<bool(const gd::String &)> exists) {
|
|
return NewNameGenerator::Generate(name, "", exists);
|
|
}
|
|
|
|
} // namespace gd
|