VirtualBox

Changeset 21079 in vbox for trunk


Ignore:
Timestamp:
Jun 30, 2009 3:59:22 PM (16 years ago)
Author:
vboxsync
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
Files:
19 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r21077 r21079  
    490490## Use the new version of liblzf. Remove with the old liblzf.
    491491#VBOX_WITH_NEW_LIBLZF = 1
    492 ## For experimenting with linking libxml2 into VBoxRT.
    493 VBOX_WITH_LIBXML2_IN_VBOXRT = 1
    494492
    495493## For experimenting with disabling preemption instead of interrupts
     
    17991797#
    18001798SDK_VBOX_LIBXML2          = .
    1801 #if1of ($(KBUILD_TARGET),win os2 solaris)
    1802  SDK_VBOX_LIBXML2_INCS   ?= $(PATH_ROOT)/src/libs/libxml2-2.6.30/include
    1803  ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
    1804   SDK_VBOX_LIBXML2_DEFS  ?= _REENTRANT
    1805  else
    1806   SDK_VBOX_LIBXML2_DEFS  ?= LIBXML_STATIC _REENTRANT
    1807   SDK_VBOX_LIBXML2_LIBS  ?= $(PATH_LIB)/VBox-libxml2$(VBOX_SUFF_LIB)
    1808  endif
    1809  SDK_VBOX_LIBXML2_DEFS.win += WIN32 _WINDOWS _MBCS
    1810 #else if1of ($(KBUILD_TARGET),linux)
    1811 # SDK_VBOX_LIBXML2_INCS      ?=
    1812 # SDK_VBOX_LIBXML2_LIBS      ?=
    1813 # SDK_VBOX_LIBXML2_CFLAGS    ?= $(shell pkg-config libxml-2.0 --cflags)
    1814 # SDK_VBOX_LIBXML2_CXXFLAGS  ?= $(SDK_VBOX_LIBXML2_CFLAGS)
    1815 # SDK_VBOX_LIBXML2_LDFLAGS   ?= $(shell pkg-config libxml-2.0 --libs)
    1816 #else
    1817 # SDK_VBOX_LIBXML2_INCS   ?=
    1818 # SDK_VBOX_LIBXML2_LIBS   ?= xml2
    1819 #endif
     1799SDK_VBOX_LIBXML2_INCS   ?= $(PATH_ROOT)/src/libs/libxml2-2.6.30/include
     1800SDK_VBOX_LIBXML2_DEFS  ?= _REENTRANT
     1801SDK_VBOX_LIBXML2_DEFS.win += WIN32 _WINDOWS _MBCS
     1802# note: no linking to LIB here, we do that explicitly in src/VBox/Runtime/Makefile.kmk to link
     1803# libxml against VBoxRT
    18201804
    18211805SDK_VBOX_LIBXSLT          = .
     
    18531837SDK_VBOX_OPENSSL_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS)
    18541838SDK_VBOX_OPENSSL_ORDERDEPS ?= $(crypto-headers_1_TARGET)
    1855 ifndef VBOX_WITH_LIBXML2_IN_VBOXRT
    1856  SDK_VBOX_OPENSSL_LIBS ?= $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
    1857 endif
     1839SDK_VBOX_OPENSSL_LIBS ?= $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
    18581840# Build entire openssl library, not just the minimal subset.
    18591841if1of ($(KBUILD_TARGET), linux solaris)
  • trunk/include/VBox/com/string.h

    r21077 r21079  
    4949#include "VBox/com/assert.h"
    5050
    51 #include <iprt/string.h>
    5251#include <iprt/cpputils.h>
    5352#include <iprt/alloc.h>
     53#include <iprt/ministring_cpp.h>
    5454
    5555namespace com
     
    153153    }
    154154
    155     bool operator == (const Bstr &that) const { return !compare (that.bstr); }
    156     bool operator != (const Bstr &that) const { return !!compare (that.bstr); }
    157     bool operator == (CBSTR that) const { return !compare (that); }
    158     bool operator == (BSTR that) const { return !compare (that); }
     155    bool operator==(const Bstr &that) const { return !compare (that.bstr); }
     156    bool operator!=(const Bstr &that) const { return !!compare (that.bstr); }
     157    bool operator==(CBSTR that) const { return !compare (that); }
     158    bool operator==(BSTR that) const { return !compare (that); }
    159159
    160160#if defined (VBOX_WITH_XPCOM)
    161     bool operator != (const wchar_t *that) const
     161    bool operator!=(const wchar_t *that) const
    162162    {
    163163        AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR));
    164164        return !!compare ((CBSTR) that);
    165165    }
    166     bool operator == (const wchar_t *that) const
     166    bool operator==(const wchar_t *that) const
    167167    {
    168168        AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR));
     
    171171#endif
    172172
    173     bool operator != (CBSTR that) const { return !!compare (that); }
    174     bool operator != (BSTR that) const { return !!compare (that); }
    175     bool operator < (const Bstr &that) const { return compare (that.bstr) < 0; }
    176     bool operator < (CBSTR that) const { return compare (that) < 0; }
    177     bool operator < (BSTR that) const { return compare (that) < 0; }
     173    bool operator!=(CBSTR that) const { return !!compare (that); }
     174    bool operator!=(BSTR that) const { return !!compare (that); }
     175    bool operator<(const Bstr &that) const { return compare (that.bstr) < 0; }
     176    bool operator<(CBSTR that) const { return compare (that) < 0; }
     177    bool operator<(BSTR that) const { return compare (that) < 0; }
    178178#if defined (VBOX_WITH_XPCOM)
    179     bool operator < (const wchar_t *that) const
     179    bool operator<(const wchar_t *that) const
    180180    {
    181181        AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR));
     
    303303
    304304/* symmetric compare operators */
    305 inline bool operator== (CBSTR l, const Bstr &r) { return r.operator== (l); }
    306 inline bool operator!= (CBSTR l, const Bstr &r) { return r.operator!= (l); }
    307 inline bool operator== (BSTR l, const Bstr &r) { return r.operator== (l); }
    308 inline bool operator!= (BSTR l, const Bstr &r) { return r.operator!= (l); }
     305inline bool operator==(CBSTR l, const Bstr &r) { return r.operator== (l); }
     306inline bool operator!=(CBSTR l, const Bstr &r) { return r.operator!= (l); }
     307inline bool operator==(BSTR l, const Bstr &r) { return r.operator== (l); }
     308inline bool operator!=(BSTR l, const Bstr &r) { return r.operator!= (l); }
    309309
    310310////////////////////////////////////////////////////////////////////////////////
     
    324324 *    afterwards.
    325325 */
    326 class Utf8Str
     326class Utf8Str : public ministring
    327327{
    328328public:
    329329
    330     enum CaseSensitivity
    331     {
    332         CaseSensitive,
    333         CaseInsensitive
    334     };
    335 
    336     typedef char *String;
    337     typedef const char *ConstString;
    338 
    339     Utf8Str () : str (NULL) {}
    340 
    341     Utf8Str (const Utf8Str &that) : str (NULL) { raw_copy (str, that.str); }
    342     Utf8Str (const char *that) : str (NULL) { raw_copy (str, that); }
    343 
    344     Utf8Str (const Bstr &that) : str (NULL) { raw_copy (str, that); }
    345     Utf8Str (CBSTR that) : str (NULL) { raw_copy (str, that); }
    346 
    347     /** Shortcut that calls #alloc(aSize) right after object creation. */
    348     Utf8Str (size_t aSize) : str (NULL) { alloc(aSize); }
    349 
    350     virtual ~Utf8Str () { setNull(); }
    351 
    352     Utf8Str &operator = (const Utf8Str &that) { safe_assign (that.str); return *this; }
    353     Utf8Str &operator = (const char *that) { safe_assign (that); return *this; }
    354 
    355     Utf8Str &operator = (const Bstr &that)
    356     {
    357         setNull();
    358         raw_copy (str, that);
    359         return *this;
    360     }
    361     Utf8Str &operator = (CBSTR that)
    362     {
    363         setNull();
    364         raw_copy (str, that);
    365         return *this;
    366     }
    367 
    368     Utf8Str &setNull()
    369     {
    370         if (str)
    371         {
    372 #if !defined (VBOX_WITH_XPCOM)
    373             ::RTStrFree (str);
    374 #else
    375             nsMemory::Free (str);
    376 #endif
    377             str = NULL;
    378         }
    379         return *this;
    380     }
    381 
    382     Utf8Str &setNullIfEmpty()
    383     {
    384         if (str && *str == 0)
    385         {
    386 #if !defined (VBOX_WITH_XPCOM)
    387             ::RTStrFree (str);
    388 #else
    389             nsMemory::Free (str);
    390 #endif
    391             str = NULL;
    392         }
    393         return *this;
    394     }
    395 
    396     /**
    397      *  Allocates memory for a string capable to store \a aSize - 1 bytes (not characters!);
    398      *  in other words, aSize includes the terminating zero character. If \a aSize
    399      *  is zero, or if a memory allocation error occurs, this object will become null.
    400      */
    401     Utf8Str &alloc (size_t aSize)
    402     {
    403         setNull();
    404         if (aSize)
    405         {
    406 #if !defined (VBOX_WITH_XPCOM)
    407             str = (char *) ::RTMemTmpAlloc (aSize);
    408 #else
    409             str = (char *) nsMemory::Alloc (aSize);
    410 #endif
    411             if (str)
    412                 str [0] = 0;
    413         }
    414         return *this;
    415     }
    416 
    417     void append(const Utf8Str &that)
    418     {
    419         size_t cbThis = length();
    420         size_t cbThat = that.length();
    421 
    422         if (cbThat)
    423         {
    424             size_t cbBoth = cbThis + cbThat + 1;
    425 
    426             // @todo optimize with realloc() once the memory management is fixed
    427             char *pszTemp;
    428 #if !defined (VBOX_WITH_XPCOM)
    429             pszTemp = (char*)::RTMemTmpAlloc(cbBoth);
    430 #else
    431             pszTemp = (char*)nsMemory::Alloc(cbBoth);
    432 #endif
    433             if (str)
    434             {
    435                 memcpy(pszTemp, str, cbThis);
    436                 setNull();
    437             }
    438             if (that.str)
    439                 memcpy(pszTemp + cbThis, that.str, cbThat);
    440             pszTemp[cbThis + cbThat] = '\0';
    441 
    442             str = pszTemp;
    443         }
    444     }
    445 
    446     int compare (const char *pcsz, CaseSensitivity cs = CaseSensitive) const
    447     {
    448         if (str == pcsz)
    449             return 0;
    450         if (str == NULL)
    451             return -1;
    452         if (pcsz == NULL)
    453             return 1;
    454 
    455         if (cs == CaseSensitive)
    456             return ::RTStrCmp(str, pcsz);
    457         else
    458             return ::RTStrICmp(str, pcsz);
    459     }
    460 
    461     int compare (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const
    462     {
    463         return compare (that.str, cs);
    464     }
    465 
    466     bool operator == (const Utf8Str &that) const { return !compare (that); }
    467     bool operator != (const Utf8Str &that) const { return !!compare (that); }
    468     bool operator == (const char *that) const { return !compare (that); }
    469     bool operator != (const char *that) const { return !!compare (that); }
    470     bool operator < (const Utf8Str &that) const { return compare (that) < 0; }
    471     bool operator < (const char *that) const { return compare (that) < 0; }
    472 
    473     bool endsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const
    474     {
    475         if (isNull() || that.isNull())
    476             return false;
    477 
    478         size_t l1 = length();
    479         size_t l2 = that.length();
    480         if (l1 < l2)
    481             return false;
    482 
    483         size_t l = l1 - l2;
    484         if (cs == CaseSensitive)
    485             return ::RTStrCmp(&str[l], that.str) == 0;
    486         else
    487             return ::RTStrICmp(&str[l], that.str) == 0;
    488     }
    489 
    490     bool startsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const
    491     {
    492         if (isNull() || that.isNull())
    493             return false;
    494 
    495         size_t l1 = length();
    496         size_t l2 = that.length();
    497         if (l1 < l2)
    498             return false;
    499 
    500         if (cs == CaseSensitive)
    501             return ::RTStrNCmp(str, that.str, l2) == 0;
    502         else
    503             return ::RTStrNICmp(str, that.str, l2) == 0;
    504     }
    505 
    506     bool contains (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const
    507     {
    508         if (cs == CaseSensitive)
    509             return ::RTStrStr (str, that.str) != NULL;
    510         else
    511             return ::RTStrIStr (str, that.str) != NULL;
    512     }
    513 
    514     Utf8Str& toLower()
    515     {
    516         if (isEmpty())
    517             return *this;
    518 
    519         ::RTStrToLower(str);
    520 
    521         return *this;
    522     }
    523 
    524     Utf8Str& toUpper()
    525     {
    526         if (isEmpty())
    527             return *this;
    528 
    529         ::RTStrToUpper(str);
    530 
    531         return *this;
    532     }
    533 
    534     bool isNull() const { return str == NULL; }
    535     operator bool() const { return !isNull(); }
    536 
    537     bool isEmpty() const { return isNull() || *str == 0; }
    538 
    539     size_t length() const { return isNull() ? 0 : ::strlen (str); }
    540 
    541     /** Intended to to pass instances as input (|char *|) parameters to methods. */
    542     operator const char *() const { return str; }
    543 
    544     /** The same as operator const char *(), but for situations where the compiler
    545         cannot typecast implicitly (for example, in printf() argument list). */
    546     const char *raw() const { return str; }
    547 
    548     /** The same as operator const char *(), but for situations where the compiler
    549         cannot typecast implicitly (for example, in printf() argument list). */
    550     const char *c_str() const { return str; }
    551 
    552     /**
    553      *  Returns a non-const raw pointer that allows to modify the string directly.
    554      *  @warning
    555      *      Be sure not to modify data beyond the allocated memory! The
    556      *      guaranteed size of the allocated memory is at least #length()
    557      *      bytes after creation and after every assignment operation.
    558      */
    559     char *mutableRaw() { return str; }
     330    Utf8Str() {}
     331
     332    Utf8Str(const Utf8Str &that)
     333        : ministring(that)
     334    {}
     335
     336    Utf8Str(const char *that)
     337        : ministring(that)
     338    {}
     339
     340    Utf8Str(const Bstr &that)
     341    {
     342        copyFrom(that);
     343    }
     344
     345    Utf8Str(CBSTR that)
     346    {
     347        copyFrom(that);
     348    }
     349
     350    Utf8Str& operator=(const Utf8Str &that)
     351    {
     352        ministring::operator=(that);
     353        return *this;
     354    }
     355
     356    Utf8Str& operator=(const char *that)
     357    {
     358        ministring::operator=(that);
     359        return *this;
     360    }
     361
     362    Utf8Str& operator=(const Bstr &that)
     363    {
     364        cleanup();
     365        copyFrom(that);
     366        return *this;
     367    }
     368
     369    Utf8Str& operator=(CBSTR that)
     370    {
     371        cleanup();
     372        copyFrom(that);
     373        return *this;
     374    }
    560375
    561376    /**
     
    564379     *  caller.
    565380     */
    566     const Utf8Str &cloneTo (char **pstr) const
     381    const Utf8Str& cloneTo(char **pstr) const
    567382    {
    568383        if (pstr)
    569         {
    570             *pstr = NULL;
    571             raw_copy (*pstr, str);
    572         }
     384            *pstr = RTStrDup(m_psz);
    573385        return *this;
    574386    }
     
    582394     *  string.
    583395     */
    584     Utf8Str &detachTo (char **pstr)
    585     {
    586         *pstr = str;
    587         str = NULL;
     396    Utf8Str& detachTo(char **pstr)
     397    {
     398        *pstr = m_psz;
     399        m_psz = NULL;
     400        m_cbAllocated = 0;
     401        m_cbLength = 0;
    588402        return *this;
    589403    }
     
    594408     *  caller.
    595409     */
    596     const Utf8Str &cloneTo (BSTR *pstr) const
     410    const Utf8Str& cloneTo(BSTR *pstr) const
    597411    {
    598412        if (pstr)
    599413        {
    600414            *pstr = NULL;
    601             Bstr::raw_copy (*pstr, str);
     415            Bstr::raw_copy(*pstr, m_psz);
    602416        }
    603417        return *this;
     
    623437
    624438    /**
    625      * Attempts to convert the member string into an 32-bit integer.
     439     * Returns true if "this" ends with "that".
     440     * @param that
     441     * @param cs
     442     * @return
     443     */
     444    bool endsWith(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const;
     445
     446    /**
     447     * Returns true if "this" begins with "that".
     448     * @return
     449     */
     450    bool startsWith(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const;
     451
     452    /**
     453     * Returns true if "this" contains "that" (strstr).
     454     * @param that
     455     * @param cs
     456     * @return
     457     */
     458    bool contains(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const;
     459
     460    /**
     461     * Converts "this" to lower case by calling RTStrToLower().
     462     * @return
     463     */
     464    Utf8Str& toLower();
     465
     466    /**
     467     * Converts "this" to upper case by calling RTStrToUpper().
     468     * @return
     469     */
     470    Utf8Str& toUpper();
     471
     472    /**
     473     * Removes a trailing slash from the member string, if present.
     474     * Calls RTPathStripTrailingSlash() without having to mess with mutableRaw().
     475     */
     476    void stripTrailingSlash();
     477
     478    /**
     479     * Removes a trailing filename from the member string, if present.
     480     * Calls RTPathStripFilename() without having to mess with mutableRaw().
     481     */
     482    void stripFilename();
     483
     484    /**
     485     * Removes a trailing file name extension from the member string, if present.
     486     * Calls RTPathStripExt() without having to mess with mutableRaw().
     487     */
     488    void stripExt();
     489
     490    /**
     491     * Attempts to convert the member string into a 32-bit integer.
    626492     *
    627493     * @returns 32-bit unsigned number on success.
     
    630496    int toInt32() const
    631497    {
    632         return RTStrToInt32(str);
     498        return RTStrToInt32(m_psz);
    633499    }
    634500
     
    641507    int toUInt32() const
    642508    {
    643         return RTStrToUInt32(str);
     509        return RTStrToUInt32(m_psz);
    644510    }
    645511
     
    652518    int64_t toInt64() const
    653519    {
    654         return RTStrToInt64(str);
     520        return RTStrToInt64(m_psz);
    655521    }
    656522
     
    663529    uint64_t toUInt64() const
    664530    {
    665         return RTStrToUInt64(str);
     531        return RTStrToUInt64(m_psz);
    666532    }
    667533
     
    684550     *  Takes the ownership of the returned data.
    685551     */
    686     char **asOutParam() { setNull(); return &str; }
     552    char **asOutParam()
     553    {
     554        cleanup();
     555        return &m_psz;
     556    }
    687557
    688558    /**
     
    693563protected:
    694564
    695     void safe_assign (const char *s)
    696     {
    697         if (str != s)
    698         {
    699             setNull();
    700             raw_copy (str, s);
    701         }
    702     }
    703 
    704     inline static void raw_copy (char *&ls, const char *rs)
    705     {
    706         if (rs)
    707 #if !defined (VBOX_WITH_XPCOM)
    708             ::RTStrDupEx (&ls, rs);
    709 #else
    710             ls = (char *) nsMemory::Clone (rs, strlen (rs) + 1);
    711 #endif
    712     }
    713 
    714     inline static void raw_copy (char *&ls, CBSTR rs)
    715     {
    716         if (rs)
    717         {
    718 #if !defined (VBOX_WITH_XPCOM)
    719             ::RTUtf16ToUtf8 ((PRTUTF16) rs, &ls);
    720 #else
    721             char *s = NULL;
    722             ::RTUtf16ToUtf8 ((PRTUTF16) rs, &s);
    723             raw_copy (ls, s);
    724             ::RTStrFree (s);
    725 #endif
    726         }
    727     }
    728 
    729     char *str;
     565    /**
     566     * As with the ministring::copyFrom() variants, this unconditionally
     567     * sets the members to a copy of the given other strings and makes
     568     * no assumptions about previous contents. This can therefore be used
     569     * both in copy constructors, when member variables have no defined
     570     * value, and in assignments after having called cleanup().
     571     *
     572     * This variant converts from a UTF-16 string, most probably from
     573     * a Bstr assignment.
     574     *
     575     * @param rs
     576     */
     577    void copyFrom(CBSTR s)
     578    {
     579        if (s)
     580        {
     581            RTUtf16ToUtf8((PRTUTF16)s, &m_psz);
     582            m_cbLength = strlen(m_psz);             // TODO optimize by using a different RTUtf* function
     583            m_cbAllocated = m_cbLength + 1;
     584        }
     585        else
     586        {
     587            m_cbLength = 0;
     588            m_cbAllocated = 0;
     589            m_psz = NULL;
     590        }
     591    }
    730592
    731593    friend class Bstr; /* to access our raw_copy() */
    732594};
    733 
    734 // symmetric compare operators
    735 inline bool operator== (const char *l, const Utf8Str &r) { return r.operator== (l); }
    736 inline bool operator!= (const char *l, const Utf8Str &r) { return r.operator!= (l); }
    737595
    738596// work around error C2593 of the stupid MSVC 7.x ambiguity resolver
     
    760618}
    761619
    762 inline const Bstr &Bstr::cloneTo (char **pstr) const
    763 {
    764     if (pstr) {
    765         *pstr = NULL;
    766         Utf8Str::raw_copy (*pstr, bstr);
     620inline const Bstr& Bstr::cloneTo(char **pstr) const
     621{
     622    if (pstr)
     623    {
     624        Utf8Str ustr(*this);
     625        ustr.detachTo(pstr);
    767626    }
    768627    return *this;
  • trunk/include/VBox/settings.h

    r21077 r21079  
    3131#define ___VBox_settings_h
    3232
     33#include <limits>
     34
    3335#include <iprt/cdefs.h>
    3436#include <iprt/cpputils.h>
    35 #include <iprt/string.h>
    36 
    37 #include <list>
    38 #include <memory>
    39 #include <limits>
    40 
    4137#include <iprt/time.h>
     38#include <iprt/xml_cpp.h>
    4239
    4340#include <VBox/com/Guid.h>
    44 
    45 #include <VBox/xml.h>
    46 
    47 // #include <stdarg.h>
    4841
    4942/* these conflict with numeric_digits<>::min and max */
  • trunk/include/iprt/xml_cpp.h

    r21077 r21079  
    44
    55/*
    6  * Copyright (C) 2007-2008 Sun Microsystems, Inc.
     6 * Copyright (C) 2007-2009 Sun Microsystems, Inc.
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3535#else /* IN_RING3 */
    3636
     37#include <list>
     38#include <memory>
     39
     40#include <iprt/ministring_cpp.h>
     41
    3742/** @def IN_VBOXXML_R3
    3843 * Used to indicate whether we're inside the same link module as the
     
    5459#endif
    5560
    56 /*
    57  * Shut up MSVC complaining that auto_ptr[_ref] template instantiations (as a
    58  * result of private data member declarations of some classes below) need to
    59  * be exported too to in order to be accessible by clients.
    60  *
    61  * The alternative is to instantiate a template before the data member
    62  * declaration with the VBOXXML_CLASS prefix, but the standard disables
    63  * explicit instantiations in a foreign namespace. In other words, a declaration
    64  * like:
    65  *
    66  *   template class VBOXXML_CLASS std::auto_ptr <Data>;
    67  *
    68  * right before the member declaration makes MSVC happy too, but this is not a
    69  * valid C++ construct (and G++ spits it out). So, for now we just disable the
    70  * warning and will come back to this problem one day later.
    71  *
    72  * We also disable another warning (4275) saying that a DLL-exported class
    73  * inherits form a non-DLL-exported one (e.g. settings::ENoMemory ->
    74  * std::bad_alloc). I can't get how it can harm yet.
    75  */
    76 #if defined(_MSC_VER)
    77 #pragma warning (disable:4251)
    78 #pragma warning (disable:4275)
    79 #endif
    80 
    8161/* Forwards */
    8262typedef struct _xmlParserInput xmlParserInput;
     
    9070{
    9171
    92 // Little string class for XML only
     72// Exceptions
    9373//////////////////////////////////////////////////////////////////////////////
    9474
    95 class ministring
    96 {
    97 public:
    98     ministring()
    99         : m_psz(NULL)
     75/**
     76 * Base exception class.
     77 */
     78class VBOXXML_CLASS Error : public std::exception
     79{
     80public:
     81
     82    Error(const char *pcszMessage)
     83        : m_s(pcszMessage)
    10084    {
    10185    }
    10286
    103     ministring(const ministring &s)
    104         : m_psz(NULL)
     87    Error(const Error &s)
     88        : std::exception(s),
     89          m_s(s.what())
    10590    {
    106         copyFrom(s.c_str());
    107     }
    108 
    109     ministring(const char *pcsz)
    110         : m_psz(NULL)
    111     {
    112         copyFrom(pcsz);
    113     }
    114 
    115     ~ministring()
    116     {
    117         cleanup();
    118     }
    119 
    120     void operator=(const char *pcsz)
    121     {
    122         cleanup();
    123         copyFrom(pcsz);
    124     }
    125 
    126     void operator=(const ministring &s)
    127     {
    128         cleanup();
    129         copyFrom(s.c_str());
    130     }
    131 
    132     const char* c_str() const
    133     {
    134         return m_psz;
    135     }
    136 
    137 private:
    138     void cleanup()
    139     {
    140         if (m_psz)
    141         {
    142             RTStrFree(m_psz);
    143             m_psz = NULL;
    144         }
    145     }
    146 
    147     void copyFrom(const char *pcsz)
    148     {
    149         if (pcsz)
    150             m_psz = RTStrDup(pcsz);
    151     }
    152 
    153 
    154     char *m_psz;
    155 };
    156 
    157 // Exceptions
    158 //////////////////////////////////////////////////////////////////////////////
    159 
    160 /**
    161  * Base exception class.
    162  */
    163 class VBOXXML_CLASS Error : public std::exception
    164 {
    165 public:
    166 
    167     Error(const char *pcszMessage)
    168         : m_pcsz(NULL)
    169     {
    170         copyFrom(pcszMessage);
    171     }
    172 
    173     Error(const Error &s)
    174         : std::exception(s)
    175     {
    176         copyFrom(s.what());
    17791    }
    17892
    17993    virtual ~Error() throw()
    18094    {
    181         cleanup();
    18295    }
    18396
    18497    void operator=(const Error &s)
    18598    {
    186         cleanup();
    187         copyFrom(s.what());
     99        m_s = s.what();
    188100    }
    189101
    190102    void setWhat(const char *pcszMessage)
    191103    {
    192         cleanup();
    193         copyFrom(pcszMessage);
     104        m_s = pcszMessage;
    194105    }
    195106
    196107    virtual const char* what() const throw()
    197108    {
    198         return m_pcsz;
     109        return m_s.c_str();
    199110    }
    200111
     
    202113    Error() {};     // hide the default constructor to make sure the extended one above is always used
    203114
    204     void cleanup()
    205     {
    206         if (m_pcsz)
    207         {
    208             RTStrFree(m_pcsz);
    209             m_pcsz = NULL;
    210         }
    211     }
    212 
    213     void copyFrom(const char *pcszMessage)
    214     {
    215         if (pcszMessage)
    216             m_pcsz = RTStrDup(pcszMessage);
    217     }
    218 
    219     char *m_pcsz;
     115    ministring m_s;
    220116};
    221117
     
    468364    /* Obscure class data */
    469365    struct Data;
    470     std::auto_ptr <Data> m;
     366    Data *m;
    471367
    472368    /* auto_ptr data doesn't have proper copy semantics */
     
    495391    /* Obscure class data */
    496392    struct Data;
    497     std::auto_ptr <Data> m;
     393    Data *m;
    498394
    499395    /* auto_ptr data doesn't have proper copy semantics */
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r21077 r21079  
    2626#include <iprt/file.h>
    2727#include <iprt/s3.h>
     28#include "iprt/xml_cpp.h"
    2829
    2930#include <VBox/param.h>
     
    3940
    4041#include "Logging.h"
    41 
    42 #include "VBox/xml.h"
    4342
    4443using namespace std;
     
    234233//
    235234////////////////////////////////////////////////////////////////////////////////
    236 
    237 static Utf8Str stripFilename(const Utf8Str &strFile)
    238 {
    239     Utf8Str str2(strFile);
    240     RTPathStripFilename(str2.mutableRaw());
    241     return str2;
    242 }
    243235
    244236static const struct
     
    22462238                    /* The disk image has to be on the same place as the OVF file. So
    22472239                     * strip the filename out of the full file path. */
    2248                     Utf8Str strSrcDir = stripFilename(pAppliance->m->strPath);
     2240                    Utf8Str strSrcDir(pAppliance->m->strPath);
     2241                    strSrcDir.stripFilename();
    22492242
    22502243                    /* Iterate over all given disk images */
     
    35223515            const Utf8Str &strTargetFileNameOnly = pDiskEntry->strOvf;
    35233516            // target path needs to be composed from where the output OVF is
    3524             Utf8Str strTargetFilePath = stripFilename(m->strPath);
     3517            Utf8Str strTargetFilePath(m->strPath);
     3518            strTargetFilePath.stripFilename();
    35253519            strTargetFilePath.append("/");
    35263520            strTargetFilePath.append(strTargetFileNameOnly);
     
    37213715                const Utf8Str &strTargetFileNameOnly = (*itH)->strOvf;
    37223716                /* Target path needs to be composed from where the output OVF is */
    3723                 Utf8Str strTargetFilePath = stripFilename(m->strPath);
     3717                Utf8Str strTargetFilePath(m->strPath);
     3718                strTargetFilePath.stripFilename();
    37243719                strTargetFilePath.append("/");
    37253720                strTargetFilePath.append(strTargetFileNameOnly);
     
    47364731
    47374732            Utf8Str strTargetVmdkName(bstrName);
    4738             RTPathStripExt(strTargetVmdkName.mutableRaw());
     4733            strTargetVmdkName.stripExt();
    47394734            strTargetVmdkName.append(".vmdk");
    47404735
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r21077 r21079  
    10731073    for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i)
    10741074    {
    1075         Utf8Buf.alloc(cchBuf + 1024);
     1075        Utf8Buf.reserve(cchBuf + 1024);
    10761076        if (Utf8Buf.isNull())
    10771077            return E_OUTOFMEMORY;
     
    10811081        vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3,
    10821082                                     &parm[0]);
     1083        Utf8Buf.jolt();
    10831084        if (parm[2].type != VBOX_HGCM_SVC_PARM_32BIT)
    10841085            return setError (E_FAIL, tr ("Internal application error"));
     
    17171718        {
    17181719            Utf8Str dir = stateFilePath;
    1719             RTPathStripFilename (dir.mutableRaw());
    1720             if (!RTDirExists (dir))
     1720            dir.stripFilename();
     1721            if (!RTDirExists(dir))
    17211722            {
    17221723                int vrc = RTDirCreateFullPath (dir, 0777);
     
    38653866
    38663867    parm[0].type = VBOX_HGCM_SVC_PARM_PTR;
    3867     /* To save doing a const cast, we use the mutableRaw() member. */
    3868     parm[0].u.pointer.addr = Utf8Name.mutableRaw();
     3868    parm[0].u.pointer.addr = (void*)Utf8Name.c_str();
    38693869    /* The + 1 is the null terminator */
    38703870    parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1;
     
    38823882        if (vrc != VERR_NOT_FOUND)
    38833883        {
    3884             size_t iFlags = strlen(pszBuffer) + 1;
    3885             Utf8Str(pszBuffer).cloneTo (aValue);
     3884            Utf8Str strBuffer(pszBuffer);
     3885            strBuffer.cloneTo(aValue);
     3886
    38863887            *aTimestamp = parm[2].u.uint64;
    3887             Utf8Str(pszBuffer + iFlags).cloneTo (aFlags);
     3888
     3889            size_t iFlags = strBuffer.length() + 1;
     3890            Utf8Str(pszBuffer + iFlags).cloneTo(aFlags);
    38883891        }
    38893892        else
     
    39303933
    39313934    parm[0].type = VBOX_HGCM_SVC_PARM_PTR;
    3932     /* To save doing a const cast, we use the mutableRaw() member. */
    3933     parm[0].u.pointer.addr = Utf8Name.mutableRaw();
     3935    parm[0].u.pointer.addr = (void*)Utf8Name.c_str();
    39343936    /* The + 1 is the null terminator */
    39353937    parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1;
     
    39383940    {
    39393941        parm[1].type = VBOX_HGCM_SVC_PARM_PTR;
    3940         /* To save doing a const cast, we use the mutableRaw() member. */
    3941         parm[1].u.pointer.addr = Utf8Value.mutableRaw();
     3942        parm[1].u.pointer.addr = (void*)Utf8Value.c_str();
    39423943        /* The + 1 is the null terminator */
    39433944        parm[1].u.pointer.size = (uint32_t)Utf8Value.length() + 1;
     
    39473948    {
    39483949        parm[2].type = VBOX_HGCM_SVC_PARM_PTR;
    3949         /* To save doing a const cast, we use the mutableRaw() member. */
    3950         parm[2].u.pointer.addr = Utf8Flags.mutableRaw();
     3950        parm[2].u.pointer.addr = (void*)Utf8Flags.c_str();
    39513951        /* The + 1 is the null terminator */
    39523952        parm[2].u.pointer.size = (uint32_t)Utf8Flags.length() + 1;
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r21077 r21079  
    18141814        {
    18151815            /* Pull over the properties from the server. */
    1816             SafeArray <BSTR> namesOut;
    1817             SafeArray <BSTR> valuesOut;
    1818             SafeArray <ULONG64> timestampsOut;
    1819             SafeArray <BSTR> flagsOut;
     1816            SafeArray<BSTR> namesOut;
     1817            SafeArray<BSTR> valuesOut;
     1818            SafeArray<ULONG64> timestampsOut;
     1819            SafeArray<BSTR> flagsOut;
    18201820            hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut),
    18211821                                                ComSafeArrayAsOutParam(valuesOut),
     
    18291829                rc = VERR_INVALID_PARAMETER;
    18301830
    1831             std::vector <Utf8Str> utf8Names, utf8Values, utf8Flags;
    1832             std::vector <char *> names, values, flags;
    1833             std::vector <ULONG64> timestamps;
     1831            std::vector<Utf8Str> utf8Names, utf8Values, utf8Flags;
     1832            std::vector<char *> names, values, flags;
     1833            std::vector<ULONG64> timestamps;
    18341834            for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i)
    18351835                if (   !VALID_PTR(namesOut[i])
  • trunk/src/VBox/Main/MachineImpl.cpp

    r21077 r21079  
    34503450    AssertReturn (!mData->mConfigFileFull.isNull(), VERR_GENERAL_FAILURE);
    34513451
    3452     Utf8Str settingsDir = mData->mConfigFileFull;
    3453 
    3454     RTPathStripFilename (settingsDir.mutableRaw());
    3455     char folder [RTPATH_MAX];
    3456     int vrc = RTPathAbsEx (settingsDir, aPath, folder, sizeof (folder));
    3457     if (RT_SUCCESS (vrc))
     3452    Utf8Str strSettingsDir = mData->mConfigFileFull;
     3453
     3454    strSettingsDir.stripFilename();
     3455    char folder[RTPATH_MAX];
     3456    int vrc = RTPathAbsEx(strSettingsDir, aPath, folder, sizeof(folder));
     3457    if (RT_SUCCESS(vrc))
    34583458        aResult = folder;
    34593459
     
    34833483    Utf8Str settingsDir = mData->mConfigFileFull;
    34843484
    3485     RTPathStripFilename (settingsDir.mutableRaw());
    3486     if (RTPathStartsWith (aPath, settingsDir))
     3485    settingsDir.stripFilename();
     3486    if (RTPathStartsWith(aPath, settingsDir))
    34873487    {
    34883488        /* when assigning, we create a separate Utf8Str instance because both
     
    34913491         * first, and since its the same as aPath, an attempt to copy garbage
    34923492         * will be made. */
    3493         aResult = Utf8Str (aPath + settingsDir.length() + 1);
     3493        aResult = Utf8Str(aPath + settingsDir.length() + 1);
    34943494    }
    34953495}
     
    59495949            /* first, rename the directory if it matches the machine name */
    59505950            configDir = configFile;
    5951             RTPathStripFilename (configDir.mutableRaw());
     5951            configDir.stripFilename();
    59525952            newConfigDir = configDir;
    5953             if (RTPathFilename (configDir) == name)
     5953            if (RTPathFilename(configDir) == name)
    59545954            {
    5955                 RTPathStripFilename (newConfigDir.mutableRaw());
     5955                newConfigDir.stripFilename();
    59565956                newConfigDir = Utf8StrFmt ("%s%c%s",
    59575957                    newConfigDir.raw(), RTPATH_DELIMITER, newName.raw());
     
    60786078
    60796079        /* ensure the settings directory exists */
    6080         Utf8Str path = mData->mConfigFileFull;
    6081         RTPathStripFilename (path.mutableRaw());
    6082         if (!RTDirExists (path))
    6083         {
    6084             vrc = RTDirCreateFullPath (path, 0777);
    6085             if (RT_FAILURE (vrc))
     6080        Utf8Str path(mData->mConfigFileFull);
     6081        path.stripFilename();
     6082        if (!RTDirExists(path))
     6083        {
     6084            vrc = RTDirCreateFullPath(path, 0777);
     6085            if (RT_FAILURE(vrc))
    60866086            {
    60876087                return setError (E_FAIL,
     
    76557655 *  @note Not thread safe (must be called from this object's lock).
    76567656 */
    7657 bool Machine::isInOwnDir (Utf8Str *aSettingsDir /* = NULL */)
     7657bool Machine::isInOwnDir(Utf8Str *aSettingsDir /* = NULL */)
    76587658{
    76597659    Utf8Str settingsDir = mData->mConfigFileFull;
    7660     RTPathStripFilename (settingsDir.mutableRaw());
    7661     char *dirName = RTPathFilename (settingsDir);
     7660    settingsDir.stripFilename();
     7661    char *dirName = RTPathFilename(settingsDir);
    76627662
    76637663    AssertReturn (dirName, false);
  • trunk/src/VBox/Main/Makefile.kmk

    r21077 r21079  
    519519        include
    520520VBoxSettings_SOURCES    = \
    521         xml/xml.cpp \
    522521        xml/Settings.cpp
    523522VBoxSettings_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(notdir $(LIB_SETTINGS)) -Wl,-x # no debug info please.
  • trunk/src/VBox/Main/SharedFolderImpl.cpp

    r21077 r21079  
    2828
    2929#include <iprt/param.h>
     30#include <iprt/cpputils.h>
    3031#include <iprt/path.h>
    31 #include <iprt/cpputils.h>
    3232
    3333// constructor / destructor
     
    199199        ;
    200200#else
    201     if (hostPathLen == 1 && RTPATH_IS_SEP (hostPath[0]))
     201    if (hostPathLen == 1 && RTPATH_IS_SEP(hostPath[0]))
    202202        ;
    203203#endif
    204204    else
    205         RTPathStripTrailingSlash (hostPath.mutableRaw());
     205        hostPath.stripTrailingSlash();
    206206
    207207    /* Check whether the path is full (absolute) */
  • trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp

    r21077 r21079  
    156156    AssertComRC (rc);
    157157    Utf8Str message;
    158     rc = aInfo->GetMessage (message.asOutParam());
     158    rc = aInfo->GetMessage(message.asOutParam());
     159    message.jolt();
    159160    AssertComRC (rc);
    160161    mText = message;
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r21077 r21079  
    38703870HRESULT VirtualBox::ensureFilePathExists (const char *aFileName)
    38713871{
    3872     Utf8Str dir = aFileName;
    3873     RTPathStripFilename (dir.mutableRaw());
    3874     if (!RTDirExists (dir))
    3875     {
    3876         int vrc = RTDirCreateFullPath (dir, 0777);
     3872    Utf8Str strDir(aFileName);
     3873    strDir.stripFilename();
     3874    if (!RTDirExists(strDir))
     3875    {
     3876        int vrc = RTDirCreateFullPath(strDir, 0777);
    38773877        if (RT_FAILURE (vrc))
    38783878        {
    38793879            return setError (E_FAIL,
    38803880                tr ("Could not create the directory '%s' (%Rrc)"),
    3881                 dir.raw(), vrc);
     3881                strDir.c_str(), vrc);
    38823882        }
    38833883    }
  • 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
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r21077 r21079  
    9292    const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
    9393
    94     struct Data;            // obscure, defined in AppliannceImpl.cpp
     94    struct Data;            // opaque, defined in ApplianceImpl.cpp
    9595    Data *m;
    9696
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r21077 r21079  
    603603 * @return
    604604 */
    605 std::string ConvertComString(const com::Guid &bstr)
    606 {
     605std::string ConvertComString(const com::Guid &uuid)
     606{
     607    com::Bstr bstr(uuid);
    607608    com::Utf8Str ustr(bstr);
    608609    const char *pcsz;
  • trunk/src/VBox/Runtime/Makefile.kmk

    r21077 r21079  
    5151 LIBRARIES += RuntimeR3
    5252 DLLS += VBoxRT
    53 
    54  # Temporary(?) hack.
    55  VBOX_WITH_LIBXML2_IN_VBOXRT=
    5653
    5754else # !VBOX_ONLY_ADDITIONS && !VBOX_ONLY_DOCS
     
    165162#
    166163RuntimeR3_TEMPLATE      = VBOXR3STATIC
     164RuntimeR3_SDKS          = VBOX_LIBXML2
    167165RuntimeR3_SDKS.win      = WINPSDK W2K3DDK
    168166RuntimeR3_DEFS          = IN_RT_R3 IN_SUP_R3 LDR_WITH_NATIVE LDR_WITH_ELF32 LDR_WITH_PE RT_WITH_VBOX RT_NO_GIP
     
    306304        r3/test.cpp \
    307305        r3/testi.cpp \
    308         r3/tcp.cpp
     306        r3/tcp.cpp \
     307        r3/xml.cpp
    309308
    310309#if1of ($(KBUILD_TARGET_ARCH),amd64 x86)
     
    787786#
    788787VBoxRT_TEMPLATE                = VBOXR3
    789 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
    790788VBoxRT_SDKS                    = VBOX_OPENSSL VBOX_LIBXML2 VBOX_LIBCURL
    791 endif
    792789VBoxRT_SDKS.win                = WINPSDK W2K3DDK VBOX_NTDLL
    793790ifeq ($(KBUILD_TARGET)$(VBOX_WITH_HARDENING),darwin)
     
    799796        VBox/VBoxRTDeps.cpp \
    800797        $(RuntimeR3_SOURCES)
    801 if defined(VBOX_WITH_LIBXML2_IN_VBOXRT)
    802798VBoxRT_SOURCES                += \
    803799        common/misc/s3.cpp
    804 endif
    805800VBoxRT_SOURCES.$(KBUILD_TARGET) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET))
    806801VBoxRT_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
     
    818813        $(PATH_LIB)/VBox-kStuff$(VBOX_SUFF_LIB)
    819814endif
    820 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
    821  ifndef SDK_VBOX_LIBXML2_LIBS
    822   VBoxRT_LIBS                 += \
     815ifndef  SDK_VBOX_LIBXML2_LIBS
     816 VBoxRT_LIBS                 += \
    823817        $(PATH_LIB)/VBox-libxml2$(VBOX_SUFF_LIB)
    824  endif
    825  ifndef SDK_VBOX_OPENSSL_LIBS
    826   VBoxRT_LIBS                 += \
     818endif
     819ifndef  SDK_VBOX_OPENSSL_LIBS
     820 VBoxRT_LIBS                 += \
    827821        $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB)
    828  endif
    829822endif
    830823VBoxRT_LIBS.darwin             = \
     
    851844        $(PATH_LIB)/RuntimeR3L4$(VBOX_SUFF_LIB)
    852845
    853 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
    854 VBox/VBoxRTDeps.cpp_DEFS = VBOX_WITH_LIBXML2_IN_VBOXRT
    855 endif
    856 
    857846if1of ($(DLLS), VBoxRT)
    858847$$(VBoxRT_0_OUTDIR)/VBoxRT.def: \
    859848                $(PATH_SUB_CURRENT)/r3/win/VBoxRT-$$(if-expr $$(KBUILD_TARGET_ARCH) == amd64,win64,win32).def \
    860                 $(if-expr defined(VBOX_WITH_LIBXML2_IN_VBOXRT),$(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def),)
     849                $(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def)
    861850        $(RM) -f -- $@
    862851        $(REDIRECT) -wto $@ -- $(CAT_EXT) $^
  • trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp

    r21077 r21079  
    3636#include <iprt/assert.h>
    3737#include <iprt/asm.h>
    38 #ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
     38
    3939# include <libxml/xmlmodule.h>
    4040# include <libxml/globals.h>
     
    4444# include <openssl/x509.h>
    4545# include <openssl/rsa.h>
    46 #endif
    4746
    4847
     
    5554    (PFNRT)SUPR3PageAllocEx,
    5655    (PFNRT)SUPSemEventCreate,
    57 #ifdef VBOX_WITH_LIBXML2_IN_VBOXRT
    5856    (PFNRT)xmlModuleOpen,
    5957    (PFNRT)MD5_Init,
     
    6563    (PFNRT)i2d_X509,
    6664    (PFNRT)RSA_generate_key,
    67 #endif
    6865    (PFNRT)RTAssertShouldPanic,
    6966    (PFNRT)ASMAtomicReadU64,
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r21077 r21079  
    1919 */
    2020
    21 #include "Logging.h"
    22 
    2321#include <iprt/cdefs.h>
    2422#include <iprt/err.h>
    2523#include <iprt/file.h>
    2624#include <iprt/lock.h>
    27 #include <iprt/string.h>
     25#include <iprt/xml_cpp.h>
    2826
    2927#include <libxml/tree.h>
     
    3634#include <libxml/xmlschemas.h>
    3735
    38 #include <list>
    3936#include <map>
    4037#include <boost/shared_ptr.hpp>
    41 
    42 #include "VBox/xml.h"
    4338
    4439////////////////////////////////////////////////////////////////////////////////
     
    991986{
    992987    m->copyFrom(x.m);
    993 };
     988}
    994989
    995990Document& Document::operator=(const Document &x)
     
    998993    m->copyFrom(x.m);
    999994    return *this;
    1000 };
     995}
    1001996
    1002997Document::~Document()
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r21077 r21079  
    4242#include <iprt/err.h>
    4343#include <iprt/test.h>
     44#include <iprt/ministring_cpp.h>
    4445
    4546#include <stdlib.h> /** @todo use our random. */
     
    926927
    927928
     929void testMinistring(RTTEST hTest)
     930{
     931    RTTestSub(hTest, "class ministring");
     932
     933#define CHECK(expr) \
     934    do { \
     935        if (!(expr)) \
     936            RTTestFailed(hTest, "%d: FAILED %s", __LINE__, #expr); \
     937    } while (0)
     938
     939#define CHECK_DUMP(expr, value) \
     940    do { \
     941        if (!(expr)) \
     942            RTTestFailed(hTest, "%d: FAILED %s, got \"%s\"", __LINE__, #expr, value); \
     943    } while (0)
     944
     945#define CHECK_DUMP_I(expr) \
     946    do { \
     947        if (!(expr)) \
     948            RTTestFailed(hTest, "%d: FAILED %s, got \"%d\"", __LINE__, #expr, expr); \
     949    } while (0)
     950
     951    ministring empty;
     952    CHECK( (empty.length() == 0) );
     953    CHECK( (empty.capacity() == 0) );
     954
     955    ministring sixbytes("12345");
     956    CHECK( (sixbytes.length() == 5) );
     957    CHECK( (sixbytes.capacity() == 6) );
     958
     959    sixbytes.append("678");
     960    CHECK( (sixbytes.length() == 8) );
     961    CHECK( (sixbytes.capacity() == 9) );
     962
     963    char *psz = sixbytes.mutableRaw();
     964        // 12345678
     965        //       ^
     966        // 0123456
     967    psz[6] = '\0';
     968    sixbytes.jolt();
     969    CHECK( (sixbytes.length() == 6) );
     970    CHECK( (sixbytes.capacity() == 7) );
     971
     972    ministring morebytes("tobereplaced");
     973    morebytes = "newstring ";
     974    morebytes.append(sixbytes);
     975
     976    CHECK_DUMP( (morebytes == "newstring 123456"), morebytes.c_str() );
     977
     978    ministring third(morebytes);
     979    third.reserve(100 * 1024);      // 100 KB
     980    CHECK_DUMP( (third == "newstring 123456"), morebytes.c_str() );
     981    CHECK( (third.capacity() == 100 * 1024) );
     982    CHECK( (third.length() == morebytes.length()) );        // must not have changed
     983
     984    ministring copy1(morebytes);
     985    ministring copy2 = morebytes;
     986    CHECK( (copy1 == copy2) );
     987
     988    copy1 = NULL;
     989    CHECK( (copy1.isNull()) );
     990
     991    copy1 = "";
     992    CHECK( (copy1.isEmpty()) );
     993
     994    CHECK( (ministring("abc") < ministring("def")) );
     995    CHECK( (ministring("abc") != ministring("def")) );
     996    CHECK_DUMP_I( (ministring("def") > ministring("abc")) );
     997
     998    copy2.setNull();
     999    for (int i = 0;
     1000         i < 100;
     1001         ++i)
     1002    {
     1003        copy2.reserve(50);      // should be ignored after 50 loops
     1004        copy2.append("1");
     1005    }
     1006    CHECK( (copy2.length() == 100) );
     1007
     1008#undef CHECK
     1009}
     1010
    9281011int main()
    9291012{
     
    9461029    TstRTStrXCmp(hTest);
    9471030    testStrStr(hTest);
     1031
     1032    testMinistring(hTest);
     1033
    9481034    Benchmarks(hTest);
    9491035
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