VirtualBox

Changeset 21079 in vbox for trunk/src/VBox/Main/glue


Ignore:
Timestamp:
Jun 30, 2009 3:59:22 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49339
Message:

Main: move libxml2 to IPRT unconditionally (remove VBOX_WITH_LIBXML2_IN_VBOXRT); move xml classes to IPRT; introduce IPRT ministring class as base for both Utf8Str and xml.cpp, with better performance; introduce some Utf8Str helpers to avoid string buffer hacks in Main code; remove std::auto_ptr<> from some headers

Location:
trunk/src/VBox/Main/glue
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r21077 r21079  
    118118
    119119                    Utf8Str message;
    120                     rc = ex->GetMessage (message.asOutParam());
     120                    rc = ex->GetMessage(message.asOutParam());
     121                    message.jolt();
    121122                    gotSomething |= NS_SUCCEEDED (rc);
    122123                    if (NS_SUCCEEDED (rc))
  • trunk/src/VBox/Main/glue/VirtualBoxErrorInfo.cpp

    r21077 r21079  
    179179    AssertComRC (rc);
    180180    Utf8Str message;
    181     rc = aInfo->GetMessage (message.asOutParam());
     181    rc = aInfo->GetMessage(message.asOutParam());
     182    message.jolt();
    182183    AssertComRC (rc);
    183184    mText = message;
  • trunk/src/VBox/Main/glue/string.cpp

    r21077 r21079  
    2626
    2727#include <iprt/err.h>
     28#include <iprt/path.h>
    2829
    2930namespace com
     
    8586
    8687                size_t cbCopy = psz - pFirst;
    87                 ret.alloc(cbCopy + 1);
    88                 memcpy(ret.str, pFirst, cbCopy);
    89                 ret.str[cbCopy] = '\0';
     88                ret.reserve(cbCopy + 1);
     89                memcpy(ret.m_psz, pFirst, cbCopy);
     90                ret.m_psz[cbCopy] = '\0';
    9091            }
    9192        }
     
    9596}
    9697
     98bool Utf8Str::endsWith(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const
     99{
     100    size_t l1 = length();
     101    if (l1 == 0)
     102        return false;
     103
     104    size_t l2 = that.length();
     105    if (l1 < l2)
     106        return false;
     107
     108    size_t l = l1 - l2;
     109    if (cs == CaseSensitive)
     110        return ::RTStrCmp(&m_psz[l], that.m_psz) == 0;
     111    else
     112        return ::RTStrICmp(&m_psz[l], that.m_psz) == 0;
     113}
     114
     115bool Utf8Str::startsWith(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const
     116{
     117    size_t l1 = length();
     118    size_t l2 = that.length();
     119    if (l1 == 0 || l2 == 0)
     120        return false;
     121
     122    if (l1 < l2)
     123        return false;
     124
     125    if (cs == CaseSensitive)
     126        return ::RTStrNCmp(m_psz, that.m_psz, l2) == 0;
     127    else
     128        return ::RTStrNICmp(m_psz, that.m_psz, l2) == 0;
     129}
     130
     131bool Utf8Str::contains(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const
     132{
     133    if (cs == CaseSensitive)
     134        return ::RTStrStr(m_psz, that.m_psz) != NULL;
     135    else
     136        return ::RTStrIStr(m_psz, that.m_psz) != NULL;
     137}
     138
     139Utf8Str& Utf8Str::toLower()
     140{
     141    if (!isEmpty())
     142        ::RTStrToLower(m_psz);
     143    return *this;
     144}
     145
     146Utf8Str& Utf8Str::toUpper()
     147{
     148    if (!isEmpty())
     149        ::RTStrToUpper(m_psz);
     150    return *this;
     151}
     152
     153void Utf8Str::stripTrailingSlash()
     154{
     155    RTPathStripTrailingSlash(m_psz);
     156    jolt();
     157}
     158
     159void Utf8Str::stripFilename()
     160{
     161    RTPathStripFilename(m_psz);
     162    jolt();
     163}
     164
     165void Utf8Str::stripExt()
     166{
     167    RTPathStripExt(m_psz);
     168    jolt();
     169}
     170
    97171int Utf8Str::toInt(uint64_t &i) const
    98172{
    99     if (!str)
     173    if (!m_psz)
    100174        return VERR_NO_DIGITS;
    101     return RTStrToUInt64Ex(str, NULL, 0, &i);
     175    return RTStrToUInt64Ex(m_psz, NULL, 0, &i);
    102176}
    103177
    104178int Utf8Str::toInt(uint32_t &i) const
    105179{
    106     if (!str)
     180    if (!m_psz)
    107181        return VERR_NO_DIGITS;
    108     return RTStrToUInt32Ex(str, NULL, 0, &i);
     182    return RTStrToUInt32Ex(m_psz, NULL, 0, &i);
    109183}
    110184
Note: See TracChangeset for help on using the changeset viewer.

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