Changeset 36501 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Apr 1, 2011 1:40:21 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 70912
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/ministring.cpp
r35567 r36501 332 332 } 333 333 334 iprt::list<iprt::MiniString, iprt::MiniString*> MiniString::split(const iprt::MiniString &strSep, SplitMode mode /* = RemoveEmptyParts */) 335 { 336 iprt::list<iprt::MiniString> res; 337 if (!m_psz) 338 return res; 339 if (strSep.isEmpty()) 340 { 341 res.append(iprt::MiniString(m_psz)); 342 return res; 343 } 344 345 size_t cch = m_cch; 346 char *pszTmp = m_psz; 347 while(cch > 0) 348 { 349 char *pszNext = strstr(pszTmp, strSep.c_str()); 350 if (!pszNext) 351 break; 352 size_t chNext = pszNext - pszTmp; 353 if ( chNext > 0 354 || mode == KeepEmptyParts) 355 res.append(iprt::MiniString(pszTmp, chNext)); 356 pszTmp += chNext + strSep.length(); 357 cch -= chNext + strSep.length(); 358 } 359 /* Some characters left at the end? */ 360 if (cch > 0) 361 res.append(iprt::MiniString(pszTmp, cch)); 362 363 return res; 364 } 365 366 /* static */ 367 iprt::MiniString MiniString::join(const iprt::list<iprt::MiniString, iprt::MiniString*> &list, const iprt::MiniString &strSep /* = "" */) 368 { 369 MiniString res; 370 if (list.size() > 1) 371 { 372 for(size_t i = 0; i < list.size() - 1; ++i) 373 res += list.at(i) + strSep; 374 res += list.last(); 375 } 376 377 return res; 378 } 379 380 const iprt::MiniString operator+(const iprt::MiniString &one, const iprt::MiniString &other) 381 { 382 iprt::MiniString res(one); 383 384 return res += other; 385 } 386 387 const iprt::MiniString operator+(const iprt::MiniString &one, const char *pcszOther) 388 { 389 iprt::MiniString res(one); 390 391 return res += pcszOther; 392 } 393 394 const iprt::MiniString operator+(const char *pcszOne, const iprt::MiniString &other) 395 { 396 iprt::MiniString res(pcszOne); 397 398 return res += other; 399 } 400
Note:
See TracChangeset
for help on using the changeset viewer.