MCPcopy Create free account
hub / github.com/Kitware/CMake / cmCatViews

Function cmCatViews

Source/cmStringAlgorithms.cxx:141–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141std::string cmCatViews(
142 std::initializer_list<std::pair<cm::string_view, std::string*>> views)
143{
144 std::size_t totalSize = 0;
145 std::string* rvalueString = nullptr;
146 std::size_t rvalueStringLength = 0;
147 std::size_t rvalueStringOffset = 0;
148 for (auto const& view : views) {
149 // Find the rvalue string with the largest capacity.
150 if (view.second &&
151 (!rvalueString ||
152 view.second->capacity() > rvalueString->capacity())) {
153 rvalueString = view.second;
154 rvalueStringLength = rvalueString->length();
155 rvalueStringOffset = totalSize;
156 }
157 totalSize += view.first.size();
158 }
159
160 std::string result;
161 std::string::size_type initialLen = 0;
162 if (rvalueString && rvalueString->capacity() >= totalSize) {
163 result = std::move(*rvalueString);
164 } else {
165 rvalueString = nullptr;
166 }
167 result.resize(totalSize);
168 if (rvalueString && rvalueStringOffset > 0) {
169 std::copy_backward(result.begin(), result.begin() + rvalueStringLength,
170 result.begin() + rvalueStringOffset +
171 rvalueStringLength);
172 }
173 std::string::iterator sit = result.begin() + initialLen;
174 for (auto const& view : views) {
175 if (rvalueString && view.second == rvalueString) {
176 sit += rvalueStringLength;
177 } else {
178 sit = std::copy_n(view.first.data(), view.first.size(), sit);
179 }
180 }
181 return result;
182}
183
184bool cmStrToLong(char const* str, long* value)
185{

Callers 2

cmStrCatFunction · 0.85
cmWrapFunction · 0.85

Calls 6

moveFunction · 0.85
lengthMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…