Changeset 67651 in vbox for trunk/src/VBox/Runtime/common/string/ministring.cpp
- Timestamp:
- Jun 27, 2017 5:11:00 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/ministring.cpp
r67650 r67651 33 33 *********************************************************************************************************************************/ 34 34 #include <iprt/cpp/ministring.h> 35 #include <iprt/ctype.h> 35 36 36 37 … … 282 283 #endif 283 284 285 286 RTCString &RTCString::strip() 287 { 288 stripRight(); 289 return stripLeft(); 290 } 291 292 293 RTCString &RTCString::stripLeft() 294 { 295 char *psz = m_psz; 296 size_t const cch = m_cch; 297 size_t off = 0; 298 while (off < cch && RT_C_IS_SPACE(psz[off])) 299 off++; 300 if (off > 0) 301 { 302 if (off != cch) 303 { 304 memmove(psz, &psz[off], cch - off + 1); 305 m_cch = cch - off; 306 } 307 else 308 setNull(); 309 } 310 return *this; 311 } 312 313 314 RTCString &RTCString::stripRight() 315 { 316 char *psz = m_psz; 317 size_t cch = m_cch; 318 while (cch > 0 && RT_C_IS_SPACE(psz[cch - 1])) 319 cch--; 320 if (m_cch != cch) 321 { 322 m_cch = cch; 323 psz[cch] = '\0'; 324 } 325 return *this; 326 } 327 328 329 284 330 RTCString RTCString::substrCP(size_t pos /*= 0*/, size_t n /*= npos*/) const 285 331 {
Note:
See TracChangeset
for help on using the changeset viewer.