MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / addExactName

Method addExactName

src/Base/UniqueNameManager.cpp:64–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void Base::UniqueNameManager::addExactName(std::string_view name)
65{
66 const auto [namePrefix, nameSuffix, digitCount, digitsValue] = decomposeName(name);
67 std::string baseName {namePrefix};
68 baseName += nameSuffix;
69 auto baseNameEntry = uniqueSeeds.find(baseName);
70 if (baseNameEntry == uniqueSeeds.end()) {
71 // First use of baseName
72 baseNameEntry
73 = uniqueSeeds
74 .emplace(baseName, std::vector<PiecewiseSparseIntegerSet<UnlimitedUnsigned>>())
75 .first;
76 }
77 if (digitCount >= baseNameEntry->second.size()) {
78 // First use of this digitCount
79 baseNameEntry->second.resize(digitCount + 1);
80 }
81 PiecewiseSparseIntegerSet<UnlimitedUnsigned>& baseNameAndDigitCountEntry
82 = baseNameEntry->second[digitCount];
83
84 if (baseNameAndDigitCountEntry.contains(digitsValue)) {
85 // We already have at least one instance of the name.
86 // Increment the duplicateCounts entry for that name,
87 // making one if none is present with an initial count of 1
88 // representing the singleton element we already have.
89 duplicateCounts.try_emplace(std::string {name}, 1U).first->second++;
90 return;
91 }
92 baseNameAndDigitCountEntry.add(digitsValue);
93}
94std::string Base::UniqueNameManager::makeUniqueName(std::string_view modelName, std::size_t minDigits) const
95{
96 auto [namePrefix, nameSuffix, digitCount, digitsValue] = decomposeName(modelName);

Callers 7

registerLabelMethod · 0.80
_addObjectMethod · 0.80
newDocumentMethod · 0.80
getUniqueDocumentNameMethod · 0.80
getUniquePropertyNameMethod · 0.80
addFileMethod · 0.80
TESTFunction · 0.80

Calls 7

findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
containsMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected