Changeset 68154 in vbox
- Timestamp:
- Jul 28, 2017 11:58:57 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/ministring.h
r68124 r68154 532 532 533 533 /** 534 * Erases a sequence from the string. 535 * 536 * @returns Reference to the object. 537 * @param offStart Where in @a this string to start erasing. 538 * @param cchLength How much following @a offStart to erase. 539 */ 540 RTCString &erase(size_t offStart = 0, size_t cchLength = npos); 541 542 /** 534 543 * Replaces a span of @a this string with a replacement string. 535 544 * -
trunk/src/VBox/Runtime/common/string/ministring.cpp
r68125 r68154 278 278 } 279 279 280 RTCString &RTCString::erase(size_t offStart /*= 0*/, size_t cchLength /*= npos*/) 281 { 282 size_t cch = length(); 283 if (offStart < cch) 284 { 285 if (cchLength >= cch - offStart) 286 { 287 /* Trail removal, nothing to move. */ 288 m_cch = offStart; 289 m_psz[offStart] = '\0'; 290 } 291 else if (cchLength > 0) 292 { 293 /* Pull up the tail to offStart. */ 294 size_t cchAfter = cch - offStart - cchLength; 295 memmove(&m_psz[offStart], &m_psz[offStart + cchLength], cchAfter); 296 m_cch = cch -= cchLength; 297 m_psz[cch] = '\0'; 298 } 299 } 300 return *this; 301 } 280 302 281 303 RTCString &RTCString::replace(size_t offStart, size_t cchLength, const RTCString &rStrReplacement)
Note:
See TracChangeset
for help on using the changeset viewer.