VirtualBox

Changeset 50503 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Feb 19, 2014 8:35:27 AM (11 years ago)
Author:
vboxsync
Message:

IPRT/ministring: Added RTCString::joinEx().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/ministring.cpp

    r40417 r50503  
    88
    99/*
    10  * Copyright (C) 2007-2012 Oracle Corporation
     10 * Copyright (C) 2007-2014 Oracle Corporation
    1111 *
    1212 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    395395/* static */
    396396RTCString
    397 RTCString::join(const RTCList<RTCString, RTCString *> &a_rList,
    398                 const RTCString &a_rstrSep /* = "" */)
     397RTCString::joinEx(const RTCList<RTCString, RTCString *> &a_rList,
     398                  const RTCString &a_rstrPrefix /* = "" */,
     399                  const RTCString &a_rstrSep /* = "" */)
    399400{
    400401    RTCString strRet;
     
    403404        /* calc the required size */
    404405        size_t cbNeeded = a_rstrSep.length() * (a_rList.size() - 1) + 1;
     406        cbNeeded += a_rstrPrefix.length() * (a_rList.size() - 1) + 1;
    405407        for (size_t i = 0; i < a_rList.size(); ++i)
    406408            cbNeeded += a_rList.at(i).length();
     
    410412        for (size_t i = 0; i < a_rList.size() - 1; ++i)
    411413        {
     414            if (a_rstrPrefix.isNotEmpty())
     415                strRet.append(a_rstrPrefix);
    412416            strRet.append(a_rList.at(i));
    413417            strRet.append(a_rstrSep);
     
    417421    /* special case: one list item. */
    418422    else if (a_rList.size() > 0)
     423    {
     424        if (a_rstrPrefix.isNotEmpty())
     425            strRet.append(a_rstrPrefix);
    419426        strRet.append(a_rList.last());
     427    }
    420428
    421429    return strRet;
     430}
     431
     432/* static */
     433RTCString
     434RTCString::join(const RTCList<RTCString, RTCString *> &a_rList,
     435                const RTCString &a_rstrSep /* = "" */)
     436{
     437    return RTCString::joinEx(a_rList,
     438                             "" /* a_rstrPrefix */, a_rstrSep);
    422439}
    423440
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette