VirtualBox

Changeset 26587 in vbox


Ignore:
Timestamp:
Feb 16, 2010 4:57:09 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57775
Message:

Main: Bstr makeover (second attempt) -- make Bstr(NULL) and Bstr() behave the same; resulting cleanup; make some more internal methods use Utf8Str instead of Bstr; fix a lot of CheckComArgNotNull?() usage

Location:
trunk
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/Guid.h

    r26553 r26587  
    9797    {
    9898        ::RTUuidClear (&uuid);
    99         if (!that.isNull())
     99        if (!that.isEmpty())
    100100           ::RTUuidFromUtf16(&uuid, that.raw());
    101101        refresh();
     
    145145    }
    146146
    147     Bstr toUtf16 () const
     147    Bstr toUtf16() const
    148148    {
    149149        if (isEmpty())
  • trunk/include/VBox/com/string.h

    r26553 r26587  
    33/** @file
    44 * MS COM / XPCOM Abstraction Layer:
    5  * Smart string classes declaration
     5 * UTF-8 and UTF-16 string classes
    66 */
    77
     
    5959
    6060/**
    61  *  Helper class that represents the |BSTR| type and hides platform-specific
    62  *  implementation details.
    63  *
    64  *  This class uses COM/XPCOM-provided memory management routines to allocate
    65  *  and free string buffers. This makes it possible to:
    66  *  - use it as a type of member variables of COM/XPCOM components and pass
    67  *    their values to callers through component methods' output parameters
    68  *    using the #cloneTo() operation;
    69  *  - adopt (take ownership of) string buffers returned in output parameters
    70  *    of COM methods using the #asOutParam() operation and correctly free them
    71  *    afterwards.
     61 *  String class used universally in Main for COM-style Utf-16 strings.
     62 *  Unfortunately COM on Windows uses UTF-16 everywhere, requiring conversions
     63 *  back and forth since most of VirtualBox and our libraries use UTF-8.
     64 *  The Bstr class makes such conversions easier.
     65 *
     66 *  Whereas the BSTR identifier is a typedef for a pointer to a wide character
     67 *  array (const char *uint_16 effectively, depending on the platform),
     68 *  the Bstr class is a fully featured string class with memory management
     69 *  for such strings.
     70 *
     71 *  Bstr uses COM/XPCOM-provided memory management routines (SysAlloc* etc.)
     72 *  to allocate and free string buffers. This makes it possible to use it as
     73 *  a type of member variables of COM/XPCOM components and pass their values
     74 *  to callers through component methods' output parameters using the #cloneTo()
     75 *  operation. Also, the class can adopt (take ownership of) string buffers
     76 *  returned in output parameters of COM methods using the #asOutParam()
     77 *  operation and correctly free them afterwards.
     78 *
     79 *  As opposed to the Ut8Str class, which is very efficient, Bstr does not
     80 *  cache the length of its member string. As a result, copying Bstr's is
     81 *  more expensive, and Bstr really should only be used to capture arguments
     82 *  from and return data to public COM methods.
     83 *
     84 *  Starting with VirtualBox 3.2, like Utf8Str, Bstr no longer differentiates
     85 *  between NULL strings and empty strings. In other words, Bstr("") and
     86 *  Bstr(NULL) behave the same. In both cases, Bstr allocates no memory,
     87 *  reports a zero length and zero allocated bytes for both, and returns an
     88 *  empty C wide string from raw().
    7289 */
    7390class Bstr
     
    7592public:
    7693
    77     typedef BSTR String;
    78     typedef CBSTR ConstString;
    79 
    80     Bstr() : bstr(NULL) {}
    81 
    82     Bstr(const Bstr &that) : bstr(NULL) { raw_copy(bstr, that.bstr); }
    83     Bstr(CBSTR that) : bstr(NULL) { raw_copy(bstr, that); }
     94    /**
     95     * Creates an empty string that has no memory allocated.
     96     */
     97    Bstr()
     98        : m_bstr(NULL)
     99    {
     100    }
     101
     102    /**
     103     * Creates a copy of another Bstr.
     104     *
     105     * This allocates s.length() + 1 wide characters for the new instance, unless s is empty.
     106     *
     107     * @param   s               The source string.
     108     *
     109     * @throws  std::bad_alloc
     110     */
     111    Bstr(const Bstr &s)
     112    {
     113        copyFrom(s);
     114    }
     115
     116    /**
     117     * Creates a copy of a wide char string buffer.
     118     *
     119     * This allocates SysStringLen(pw) + 1 wide characters for the new instance, unless s is empty.
     120     *
     121     * @param   pcsz            The source string.
     122     *
     123     * @throws  std::bad_alloc
     124     */
     125    Bstr(CBSTR pw)
     126    {
     127        copyFrom(pw);
     128    }
    84129
    85130#if defined (VBOX_WITH_XPCOM)
    86     Bstr(const wchar_t *that) : bstr(NULL)
     131    Bstr(const wchar_t *pw)
    87132    {
    88133        AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR));
    89         raw_copy(bstr, (CBSTR)that);
     134        copyFrom((CBSTR)pw);
    90135    }
    91136#endif
    92137
    93     Bstr(const iprt::MiniString &that);
    94     Bstr(const char *that);
    95 
    96     /** Shortcut that calls #alloc(aSize) right after object creation. */
    97     Bstr(size_t aSize) : bstr(NULL) { alloc(aSize); }
    98 
    99     ~Bstr() { setNull(); }
    100 
    101     Bstr &operator=(const Bstr &that) { safe_assign(that.bstr); return *this; }
    102     Bstr &operator=(CBSTR that) { safe_assign(that); return *this; }
    103 
    104     Bstr &operator=(const Utf8Str &that);
    105     Bstr &operator=(const char *that);
    106 
    107     Bstr &setNull()
    108     {
    109         if (bstr)
    110         {
    111             ::SysFreeString(bstr);
    112             bstr = NULL;
    113         }
    114         return *this;
    115     }
    116 
    117     Bstr &setNullIfEmpty()
    118     {
    119         if (bstr && *bstr == 0)
    120         {
    121             ::SysFreeString(bstr);
    122             bstr = NULL;
    123         }
    124         return *this;
    125     }
    126 
    127     /**
    128      *  Allocates memory for a string capable to store \a aSize - 1 characters;
    129      *  in other words, aSize includes the terminating zero character. If \a aSize
    130      *  is zero, or if a memory allocation error occurs, this object will become null.
    131      */
    132     Bstr &alloc(size_t aSize)
    133     {
    134         setNull();
    135         if (aSize)
    136         {
    137             unsigned int size = (unsigned int) aSize; Assert(size == aSize);
    138             bstr = ::SysAllocStringLen(NULL, size - 1);
    139             if (bstr)
    140                 bstr[0] = 0;
    141         }
    142         return *this;
    143     }
    144 
    145     int compare(CBSTR str) const
    146     {
    147         return ::RTUtf16Cmp((PRTUTF16) bstr, (PRTUTF16) str);
    148     }
    149 
    150     int compare(BSTR str) const
    151     {
    152         return ::RTUtf16Cmp((PRTUTF16) bstr, (PRTUTF16) str);
    153     }
    154 
    155     bool operator==(const Bstr &that) const { return !compare(that.bstr); }
    156     bool operator!=(const Bstr &that) const { return !!compare(that.bstr); }
     138
     139    /**
     140     * Creates a copy of an IPRT MiniString (which includes Utf8Str).
     141     *
     142     * This allocates s.length() + 1 wide characters for the new instance, unless s is empty.
     143     *
     144     * @param   pcsz            The source string.
     145     *
     146     * @throws  std::bad_alloc
     147     */
     148    Bstr(const iprt::MiniString &s)
     149    {
     150        copyFrom(s.c_str());        // @todo the source string length is know, we can probably speed this up
     151    }
     152
     153    /**
     154     * Creates a copy of a C string.
     155     *
     156     * This allocates strlen(pcsz) + 1 bytes for the new instance, unless s is empty.
     157     *
     158     * @param   pcsz            The source string.
     159     *
     160     * @throws  std::bad_alloc
     161     */
     162    Bstr(const char *pcsz)
     163    {
     164        copyFrom(pcsz);
     165    }
     166
     167    /**
     168     * String length in wide characters.
     169     *
     170     * Returns the length of the member string, which is equal to SysStringLen(raw()).
     171     * In other words, this returns neither bytes nor the number of unicode codepoints.
     172     *
     173     * As opposed to Utf8Str::length(), this is _not_ cached and expensive.
     174     */
     175    size_t length() const
     176    {
     177        return ::SysStringLen(m_bstr);
     178    }
     179
     180    /**
     181     * Deallocates all memory.
     182     */
     183    inline void setNull()
     184    {
     185        cleanup();
     186    }
     187
     188    /**
     189     * Returns a const pointer to the member string. If the member string is empty,
     190     * returns a pointer to a static null character.
     191     * @return
     192     */
     193    CBSTR raw() const
     194    {
     195        return (m_bstr) ? m_bstr : (CBSTR)L"";
     196    }
     197
     198    /**
     199     * Empty string or not?
     200     *
     201     * Returns true if the member string has no length.
     202     *
     203     * @returns true if empty, false if not.
     204     */
     205    bool isEmpty() const
     206    {
     207        return (m_bstr == NULL);
     208    }
     209
     210    operator bool() const
     211    {
     212        return !isEmpty();
     213    }
     214
     215    bool operator!() const
     216    {
     217        return isEmpty();
     218    }
     219
     220    /** Case sensitivity selector. */
     221    enum CaseSensitivity
     222    {
     223        CaseSensitive,
     224        CaseInsensitive
     225    };
     226
     227    int compare(CBSTR str, CaseSensitivity cs = CaseSensitive) const
     228    {
     229        if (m_bstr == str)
     230            return 0;
     231        if (m_bstr == NULL)
     232            return -1;
     233        if (str == NULL)
     234            return 1;
     235
     236        if (cs == CaseSensitive)
     237            return ::RTUtf16Cmp((PRTUTF16)m_bstr, (PRTUTF16)str);
     238        else
     239            return ::RTUtf16ICmp((PRTUTF16)m_bstr, (PRTUTF16)str);
     240    }
     241
     242    int compare(const Bstr &bstr, CaseSensitivity cs = CaseSensitive) const
     243    {
     244        return compare(bstr.raw(), cs);
     245    }
     246
     247    /** @name Comparison operators.
     248     * @{  */
     249    bool operator==(const Bstr &that) const { return !compare(that.raw()); }
     250    bool operator!=(const Bstr &that) const { return !!compare(that.raw()); }
     251    bool operator<( const Bstr &that) const { return compare(that.raw()) < 0; }
     252    bool operator>( const Bstr &that) const { return compare(that.raw()) > 0; }
     253
    157254    bool operator==(CBSTR that) const { return !compare(that); }
    158     bool operator==(BSTR that) const { return !compare(that); }
    159 
    160 #if defined (VBOX_WITH_XPCOM)
    161     bool operator!=(const wchar_t *that) const
    162     {
    163         AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR));
    164         return !!compare((CBSTR) that);
    165     }
    166     bool operator==(const wchar_t *that) const
    167     {
    168         AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR));
    169         return !compare((CBSTR) that);
    170     }
    171 #endif
    172 
    173255    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; }
    178 #if defined (VBOX_WITH_XPCOM)
    179     bool operator<(const wchar_t *that) const
    180     {
    181         AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR));
    182         return compare((CBSTR) that) < 0;
    183     }
    184 #endif
    185 
    186     int compareIgnoreCase(CBSTR str) const
    187     {
    188         return ::RTUtf16LocaleICmp(bstr, str);
    189     }
    190 
    191     bool isNull() const { return bstr == NULL; }
    192     operator bool() const { return !isNull(); }
    193 
    194     bool isEmpty() const { return isNull() || *bstr == 0; }
    195 
    196     size_t length() const { return isNull() ? 0 : ::RTUtf16Len((PRTUTF16) bstr); }
     256    bool operator<( CBSTR that) const { return compare(that) < 0; }
     257    bool operator>( CBSTR that) const { return compare(that) > 0; }
     258
     259    // the following two are necessary or stupid MSVC will complain with "ambiguous operator=="
     260    bool operator==( BSTR that) const { return !compare(that); }
     261    bool operator!=( BSTR that) const { return !!compare(that); }
     262
     263    /** @} */
    197264
    198265    /** Intended to to pass instances as |CBSTR| input parameters to methods. */
    199     operator CBSTR() const { return bstr; }
     266    operator CBSTR() const { return raw(); }
    200267
    201268    /**
     
    204271     * input BSTR parameters of interface methods are not const.
    205272     */
    206     operator BSTR() { return bstr; }
    207 
    208     /**
    209      *  The same as operator CBSTR(), but for situations where the compiler
    210      *  cannot typecast implicitly (for example, in printf() argument list).
    211      */
    212     CBSTR raw() const { return bstr; }
    213 
    214     /**
    215      *  Returns a non-const raw pointer that allows to modify the string directly.
    216      *  @warning
    217      *      Be sure not to modify data beyond the allocated memory! The
    218      *      guaranteed size of the allocated memory is at least #length()
    219      *      bytes after creation and after every assignment operation.
    220      */
    221     BSTR mutableRaw() { return bstr; }
     273    operator BSTR() { return (BSTR)raw(); }
    222274
    223275    /**
     
    225277     *  within the interface method. Transfers the ownership of the duplicated
    226278     *  string to the caller.
    227      */
    228     const Bstr &cloneTo(BSTR *pstr) const
     279     *
     280     *  This allocates a single 0 byte in the target if the member string is empty.
     281     */
     282    const Bstr& cloneTo(BSTR *pstr) const
    229283    {
    230284        if (pstr)
    231         {
    232             *pstr = NULL;
    233             raw_copy(*pstr, bstr);
    234         }
     285            *pstr = ::SysAllocString((const OLECHAR*)raw());
     286                    // raw() never returns NULL, so we always allocate something here
    235287        return *this;
    236288    }
     
    243295     *  As opposed to cloneTo(), this method doesn't create a copy of the
    244296     *  string.
    245      */
    246     Bstr &detachTo(BSTR *pstr)
    247     {
    248         *pstr = bstr;
    249         bstr = NULL;
     297     *
     298     *  This allocates a single 0 byte in the target if the member string is empty.
     299     */
     300    Bstr& detachTo(BSTR *pstr)
     301    {
     302        *pstr = (m_bstr) ? m_bstr : ::SysAllocString((const OLECHAR*)"");
     303        m_bstr = NULL;
    250304        return *this;
    251305    }
    252 
    253     /**
    254      *  Intended to assign copies of instances to |char *| out parameters from
    255      *  within the interface method. Transfers the ownership of the duplicated
    256      *  string to the caller.
    257      */
    258     const Bstr &cloneTo(char **pstr) const;
    259306
    260307    /**
     
    262309     *  Takes the ownership of the returned data.
    263310     */
    264     BSTR *asOutParam() { setNull(); return &bstr; }
     311    BSTR* asOutParam()
     312    {
     313        cleanup();
     314        return &m_bstr;
     315    }
    265316
    266317    /**
     
    271322protected:
    272323
    273     void safe_assign(CBSTR str)
    274     {
    275         if (bstr != str)
     324    /**
     325     * Destructor implementation, also used to clean up in operator=() before
     326     * assigning a new string.
     327     */
     328    void cleanup()
     329    {
     330        if (m_bstr)
    276331        {
    277             setNull();
    278             raw_copy(bstr, str);
     332            ::SysFreeString(m_bstr);
     333            m_bstr = NULL;
    279334        }
    280335    }
    281336
    282     inline static void raw_copy(BSTR &ls, CBSTR rs)
    283     {
    284         if (rs)
    285             ls = ::SysAllocString((const OLECHAR *) rs);
    286     }
    287 
    288     inline static void raw_copy(BSTR &ls, const char *rs)
    289     {
    290         if (rs)
     337    /**
     338     *  Protected internal helper which allocates memory for a string capable of
     339     *  storing \a aSize - 1 characters (not bytes, not codepoints); in other words,
     340     *  aSize includes the terminating null character.
     341     *
     342     *  Does NOT call cleanup() before allocating!
     343     *
     344     * @throws  std::bad_alloc  On allocation failure. The object is left describing
     345     *             a NULL string.
     346     */
     347    void alloc(size_t cw)
     348    {
     349        if (cw)
    291350        {
     351            m_bstr = ::SysAllocStringLen(NULL, (unsigned int)cw - 1);
     352#ifdef RT_EXCEPTIONS_ENABLED
     353            if (!m_bstr)
     354                throw std::bad_alloc();
     355#endif
     356        }
     357    }
     358
     359    /**
     360     * Protected internal helper to copy a string, ignoring the previous object state.
     361     *
     362     * copyFrom() unconditionally sets the members to a copy of the given other
     363     * strings and makes no assumptions about previous contents. Can therefore be
     364     * used both in copy constructors, when member variables have no defined value,
     365     * and in assignments after having called cleanup().
     366     *
     367     * This variant copies from another Bstr. Since Bstr does _not_ cache string lengths,
     368     * this is not fast.
     369     *
     370     * @param   s               The source string.
     371     *
     372     * @throws  std::bad_alloc  On allocation failure. The object is left describing
     373     *             a NULL string.
     374     */
     375    void copyFrom(const Bstr &s)
     376    {
     377        copyFrom(s.raw());
     378    }
     379
     380    /**
     381     * Protected internal helper to copy a string, ignoring the previous object state.
     382     *
     383     * See copyFrom() above.
     384     *
     385     * This variant copies from a wide char C string.
     386     *
     387     * @param   pcsz            The source string.
     388     *
     389     * @throws  std::bad_alloc  On allocation failure. The object is left describing
     390     *             a NULL string.
     391     */
     392    void copyFrom(CBSTR pw)
     393    {
     394        size_t cwLength;
     395        if (    (pw)
     396             && ((cwLength = ::SysStringLen((BSTR)pw)))
     397           )
     398        {
     399            size_t cwAllocated = cwLength + 1;
     400            alloc(cwAllocated);
     401            memcpy(m_bstr, pw, cwAllocated * sizeof(OLECHAR));     // include 0 terminator
     402        }
     403        else
     404            m_bstr = NULL;
     405    }
     406
     407    /**
     408     * Protected internal helper to copy a string, ignoring the previous object state.
     409     *
     410     * See copyFrom() above.
     411     *
     412     * This variant converts from a Utf-8 C string.
     413     *
     414     * @param   pcsz            The source string.
     415     *
     416     * @throws  std::bad_alloc  On allocation failure. The object is left describing
     417     *             a NULL string.
     418     */
     419    void copyFrom(const char *pcsz)
     420    {
     421        if (pcsz && *pcsz)
     422        {
     423            // @todo r=dj apparently this was copied twice in the original because our buffers
     424            // use memory from SysAllocMem and IPRT doesn't, but check if this can be made faster
    292425            PRTUTF16 s = NULL;
    293             ::RTStrToUtf16(rs, &s);
    294             raw_copy(ls, (BSTR)s);
     426            ::RTStrToUtf16(pcsz, &s);
     427            copyFrom((BSTR)s);              // @todo r=dj this is not exception safe
    295428            ::RTUtf16Free(s);
    296429        }
    297     }
    298 
    299     BSTR bstr;
    300 
    301     friend class Utf8Str; /* to access our raw_copy() */
     430        else
     431            m_bstr = NULL;
     432    }
     433
     434    BSTR    m_bstr;                     /**< The string buffer. */
    302435};
    303436
    304437/* 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); }
     438// inline bool operator==(CBSTR l, const Bstr &r) { return r.operator==(l); }
     439// inline bool operator!=(CBSTR l, const Bstr &r) { return r.operator!=(l); }
     440// inline bool operator==(BSTR l, const Bstr &r) { return r.operator==(l); }
     441// inline bool operator!=(BSTR l, const Bstr &r) { return r.operator!=(l); }
    309442
    310443////////////////////////////////////////////////////////////////////////////////
    311444
    312445/**
    313  *  Helper class that represents UTF8 (|char *|) strings. Useful in
    314  *  conjunction with Bstr to simplify conversions between UTF16 (|BSTR|)
    315  *  and UTF8.
    316  *
    317  *  This class uses COM/XPCOM-provided memory management routines to allocate
    318  *  and free string buffers. This makes it possible to:
    319  *  - use it as a type of member variables of COM/XPCOM components and pass
    320  *    their values to callers through component methods' output parameters
    321  *    using the #cloneTo() operation;
    322  *  - adopt (take ownership of) string buffers returned in output parameters
    323  *    of COM methods using the #asOutParam() operation and correctly free them
    324  *    afterwards.
     446 *  String class used universally in Main for Utf-8 strings.
     447 *
     448 *  This is based on iprt::MiniString, to which some functionality has been
     449 *  moved. Here we keep things that are specific to Main, such as conversions
     450 *  with UTF-16 strings (Bstr).
     451 *
     452 *  Like iprt::MiniString, Utf8Str does not differentiate between NULL strings
     453 *  and empty strings. In other words, Utf8Str("") and Utf8Str(NULL)
     454 *  behave the same. In both cases, MiniString allocates no memory, reports
     455 *  a zero length and zero allocated bytes for both, and returns an empty
     456 *  C string from c_str().
    325457 */
    326458class Utf8Str : public iprt::MiniString
     
    340472    Utf8Str(const Bstr &that)
    341473    {
    342         copyFrom(that);
     474        copyFrom(that.raw());
    343475    }
    344476
     
    361493
    362494    Utf8Str& operator=(const Bstr &that)
     495    {
     496        cleanup();
     497        copyFrom(that.raw());
     498        return *this;
     499    }
     500
     501    Utf8Str& operator=(CBSTR that)
    363502    {
    364503        cleanup();
     
    367506    }
    368507
    369     Utf8Str& operator=(CBSTR that)
    370     {
    371         cleanup();
    372         copyFrom(that);
    373         return *this;
    374     }
    375 
    376508    /**
    377509     * Intended to assign instances to |char *| out parameters from within the
     
    379511     * caller.
    380512     *
     513     * This allocates a single 0 byte in the target if the member string is empty.
     514     *
    381515     * @remarks The returned string must be freed by RTStrFree, not RTMemFree.
    382516     */
    383517    const Utf8Str& cloneTo(char **pstr) const
    384518    {
    385         if (pstr) /** @todo r=bird: This needs to if m_psz is NULL. Shouldn't it also throw std::bad_alloc? */
    386             *pstr = RTStrDup(m_psz);
    387         return *this;
    388     }
    389 
    390     /**
    391      *  Intended to assign instances to |char *| out parameters from within the
    392      *  interface method. Transfers the ownership of the original string to the
    393      *  caller and resets the instance to null.
    394      *
    395      *  As opposed to cloneTo(), this method doesn't create a copy of the
    396      *  string.
    397      */
    398     Utf8Str& detachTo(char **pstr)
    399     {
    400         *pstr = m_psz;
    401         m_psz = NULL;
    402         m_cbAllocated = 0;
    403         m_cbLength = 0;
     519        if (pstr)
     520        {
     521            *pstr = RTStrDup(raw());
     522#ifdef RT_EXCEPTIONS_ENABLED
     523            if (!*pstr)
     524                throw std::bad_alloc();
     525#endif
     526        }
    404527        return *this;
    405528    }
     
    409532     *  interface method. Transfers the ownership of the duplicated string to the
    410533     *  caller.
     534     *
     535     *  This allocates a single 0 byte in the target if the member string is empty.
    411536     */
    412537    const Utf8Str& cloneTo(BSTR *pstr) const
     
    414539        if (pstr)
    415540        {
     541            Bstr bstr(c_str());
    416542            *pstr = NULL;
    417             Bstr::raw_copy(*pstr, m_psz);
     543            bstr.detachTo(pstr);
    418544        }
    419545        return *this;
     
    507633        if (s)
    508634        {
    509             RTUtf16ToUtf8((PRTUTF16)s, &m_psz); /** @todo r=bird: This isn't throwing std::bad_alloc / handling return codes.
    510                                                  * Also, this technically requires using RTStrFree, ministring::cleanup() uses RTMemFree. */
     635            RTUtf16ToUtf8((PRTUTF16)s, &m_psz); /** @todo r=bird: This technically requires using RTStrFree, ministring::cleanup() uses RTMemFree. */
     636#ifdef RT_EXCEPTIONS_ENABLED
     637            if (!m_psz)
     638                throw std::bad_alloc();
     639#endif
    511640            m_cbLength = strlen(m_psz);         /** @todo optimize by using a different RTUtf* function */
    512641            m_cbAllocated = m_cbLength + 1;
     
    524653
    525654// work around error C2593 of the stupid MSVC 7.x ambiguity resolver
    526 WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Bstr)
    527 
    528 ////////////////////////////////////////////////////////////////////////////////
    529 
    530 // inlined Bstr members that depend on Utf8Str
    531 
    532 inline Bstr::Bstr(const iprt::MiniString &that)
    533     : bstr(NULL)
    534 {
    535     raw_copy(bstr, that.c_str());
    536 }
    537 
    538 inline Bstr::Bstr(const char *that)
    539     : bstr(NULL)
    540 {
    541     raw_copy(bstr, that);
    542 }
    543 
    544 inline Bstr &Bstr::operator=(const Utf8Str &that)
    545 {
    546     setNull();
    547     raw_copy(bstr, that.c_str());
    548     return *this;
    549 }
    550 inline Bstr &Bstr::operator=(const char *that)
    551 {
    552     setNull();
    553     raw_copy(bstr, that);
    554     return *this;
    555 }
    556 
    557 inline const Bstr& Bstr::cloneTo(char **pstr) const
    558 {
    559     if (pstr)
    560     {
    561         Utf8Str ustr(*this);
    562         ustr.detachTo(pstr);
    563     }
    564     return *this;
    565 }
     655// @todo r=dj if I enable this I get about five warnings every time this header
     656// is included, figure out what that is... for now I have modified the calling code instead
     657// WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Bstr)
    566658
    567659////////////////////////////////////////////////////////////////////////////////
     
    654746        va_list args;
    655747        va_start(args, aFormat);
    656         raw_copy(bstr, Utf8StrFmtVA(aFormat, args).c_str());
     748        copyFrom(Utf8StrFmtVA(aFormat, args).c_str());
    657749        va_end(args);
    658750    }
     
    675767    BstrFmtVA(const char *aFormat, va_list aArgs)
    676768    {
    677         raw_copy(bstr, Utf8StrFmtVA(aFormat, aArgs).c_str());
     769        copyFrom(Utf8StrFmtVA(aFormat, aArgs).c_str());
    678770    }
    679771};
  • trunk/include/iprt/cdefs.h

    r26226 r26587  
    19201920#if defined(_MSC_VER)
    19211921# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls) \
    1922     inline bool operator! (const Cls &that) { return !bool (that); } \
    1923     inline bool operator&& (const Cls &that, bool b) { return bool (that) && b; } \
    1924     inline bool operator|| (const Cls &that, bool b) { return bool (that) || b; } \
    1925     inline bool operator&& (bool b, const Cls &that) { return b && bool (that); } \
    1926     inline bool operator|| (bool b, const Cls &that) { return b || bool (that); }
     1922    inline bool operator! (const Cls &that) { return !bool(that); } \
     1923    inline bool operator&& (const Cls &that, bool b) { return bool(that) && b; } \
     1924    inline bool operator|| (const Cls &that, bool b) { return bool(that) || b; } \
     1925    inline bool operator&& (bool b, const Cls &that) { return b && bool(that); } \
     1926    inline bool operator|| (bool b, const Cls &that) { return b || bool(that); }
    19271927#else
    19281928# define WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Cls)
  • trunk/include/iprt/cpp/ministring.h

    r26553 r26587  
    4545 * else except IPRT memory management functions.  Semantics are like in
    4646 * std::string, except it can do a lot less.
     47 *
     48 * Note that MiniString does not differentiate between NULL strings and
     49 * empty strings. In other words, MiniString("") and MiniString(NULL)
     50 * behave the same. In both cases, MiniString allocates no memory, reports
     51 * a zero length and zero allocated bytes for both, and returns an empty
     52 * C string from c_str().
    4753 */
    4854#ifdef VBOX
     
    7177     * Creates a copy of another MiniString.
    7278     *
    73      * This allocates s.length() + 1 bytes for the new instance.
     79     * This allocates s.length() + 1 bytes for the new instance, unless s is empty.
    7480     *
    7581     * @param   s               The source string.
     
    8389
    8490    /**
    85      * Creates a copy of another MiniString.
    86      *
    87      * This allocates strlen(pcsz) + 1 bytes for the new instance.
     91     * Creates a copy of a C string.
     92     *
     93     * This allocates strlen(pcsz) + 1 bytes for the new instance, unless s is empty.
    8894     *
    8995     * @param   pcsz            The source string.
     
    123129     *
    124130     * Returns the number of bytes allocated in the internal string buffer, which is
    125      * at least length() + 1 if length() > 0.
     131     * at least length() + 1 if length() > 0. Returns 0 for an empty string.
    126132     *
    127133     * @returns m_cbAllocated.
     
    275281     * Returns the byte at the given index, or a null byte if the index is not
    276282     * smaller than length().  This does _not_ count codepoints but simply points
    277      * into the member C string.
     283     * into the member C string; the result may not be a valid UTF-8 character.
    278284     *
    279285     * @param   i       The index into the string buffer.
     
    289295    /**
    290296     * Returns the contained string as a C-style const char* pointer.
     297     * This never returns NULL; if the string is empty, returns a
     298     * pointer to static null byte.
    291299     *
    292300     * @returns const pointer to C-style string.
     
    294302    inline const char *c_str() const
    295303    {
    296         return m_psz;
     304        return (m_psz) ? m_psz : "";
    297305    }
    298306
    299307    /**
    300308     * Like c_str(), for compatibility with lots of VirtualBox Main code.
     309     * This never returns NULL; if the string is empty, returns a
     310     * pointer to static null byte.
    301311     *
    302312     * @returns const pointer to C-style string.
     
    304314    inline const char *raw() const
    305315    {
    306         return m_psz;
    307     }
    308 
    309     /**
    310      * Emptry string or not?
     316        return (m_psz) ? m_psz : "";
     317    }
     318
     319    /**
     320     * Empty string or not?
    311321     *
    312322     * Returns true if the member string has no length.  This states nothing about
     
    472482
    473483    /**
    474      * Hide operator bool() to force people to use isEmpty() explicitly.
    475      */
    476     operator bool() const { return false; }
    477 
    478     /**
    479484     * Destructor implementation, also used to clean up in operator=() before
    480485     * assigning a new string.
     
    492497
    493498    /**
    494      * Protected internal helper for copy a string that completely ignors the
    495      * current object state.
     499     * Protected internal helper to copy a string, ignoring the previous object state.
    496500     *
    497501     * copyFrom() unconditionally sets the members to a copy of the given other
     
    501505     *
    502506     * This variant copies from another MiniString and is fast since
    503      * the length of source string is known.
     507     * the length of the source string is known.
    504508     *
    505509     * @param   s               The source string.
     
    533537
    534538    /**
    535      * Protected internal helper for copy a string that completely ignors the
    536      * current object state.
     539     * Protected internal helper to copy a string, ignoring the previous object state.
    537540     *
    538541     * See copyFrom() above.
     
    572575    }
    573576
     577private:
     578
     579    /**
     580     * Hide operator bool() to force people to use isEmpty() explicitly.
     581     */
     582    operator bool() const;
     583
     584protected:
     585
    574586    char    *m_psz;                     /**< The string buffer. */
    575587    size_t  m_cbLength;                 /**< strlen(m_psz) - i.e. no terminator included. */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp

    r26553 r26587  
    230230
    231231        ComPtr<IHostNetworkInterface> hif;
    232         CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName).mutableRaw(), hif.asOutParam()));
     232        CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName), hif.asOutParam()));
    233233        if(FAILED(rc))
    234234            return errorArgument("could not find interface '%s'", pIfName);
     
    244244
    245245    ComPtr<IDHCPServer> svr;
    246     rc = a->virtualBox->FindDHCPServerByNetworkName(NetName.mutableRaw(), svr.asOutParam());
     246    rc = a->virtualBox->FindDHCPServerByNetworkName(NetName, svr.asOutParam());
    247247    if(enmCode == OP_ADD)
    248248    {
     
    250250            return errorArgument("dhcp server already exists");
    251251
    252         CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName.mutableRaw(), svr.asOutParam()));
     252        CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName, svr.asOutParam()));
    253253        if(FAILED(rc))
    254254            return errorArgument("failed to create server");
     
    263263        if (pIp || pNetmask || pLowerIp || pUpperIp)
    264264        {
    265             CHECK_ERROR(svr, SetConfiguration (Bstr(pIp).mutableRaw(), Bstr(pNetmask).mutableRaw(), Bstr(pLowerIp).mutableRaw(), Bstr(pUpperIp).mutableRaw()));
     265            CHECK_ERROR(svr, SetConfiguration(Bstr(pIp), Bstr(pNetmask), Bstr(pLowerIp), Bstr(pUpperIp)));
    266266            if(FAILED(rc))
    267267                return errorArgument("failed to set configuration");
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r26553 r26587  
    255255
    256256    /* check the outcome */
    257     if (   !filename
     257    if (   filename.isEmpty()
    258258        || sizeMB == 0)
    259259        return errorSyntax(USAGE_CREATEHD, "Parameters --filename and --size are required");
     
    281281        bool doClose = false;
    282282
    283         if (!comment.isNull())
     283        if (!comment.isEmpty())
    284284        {
    285285            CHECK_ERROR(hardDisk,COMSETTER(Description)(comment));
     
    10121012
    10131013    /* check for required options */
    1014     if (!server || !target)
     1014    if (server.isEmpty() || target.isEmpty())
    10151015        return errorSyntax(USAGE_ADDISCSIDISK, "Parameters --server and --target are required");
    10161016
     
    10381038        if (FAILED(rc)) break;
    10391039
    1040         if (!port.isNull())
     1040        if (!port.isEmpty())
    10411041            server = BstrFmt ("%ls:%ls", server.raw(), port.raw());
    10421042
     
    10471047        server.detachTo (values.appendedRaw());
    10481048        Bstr ("TargetName").detachTo (names.appendedRaw());
    1049         target.detachTo (values.appendedRaw());
    1050 
    1051         if (!lun.isNull())
     1049        target.detachTo(values.appendedRaw());
     1050
     1051        if (!lun.isEmpty())
    10521052        {
    10531053            Bstr ("LUN").detachTo (names.appendedRaw());
    10541054            lun.detachTo (values.appendedRaw());
    10551055        }
    1056         if (!username.isNull())
     1056        if (!username.isEmpty())
    10571057        {
    10581058            Bstr ("InitiatorUsername").detachTo (names.appendedRaw());
    10591059            username.detachTo (values.appendedRaw());
    10601060        }
    1061         if (!password.isNull())
     1061        if (!password.isEmpty())
    10621062        {
    10631063            Bstr ("InitiatorSecret").detachTo (names.appendedRaw());
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r24024 r26587  
    248248            RTPrintf("No value set!\n");
    249249        if (value)
     250        {
    250251            RTPrintf("Value: %lS\n", value.raw());
    251         if (value && verbose)
    252         {
    253             RTPrintf("Timestamp: %lld\n", u64Timestamp);
    254             RTPrintf("Flags: %lS\n", flags.raw());
     252            if (verbose)
     253            {
     254                RTPrintf("Timestamp: %lld\n", u64Timestamp);
     255                RTPrintf("Flags: %lS\n", flags.raw());
     256            }
    255257        }
    256258    }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp

    r26553 r26587  
    364364                        && !cmd.mMachine)
    365365                    || (   cmd.mGlobal
    366                         && cmd.mFilter.mRemote)
     366                        && !cmd.mFilter.mRemote.isEmpty())
    367367                   )
    368368                {
     
    441441                if (!f.mActive.isNull())
    442442                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    443                 if (!f.mVendorId.isNull())
    444                     CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
    445                 if (!f.mProductId.isNull())
    446                     CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
    447                 if (!f.mRevision.isNull())
    448                     CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
    449                 if (!f.mManufacturer.isNull())
    450                     CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
    451                 if (!f.mSerialNumber.isNull())
    452                     CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
     443                if (!f.mVendorId.isEmpty())
     444                    CHECK_ERROR_BREAK (flt, COMSETTER(VendorId)(f.mVendorId));
     445                if (!f.mProductId.isEmpty())
     446                    CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId));
     447                if (!f.mRevision.isEmpty())
     448                    CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision));
     449                if (!f.mManufacturer.isEmpty())
     450                    CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer));
     451                if (!f.mSerialNumber.isEmpty())
     452                    CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber));
    453453                if (!f.mMaskedInterfaces.isNull())
    454454                    CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces));
     
    466466                if (!f.mActive.isNull())
    467467                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    468                 if (!f.mVendorId.isNull())
    469                     CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
    470                 if (!f.mProductId.isNull())
    471                     CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
    472                 if (!f.mRevision.isNull())
    473                     CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
    474                 if (!f.mManufacturer.isNull())
    475                     CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
    476                 if (!f.mRemote.isNull())
    477                     CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty()));
    478                 if (!f.mSerialNumber.isNull())
    479                     CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
     468                if (!f.mVendorId.isEmpty())
     469                    CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId));
     470                if (!f.mProductId.isEmpty())
     471                    CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId));
     472                if (!f.mRevision.isEmpty())
     473                    CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision));
     474                if (!f.mManufacturer.isEmpty())
     475                    CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer));
     476                if (!f.mRemote.isEmpty())
     477                    CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote));
     478                if (!f.mSerialNumber.isEmpty())
     479                    CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber));
    480480                if (!f.mMaskedInterfaces.isNull())
    481481                    CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces));
     
    494494                ComPtr <IHostUSBDeviceFilter> flt = coll[cmd.mIndex];
    495495
    496                 if (!f.mName.isNull())
    497                     CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
     496                if (!f.mName.isEmpty())
     497                    CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName));
    498498                if (!f.mActive.isNull())
    499499                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    500                 if (!f.mVendorId.isNull())
    501                     CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
    502                 if (!f.mProductId.isNull())
    503                     CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
    504                 if (!f.mRevision.isNull())
    505                     CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
    506                 if (!f.mManufacturer.isNull())
    507                     CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
    508                 if (!f.mSerialNumber.isNull())
    509                     CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
     500                if (!f.mVendorId.isEmpty())
     501                    CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId));
     502                if (!f.mProductId.isEmpty())
     503                    CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId));
     504                if (!f.mRevision.isEmpty())
     505                    CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision));
     506                if (!f.mManufacturer.isEmpty())
     507                    CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer));
     508                if (!f.mSerialNumber.isEmpty())
     509                    CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber));
    510510                if (!f.mMaskedInterfaces.isNull())
    511511                    CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces));
     
    521521                ComPtr <IUSBDeviceFilter> flt = coll[cmd.mIndex];
    522522
    523                 if (!f.mName.isNull())
    524                     CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
     523                if (!f.mName.isEmpty())
     524                    CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName));
    525525                if (!f.mActive.isNull())
    526526                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    527                 if (!f.mVendorId.isNull())
    528                     CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
    529                 if (!f.mProductId.isNull())
    530                     CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
    531                 if (!f.mRevision.isNull())
    532                     CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
    533                 if (!f.mManufacturer.isNull())
    534                     CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
    535                 if (!f.mRemote.isNull())
    536                     CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty()));
    537                 if (!f.mSerialNumber.isNull())
    538                     CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
     527                if (!f.mVendorId.isEmpty())
     528                    CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId));
     529                if (!f.mProductId.isEmpty())
     530                    CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId));
     531                if (!f.mRevision.isEmpty())
     532                    CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision));
     533                if (!f.mManufacturer.isEmpty())
     534                    CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer));
     535                if (!f.mRemote.isEmpty())
     536                    CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote));
     537                if (!f.mSerialNumber.isEmpty())
     538                    CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber));
    539539                if (!f.mMaskedInterfaces.isNull())
    540540                    CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces));
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r26445 r26587  
    311311            {
    312312                Bstr keyString = key;
    313                 if (keyString && keyString == VBOXSDL_SECURELABEL_EXTRADATA)
     313                if (keyString == VBOXSDL_SECURELABEL_EXTRADATA)
    314314                {
    315315                    /*
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r26581 r26587  
    228228            return E_INVALIDARG;
    229229
    230         if (com::asGuidStr(id).isNull())
     230        if (com::asGuidStr(id).isEmpty())
    231231        {
    232232            /* it's a global extra data key someone wants to change */
     
    310310                                  IN_BSTR key, IN_BSTR value)
    311311    {
    312         if (com::asGuidStr(id).isNull())
     312        if (com::asGuidStr(id).isEmpty())
    313313        {
    314314            QString sKey = QString::fromUtf16 (key);
  • trunk/src/VBox/HostServices/GuestProperties/service.cpp

    r26553 r26587  
    11581158 */
    11591159/* static */
    1160 DECLCALLBACK(int) Service::reqNotify(PFNHGCMSVCEXT pfnCallback, void *pvData,
    1161                                      char *pszName, char *pszValue, uint32_t u32TimeHigh,
    1162                                      uint32_t u32TimeLow, char *pszFlags)
     1160DECLCALLBACK(int) Service::reqNotify(PFNHGCMSVCEXT pfnCallback,
     1161                                     void *pvData,
     1162                                     char *pszName,
     1163                                     char *pszValue,
     1164                                     uint32_t u32TimeHigh,
     1165                                     uint32_t u32TimeLow,
     1166                                     char *pszFlags)
    11631167{
    11641168    LogFlowFunc (("pfnCallback=%p, pvData=%p, pszName=%p, pszValue=%p, u32TimeHigh=%u, u32TimeLow=%u, pszFlags=%p\n", pfnCallback, pvData, pszName, pszValue, u32TimeHigh, u32TimeLow, pszFlags));
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r26553 r26587  
    501501}
    502502
    503 HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
     503HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
    504504{
    505505    HRESULT rc;
     
    532532
    533533    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    534                          bstrDescription,
     534                         strDescription,
    535535                         TRUE /* aCancelable */,
    536536                         cOperations, // ULONG cOperations,
    537537                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    538                          bstrDescription, // CBSTR bstrFirstOperationDescription,
     538                         strDescription, // CBSTR bstrFirstOperationDescription,
    539539                         m->ulWeightPerOperation); // ULONG ulFirstOperationWeight,
    540540    return rc;
    541541}
    542542
    543 HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
     543HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
    544544{
    545545    HRESULT rc;
     
    572572
    573573    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    574                          bstrDescription,
     574                         strDescription,
    575575                         TRUE /* aCancelable */,
    576576                         cOperations, // ULONG cOperations,
    577577                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    578                          Bstr(tr("Init")), // CBSTR bstrFirstOperationDescription,
     578                         tr("Init"), // CBSTR bstrFirstOperationDescription,
    579579                         ulInitWeight); // ULONG ulFirstOperationWeight,
    580580    return rc;
    581581}
    582582
    583 HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
     583HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
    584584{
    585585    HRESULT rc;
     
    614614
    615615    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    616                          bstrDescription,
     616                         strDescription,
    617617                         TRUE /* aCancelable */,
    618618                         cOperations, // ULONG cOperations,
    619619                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    620                          bstrDescription, // CBSTR bstrFirstOperationDescription,
     620                         strDescription, // CBSTR bstrFirstOperationDescription,
    621621                         ulOVFCreationWeight); // ULONG ulFirstOperationWeight,
    622622    return rc;
     
    837837    task->locInfo = aLocInfo;
    838838
    839     Bstr progressDesc = BstrFmt(tr("Import appliance '%s'"),
    840                                 aLocInfo.strPath.c_str());
     839    Utf8Str progressDesc = Utf8StrFmt(tr("Import appliance '%s'"),
     840                                      aLocInfo.strPath.c_str());
    841841
    842842    HRESULT rc = S_OK;
     
    15691569                                                    mhda.lDevice,
    15701570                                                    DeviceType_Floppy,
    1571                                                     Bstr(""));
     1571                                                    NULL);
    15721572                        if (FAILED(rc)) throw rc;
    15731573
     
    16181618                                                    mhda.lDevice,
    16191619                                                    DeviceType_DVD,
    1620                                                     Bstr(""));
     1620                                                    NULL);
    16211621                        if (FAILED(rc)) throw rc;
    16221622
     
    17441744                            rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath),
    17451745                                                           AccessMode_ReadOnly,
    1746                                                            false, Bstr(""), false, Bstr(""),
     1746                                                           false, NULL, false, NULL,
    17471747                                                           srcHdVBox.asOutParam());
    17481748                            if (FAILED(rc)) throw rc;
     
    42814281                                                      IN_BSTR aExtraConfigValue)
    42824282{
    4283     CheckComArgNotNull(aVboxValue);
    4284     CheckComArgNotNull(aExtraConfigValue);
    4285 
    42864283    AutoCaller autoCaller(this);
    42874284    if (FAILED(autoCaller.rc())) return autoCaller.rc();
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r26553 r26587  
    584584    if (RT_SUCCESS(rc))
    585585    {
    586         mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
     586        mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
    587587        RTStrFree(pszPropertyName);
    588588    }
     
    591591    if (RT_SUCCESS(rc))
    592592    {
    593         mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
     593        mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
    594594        RTStrFree(pszPropertyName);
    595595    }
     
    598598    if (RT_SUCCESS(rc))
    599599    {
    600         mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
     600        mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
    601601        RTStrFree(pszPropertyName);
    602602    }
     
    11901190
    11911191// static
    1192 DECLCALLBACK(int)
    1193 Console::doGuestPropNotification(void *pvExtension, uint32_t u32Function,
    1194                                  void *pvParms, uint32_t cbParms)
     1192DECLCALLBACK(int) Console::doGuestPropNotification(void *pvExtension,
     1193                                                  uint32_t u32Function,
     1194                                                   void *pvParms, uint32_t cbParms)
    11951195{
    11961196    using namespace guestProp;
     
    12121212    Bstr value(pCBData->pcszValue);
    12131213    Bstr flags(pCBData->pcszFlags);
    1214     if (   !name.isNull()
    1215         && (!value.isNull() || pCBData->pcszValue == NULL)
    1216         && (!flags.isNull() || pCBData->pcszFlags == NULL)
    1217        )
    1218     {
    1219         ComObjPtr<Console> ptrConsole = reinterpret_cast<Console *>(pvExtension);
    1220         HRESULT hrc = ptrConsole->mControl->PushGuestProperty(name,
    1221                                                               value,
    1222                                                               pCBData->u64Timestamp,
    1223                                                               flags);
    1224         if (SUCCEEDED(hrc))
    1225             rc = VINF_SUCCESS;
    1226         else
    1227         {
    1228             LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
    1229                      pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
    1230             rc = Global::vboxStatusCodeFromCOM(hrc);
    1231         }
    1232     }
     1214    ComObjPtr<Console> ptrConsole = reinterpret_cast<Console *>(pvExtension);
     1215    HRESULT hrc = ptrConsole->mControl->PushGuestProperty(name,
     1216                                                          value,
     1217                                                          pCBData->u64Timestamp,
     1218                                                          flags);
     1219    if (SUCCEEDED(hrc))
     1220        rc = VINF_SUCCESS;
    12331221    else
    1234         rc = VERR_NO_MEMORY;
     1222    {
     1223        LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
     1224                    pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
     1225        rc = Global::vboxStatusCodeFromCOM(hrc);
     1226    }
    12351227    return rc;
    12361228}
     
    25942586{
    25952587#ifdef VBOX_WITH_USB
    2596     CheckComArgNotNull(aAddress);
     2588    CheckComArgStrNotEmptyOrNull(aAddress);
    25972589    CheckComArgOutPointerValid(aDevice);
    25982590
     
    26612653}
    26622654
    2663 STDMETHODIMP
    2664 Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
    2665 {
    2666     CheckComArgNotNull(aName);
    2667     CheckComArgNotNull(aHostPath);
     2655STDMETHODIMP Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
     2656{
     2657    CheckComArgStrNotEmptyOrNull(aName);
     2658    CheckComArgStrNotEmptyOrNull(aHostPath);
    26682659
    26692660    AutoCaller autoCaller(this);
     
    27322723STDMETHODIMP Console::RemoveSharedFolder(IN_BSTR aName)
    27332724{
    2734     CheckComArgNotNull(aName);
     2725    CheckComArgStrNotEmptyOrNull(aName);
    27352726
    27362727    AutoCaller autoCaller(this);
     
    27982789    LogFlowThisFunc(("aName='%ls' mMachineState=%08X\n", aName, mMachineState));
    27992790
    2800     CheckComArgNotNull(aName);
     2791    CheckComArgStrNotEmptyOrNull(aName);
    28012792    CheckComArgOutPointerValid(aProgress);
    28022793
     
    50345025                Bstr hostif;
    50355026                adapter->COMGETTER(HostInterface)(hostif.asOutParam());
    5036                 if (!hostif)
     5027                if (hostif.isEmpty())
    50375028                {
    50385029                    return setError(VBOX_E_HOST_ERROR,
     
    50905081        rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
    50915082        if (FAILED(rc)) return rc;
    5092         ComAssertRet(!!savedStateFile, E_FAIL);
     5083        ComAssertRet(!savedStateFile.isEmpty(), E_FAIL);
    50935084        int vrc = SSMR3ValidateFile(Utf8Str(savedStateFile).c_str(), false /* fChecksumIt */);
    50945085        if (RT_FAILURE(vrc))
     
    58185809{
    58195810    ComAssertRet(aName && *aName, E_FAIL);
    5820     ComAssertRet(aData.mHostPath, E_FAIL);
     5811    ComAssertRet(!aData.mHostPath.isEmpty(), E_FAIL);
    58215812
    58225813    /* sanity checks */
     
    77257716         * (i.e. creating a snapshot online)
    77267717         */
    7727         ComAssertThrow(    (!pTask->bstrSavedStateFile.isNull() && pTask->fTakingSnapshotOnline)
    7728                         || (pTask->bstrSavedStateFile.isNull() && !pTask->fTakingSnapshotOnline),
     7718        ComAssertThrow(    (!pTask->bstrSavedStateFile.isEmpty() && pTask->fTakingSnapshotOnline)
     7719                        || (pTask->bstrSavedStateFile.isEmpty() && !pTask->fTakingSnapshotOnline),
    77297720                       rc = E_FAIL);
    77307721
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r26553 r26587  
    761761    Bstr logoImagePath;
    762762    hrc = biosSettings->COMGETTER(LogoImagePath)(logoImagePath.asOutParam());       H();
    763     rc = CFGMR3InsertString(pCfg,   "LogoFile", logoImagePath ? Utf8Str(logoImagePath).c_str() : ""); RC_CHECK();
     763    rc = CFGMR3InsertString(pCfg,   "LogoFile", Utf8Str(logoImagePath).c_str());    RC_CHECK();
    764764
    765765    /*
     
    14871487        Bstr macAddr;
    14881488        hrc = networkAdapter->COMGETTER(MACAddress)(macAddr.asOutParam());          H();
    1489         Assert(macAddr);
     1489        Assert(!macAddr.isEmpty());
    14901490        Utf8Str macAddrUtf8 = macAddr;
    14911491        char *macStr = (char*)macAddrUtf8.raw();
     
    31553155                }
    31563156
    3157                 if (!networkName.isNull())
     3157                if (!networkName.isEmpty())
    31583158                {
    31593159                    /*
     
    31623162                     */
    31633163                    ComPtr<IDHCPServer> dhcpServer;
    3164                     hrc = virtualBox->FindDHCPServerByNetworkName(networkName.mutableRaw(), dhcpServer.asOutParam());
     3164                    hrc = virtualBox->FindDHCPServerByNetworkName(networkName, dhcpServer.asOutParam());
    31653165                    if (SUCCEEDED(hrc))
    31663166                    {
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r26553 r26587  
    894894 * @param   aProgress       Where to return the progress object.
    895895 */
    896 STDMETHODIMP
    897 Console::Teleport(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress)
     896STDMETHODIMP Console::Teleport(IN_BSTR aHostname,
     897                               ULONG aPort,
     898                               IN_BSTR aPassword,
     899                               ULONG aMaxDowntime,
     900                               IProgress **aProgress)
    898901{
    899902    /*
     
    903906    CheckComArgOutPointerValid(aProgress);
    904907    CheckComArgStrNotEmptyOrNull(aHostname);
    905     CheckComArgNotNull(aHostname);
    906908    CheckComArgExprMsg(aPort, aPort > 0 && aPort <= 65535, ("is %u", aPort));
    907909    CheckComArgExprMsg(aMaxDowntime, aMaxDowntime > 0, ("is %u", aMaxDowntime));
  • trunk/src/VBox/Main/GuestImpl.cpp

    r26553 r26587  
    127127
    128128    // redirect the call to IMachine if no additions are installed
    129     if (mData.mAdditionsVersion.isNull())
    130         return mParent->machine()->COMGETTER(OSTypeId) (aOSTypeId);
     129    if (mData.mAdditionsVersion.isEmpty())
     130        return mParent->machine()->COMGETTER(OSTypeId)(aOSTypeId);
    131131
    132132    mData.mOSTypeId.cloneTo(aOSTypeId);
     
    135135}
    136136
    137 STDMETHODIMP Guest::COMGETTER(AdditionsActive) (BOOL *aAdditionsActive)
     137STDMETHODIMP Guest::COMGETTER(AdditionsActive)(BOOL *aAdditionsActive)
    138138{
    139139    CheckComArgOutPointerValid(aAdditionsActive);
     
    262262                                   IN_BSTR aDomain, BOOL aAllowInteractiveLogon)
    263263{
    264     CheckComArgNotNull(aUserName);
    265     CheckComArgNotNull(aPassword);
    266     CheckComArgNotNull(aDomain);
    267 
    268264    AutoCaller autoCaller(this);
    269265    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    278274
    279275        vmmDev->getVMMDevPort()->pfnSetCredentials(vmmDev->getVMMDevPort(),
    280             Utf8Str(aUserName).raw(), Utf8Str(aPassword).raw(),
    281             Utf8Str(aDomain).raw(), u32Flags);
     276                                                   Utf8Str(aUserName).raw(),
     277                                                   Utf8Str(aPassword).raw(),
     278                                                   Utf8Str(aDomain).raw(),
     279                                                   u32Flags);
    282280        return S_OK;
    283281    }
     
    317315void Guest::setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType)
    318316{
    319     Assert(aVersion.isNull() || !aVersion.isEmpty());
     317    Assert(aVersion.isEmpty() || !aVersion.isEmpty());
    320318
    321319    AutoCaller autoCaller(this);
     
    325323
    326324    mData.mAdditionsVersion = aVersion;
    327     mData.mAdditionsActive = !aVersion.isNull();
    328 
    329     mData.mOSTypeId = Global::OSTypeId (aOsType);
     325    mData.mAdditionsActive = !aVersion.isEmpty();
     326
     327    mData.mOSTypeId = Global::OSTypeId(aOsType);
    330328}
    331329
  • trunk/src/VBox/Main/HostImpl.cpp

    r26553 r26587  
    451451    if(hr == S_OK)
    452452    {
    453         size_t cUnicodeName = wcslen(lpszName) + 1;
    454         size_t uniLen = (cUnicodeName * 2 + sizeof (OLECHAR) - 1) / sizeof (OLECHAR);
    455         Bstr name (uniLen + 1 /* extra zero */);
    456         wcscpy((wchar_t *) name.mutableRaw(), lpszName);
     453        Bstr name(lpszName);
    457454
    458455        hr = pncc->GetInstanceGuid(&IfGuid);
     
    464461            iface.createObject();
    465462            /* remove the curly bracket at the end */
    466             if (SUCCEEDED(iface->init (name, Guid (IfGuid), HostNetworkInterfaceType_Bridged)))
     463            if (SUCCEEDED(iface->init(name, Guid (IfGuid), HostNetworkInterfaceType_Bridged)))
    467464            {
    468465//                iface->setVirtualBox(m->pParent);
     
    12901287STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IMedium **aDrive)
    12911288{
    1292     CheckComArgNotNull(aName);
     1289    CheckComArgStrNotEmptyOrNull(aName);
    12931290    CheckComArgOutPointerValid(aDrive);
    12941291
     
    13171314STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IMedium **aDrive)
    13181315{
    1319     CheckComArgNotNull(aName);
     1316    CheckComArgStrNotEmptyOrNull(aName);
    13201317    CheckComArgOutPointerValid(aDrive);
    13211318
     
    14511448{
    14521449#ifdef VBOX_WITH_USB
    1453     CheckComArgNotNull(aAddress);
     1450    CheckComArgStrNotEmptyOrNull(aAddress);
    14541451    CheckComArgOutPointerValid(aDevice);
    14551452
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r26553 r26587  
    5656 * @param   aGuid GUID of the host network interface
    5757 */
    58 HRESULT HostNetworkInterface::init (Bstr aInterfaceName, Guid aGuid, HostNetworkInterfaceType_T ifType)
     58HRESULT HostNetworkInterface::init(Bstr aInterfaceName, Guid aGuid, HostNetworkInterfaceType_T ifType)
    5959{
    6060    LogFlowThisFunc(("aInterfaceName={%ls}, aGuid={%s}\n",
    61                       aInterfaceName.raw(), aGuid.toString().raw()));
    62 
    63     ComAssertRet(aInterfaceName, E_INVALIDARG);
     61                     aInterfaceName.raw(), aGuid.toString().raw()));
     62
     63    ComAssertRet(!aInterfaceName.isEmpty(), E_INVALIDARG);
    6464    ComAssertRet(!aGuid.isEmpty(), E_INVALIDARG);
    6565
     
    423423            {
    424424                m.realIPAddress = 0;
    425                 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), Bstr(""))))
     425                if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), NULL)))
    426426                    return E_FAIL;
    427                 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), Bstr(""))))
     427                if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), NULL)))
    428428                    return E_FAIL;
    429429                return S_OK;
  • trunk/src/VBox/Main/MachineImpl.cpp

    r26553 r26587  
    697697STDMETHODIMP Machine::COMSETTER(Name)(IN_BSTR aName)
    698698{
    699     CheckComArgNotNull(aName);
    700 
    701     if (!*aName)
     699    if (!aName || !*aName)
    702700        return setError(E_INVALIDARG,
    703701                        tr("Machine name cannot be empty"));
     
    779777STDMETHODIMP Machine::COMSETTER(OSTypeId)(IN_BSTR aOSTypeId)
    780778{
    781     CheckComArgNotNull(aOSTypeId);
     779    CheckComArgStrNotEmptyOrNull(aOSTypeId);
    782780
    783781    AutoCaller autoCaller(this);
     
    19301928    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    19311929
    1932     if (mData->mSession.mType.isNull())
    1933         Bstr("").cloneTo(aSessionType);
    1934     else
    1935         mData->mSession.mType.cloneTo(aSessionType);
     1930    mData->mSession.mType.cloneTo(aSessionType);
    19361931
    19371932    return S_OK;
     
    19901985    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    19911986
    1992     if (mSSData->mStateFilePath.isEmpty())
    1993         Bstr("").cloneTo(aStateFilePath);
    1994     else
    1995         mSSData->mStateFilePath.cloneTo(aStateFilePath);
     1987    mSSData->mStateFilePath.cloneTo(aStateFilePath);
    19961988
    19971989    return S_OK;
     
    21342126}
    21352127
    2136 STDMETHODIMP
    2137 Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
    2138 {
    2139     CheckComArgNotNull(aPatterns);
     2128STDMETHODIMP Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
     2129{
    21402130    AutoCaller autoCaller(this);
    21412131    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    24002390                                   IN_BSTR aId)
    24012391{
     2392    CheckComArgStrNotEmptyOrNull(aControllerName);
     2393
    24022394    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aType=%d aId=\"%ls\"\n",
    24032395                     aControllerName, aControllerPort, aDevice, aType, aId));
    2404 
    2405     CheckComArgNotNull(aControllerName);
    2406     CheckComArgNotNull(aId);
    24072396
    24082397    AutoCaller autoCaller(this);
     
    28262815                                   LONG aDevice)
    28272816{
    2828     CheckComArgNotNull(aControllerName);
     2817    CheckComArgStrNotEmptyOrNull(aControllerName);
    28292818
    28302819    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld\n",
     
    29112900                                        LONG aDevice, BOOL aPassthrough)
    29122901{
    2913     CheckComArgNotNull(aControllerName);
     2902    CheckComArgStrNotEmptyOrNull(aControllerName);
    29142903
    29152904    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld aPassthrough=%d\n",
     
    29652954                     aControllerName, aControllerPort, aDevice, aForce));
    29662955
    2967     CheckComArgNotNull(aControllerName);
    2968     CheckComArgNotNull(aId);
     2956    CheckComArgStrNotEmptyOrNull(aControllerName);
    29692957
    29702958    AutoCaller autoCaller(this);
     
    31063094                     aControllerName, aControllerPort, aDevice));
    31073095
    3108     CheckComArgNotNull(aControllerName);
     3096    CheckComArgStrNotEmptyOrNull(aControllerName);
    31093097    CheckComArgOutPointerValid(aMedium);
    31103098
     
    32053193                                   BSTR *aValue)
    32063194{
    3207     CheckComArgNotNull(aKey);
     3195    CheckComArgStrNotEmptyOrNull(aKey);
    32083196    CheckComArgOutPointerValid(aValue);
    32093197
     
    32123200
    32133201    /* start with nothing found */
    3214     Bstr bstrResult("");
     3202    Bstr bstrResult;
    32153203
    32163204    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    32323220STDMETHODIMP Machine::SetExtraData(IN_BSTR aKey, IN_BSTR aValue)
    32333221{
    3234     CheckComArgNotNull(aKey);
     3222    CheckComArgStrNotEmptyOrNull(aKey);
    32353223
    32363224    AutoCaller autoCaller(this);
     
    32633251        // lock to copy the list of callbacks to invoke
    32643252        Bstr error;
    3265         Bstr bstrValue;
    3266         if (aValue)
    3267             bstrValue = aValue;
    3268         else
    3269             bstrValue = (const char *)"";
     3253        Bstr bstrValue(aValue);
    32703254
    32713255        if (!mParent->onExtraDataCanChange(mData->mUuid, aKey, bstrValue, error))
    32723256        {
    32733257            const char *sep = error.isEmpty() ? "" : ": ";
    3274             CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw();
     3258            CBSTR err = error.raw();
    32753259            LogWarningFunc(("Someone vetoed! Change refused%s%ls\n",
    32763260                            sep, err));
     
    34563440STDMETHODIMP Machine::FindSnapshot(IN_BSTR aName, ISnapshot **aSnapshot)
    34573441{
    3458     CheckComArgNotNull(aName);
     3442    CheckComArgStrNotEmptyOrNull(aName);
    34593443    CheckComArgOutPointerValid(aSnapshot);
    34603444
     
    34823466STDMETHODIMP Machine::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
    34833467{
    3484     CheckComArgNotNull(aName);
    3485     CheckComArgNotNull(aHostPath);
     3468    CheckComArgStrNotEmptyOrNull(aName);
     3469    CheckComArgStrNotEmptyOrNull(aHostPath);
    34863470
    34873471    AutoCaller autoCaller(this);
     
    35173501STDMETHODIMP Machine::RemoveSharedFolder(IN_BSTR aName)
    35183502{
    3519     CheckComArgNotNull(aName);
     3503    CheckComArgStrNotEmptyOrNull(aName);
    35203504
    35213505    AutoCaller autoCaller(this);
     
    36073591    ReturnComNotImplemented();
    36083592#else // VBOX_WITH_GUEST_PROPS
    3609     CheckComArgNotNull(aName);
     3593    CheckComArgStrNotEmptyOrNull(aName);
    36103594    CheckComArgOutPointerValid(aValue);
    36113595    CheckComArgOutPointerValid(aTimestamp);
     
    36863670    using namespace guestProp;
    36873671
    3688     CheckComArgNotNull(aName);
    3689     CheckComArgNotNull(aValue);
     3672    CheckComArgStrNotEmptyOrNull(aName);
    36903673    if ((aFlags != NULL) && !VALID_PTR(aFlags))
    36913674        return E_INVALIDARG;
     
    36963679    {
    36973680        Utf8Str utf8Name(aName);
     3681        Utf8Str utf8Value(aValue);
    36983682        Utf8Str utf8Flags(aFlags);
    36993683
     
    37513735            if (found && SUCCEEDED(rc))
    37523736            {
    3753                 if (*aValue)
     3737                if (utf8Value.length())
    37543738                {
    37553739                    RTTIMESPEC time;
    3756                     property.strValue = aValue;
     3740                    property.strValue = utf8Value;
    37573741                    property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
    37583742                    if (aFlags != NULL)
     
    37613745                }
    37623746            }
    3763             else if (SUCCEEDED(rc) && *aValue)
     3747            else if (SUCCEEDED(rc) && utf8Value.length())
    37643748            {
    37653749                RTTIMESPEC time;
     
    37673751                mHWData.backup();
    37683752                property.strName = aName;
    3769                 property.strValue = aValue;
     3753                property.strValue = utf8Value;
    37703754                property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
    37713755                property.mFlags = fFlags;
     
    37853769        else
    37863770        {
    3787             ComPtr<IInternalSessionControl> directControl =
    3788                 mData->mSession.mDirectControl;
     3771            ComPtr<IInternalSessionControl> directControl = mData->mSession.mDirectControl;
    37893772
    37903773            /* just be on the safe side when calling another process */
     
    37973780            else
    37983781                rc = directControl->AccessGuestProperty(aName,
    3799                                                         *aValue ? aValue : NULL,  /** @todo Fix when adding DeleteGuestProperty(), see defect. */
     3782                                                        aValue,
    38003783                                                        aFlags,
    38013784                                                        true /* isSetter */,
     
    39313914                     aControllerName, aControllerPort, aDevice));
    39323915
    3933     CheckComArgNotNull(aControllerName);
     3916    CheckComArgStrNotEmptyOrNull(aControllerName);
    39343917    CheckComArgOutPointerValid(aAttachment);
    39353918
     
    72847267
    72857268        data.cCPUs       = mHWData->mCPUCount;
    7286         data.fCpuHotPlug = mHWData->mCPUHotPlugEnabled;
     7269        data.fCpuHotPlug = !!mHWData->mCPUHotPlugEnabled;
    72877270
    72887271        data.llCpus.clear();
     
    73117294
    73127295        // HPET
    7313         data.fHpetEnabled = mHWData->mHpetEnabled;
     7296        data.fHpetEnabled = !!mHWData->mHpetEnabled;
    73147297
    73157298        // boot order
     
    89478930#endif /* VBOX_WITH_USB */
    89488931
    8949     if (!mData->mSession.mType.isNull())
     8932    if (!mData->mSession.mType.isEmpty())
    89508933    {
    89518934        /* mType is not null when this machine's process has been started by
     
    96559638    using namespace guestProp;
    96569639
    9657     CheckComArgNotNull(aName);
    9658     if (aValue != NULL && (!VALID_PTR(aValue) || !VALID_PTR(aFlags)))
     9640    CheckComArgStrNotEmptyOrNull(aName);
     9641    if (aValue && *aValue && (!VALID_PTR(aValue) || !VALID_PTR(aFlags)))
    96599642        return E_POINTER;  /* aValue can be NULL to indicate deletion */
    96609643
  • trunk/src/VBox/Main/Matching.cpp

    r26553 r26587  
    198198    return
    199199        mSimple.isEmpty() ||
    200         (mIgnoreCase && mSimple.compareIgnoreCase (aValue) == 0) ||
    201         (!mIgnoreCase && mSimple.compare (aValue) == 0);
     200        (mIgnoreCase && mSimple.compare(aValue, Bstr::CaseInsensitive) == 0) ||
     201        (!mIgnoreCase && mSimple.compare(aValue) == 0);
    202202}
    203203
  • trunk/src/VBox/Main/MediumImpl.cpp

    r26553 r26587  
    13611361    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    13621362
    1363     if (m->strDescription.isEmpty())
    1364         Bstr("").cloneTo(aDescription);
    1365     else
    1366         m->strDescription.cloneTo(aDescription);
     1363    m->strDescription.cloneTo(aDescription);
    13671364
    13681365    return S_OK;
     
    13711368STDMETHODIMP Medium::COMSETTER(Description)(IN_BSTR aDescription)
    13721369{
    1373     CheckComArgNotNull(aDescription);
    1374 
    13751370    AutoCaller autoCaller(this);
    13761371    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    14151410STDMETHODIMP Medium::COMSETTER(Location)(IN_BSTR aLocation)
    14161411{
    1417     CheckComArgNotNull(aLocation);
     1412    CheckComArgStrNotEmptyOrNull(aLocation);
    14181413
    14191414    AutoCaller autoCaller(this);
     
    17251720    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    17261721
    1727     if (m->strLastAccessError.isEmpty())
    1728         Bstr("").cloneTo(aLastAccessError);
    1729     else
    1730         m->strLastAccessError.cloneTo(aLastAccessError);
     1722    m->strLastAccessError.cloneTo(aLastAccessError);
    17311723
    17321724    return S_OK;
     
    21022094                        tr("Property '%ls' does not exist"), aName);
    21032095
    2104     if (it->second.isEmpty())
    2105         Bstr("").cloneTo(aValue);
    2106     else
    2107         it->second.cloneTo(aValue);
     2096    it->second.cloneTo(aValue);
    21082097
    21092098    return S_OK;
     
    21692158    {
    21702159        it->first.cloneTo(&names[i]);
    2171         if (it->second.isEmpty())
    2172             Bstr("").cloneTo(&values[i]);
    2173         else
    2174             it->second.cloneTo(&values[i]);
     2160        it->second.cloneTo(&values[i]);
    21752161        ++ i;
    21762162    }
     
    23622348
    23632349STDMETHODIMP Medium::CloneTo(IMedium *aTarget,
    2364                               MediumVariant_T aVariant,
    2365                               IMedium *aParent,
    2366                               IProgress **aProgress)
     2350                             MediumVariant_T aVariant,
     2351                             IMedium *aParent,
     2352                             IProgress **aProgress)
    23672353{
    23682354    CheckComArgNotNull(aTarget);
     
    30903076    {
    30913077        /* only save properties that have non-default values */
    3092         if (!it->second.isNull())
     3078        if (!it->second.isEmpty())
    30933079        {
    30943080            Utf8Str name = it->first;
     
    48584844
    48594845    /* we interpret null values as "no value" in Medium */
    4860     if (it->second.isNull())
     4846    if (it->second.isEmpty())
    48614847        return VERR_CFGM_VALUE_NOT_FOUND;
    48624848
     
    48854871
    48864872    /* we interpret null values as "no value" in Medium */
    4887     if (it->second.isNull())
     4873    if (it->second.isEmpty())
    48884874        return VERR_CFGM_VALUE_NOT_FOUND;
    48894875
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r26553 r26587  
    312312    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    313313
    314     ComAssertRet(!!mData->mMACAddress, E_FAIL);
     314    ComAssertRet(!mData->mMACAddress.isEmpty(), E_FAIL);
    315315
    316316    mData->mMACAddress.cloneTo(aMACAddress);
     
    10261026        case NetworkAttachmentType_NAT:
    10271027            mData->mNATNetwork = data.strName;
    1028             if (mData->mNATNetwork.isNull())
    1029                 mData->mNATNetwork = "";
    10301028            rc = AttachToNAT();
    10311029            if (FAILED(rc)) return rc;
     
    10411039        case NetworkAttachmentType_Internal:
    10421040            mData->mInternalNetwork = data.strName;
    1043             Assert(!mData->mInternalNetwork.isNull());
     1041            Assert(!mData->mInternalNetwork.isEmpty());
    10441042
    10451043            rc = AttachToInternalNetwork();
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r26553 r26587  
    9797 * @return              COM result indicator.
    9898 */
    99 HRESULT ProgressBase::protectedInit (AutoInitSpan &aAutoInitSpan,
     99HRESULT ProgressBase::protectedInit(AutoInitSpan &aAutoInitSpan,
    100100#if !defined (VBOX_COM_INPROC)
    101                             VirtualBox *aParent,
     101                                    VirtualBox *aParent,
    102102#endif
    103                             IUnknown *aInitiator,
    104                             CBSTR aDescription, OUT_GUID aId /* = NULL */)
     103                                    IUnknown *aInitiator,
     104                                    const Utf8Str &strDescription,
     105                                    OUT_GUID aId /* = NULL */)
    105106{
    106107    /* Guarantees subclasses call this method at the proper time */
     
    116117#endif
    117118
    118     AssertReturn(aDescription, E_INVALIDARG);
     119    AssertReturn(!strDescription.isEmpty(), E_INVALIDARG);
    119120
    120121#if !defined (VBOX_COM_INPROC)
     
    143144#endif
    144145
    145     unconst(mDescription) = aDescription;
     146    unconst(m_strDescription) = strDescription;
    146147
    147148    return S_OK;
     
    220221
    221222    /* mDescription is constant during life time, no need to lock */
    222     mDescription.cloneTo(aDescription);
     223    m_strDescription.cloneTo(aDescription);
    223224
    224225    return S_OK;
     
    465466    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    466467
    467     m_bstrOperationDescription.cloneTo(aOperationDescription);
     468    m_strOperationDescription.cloneTo(aOperationDescription);
    468469
    469470    return S_OK;
     
    663664#endif
    664665                        IUnknown *aInitiator,
    665                         CBSTR aDescription,
     666                        const Utf8Str &strDescription,
    666667                        BOOL aCancelable,
    667668                        ULONG cOperations,
    668669                        ULONG ulTotalOperationsWeight,
    669                         CBSTR bstrFirstOperationDescription,
     670                        const Utf8Str &strFirstOperationDescription,
    670671                        ULONG ulFirstOperationWeight,
    671672                        OUT_GUID aId /* = NULL */)
    672673{
    673     LogFlowThisFunc(("aDescription=\"%ls\", cOperations=%d, ulTotalOperationsWeight=%d, bstrFirstOperationDescription=\"%ls\", ulFirstOperationWeight=%d\n",
    674                      aDescription,
     674    LogFlowThisFunc(("aDescription=\"%s\", cOperations=%d, ulTotalOperationsWeight=%d, strFirstOperationDescription=\"%s\", ulFirstOperationWeight=%d\n",
     675                     strDescription.c_str(),
    675676                     cOperations,
    676677                     ulTotalOperationsWeight,
    677                      bstrFirstOperationDescription,
     678                     strFirstOperationDescription.c_str(),
    678679                     ulFirstOperationWeight));
    679680
    680     AssertReturn(bstrFirstOperationDescription, E_INVALIDARG);
     681    AssertReturn(!strFirstOperationDescription.isEmpty(), E_INVALIDARG);
    681682    AssertReturn(ulTotalOperationsWeight >= 1, E_INVALIDARG);
    682683
     
    687688    HRESULT rc = S_OK;
    688689
    689     rc = ProgressBase::protectedInit (autoInitSpan,
     690    rc = ProgressBase::protectedInit(autoInitSpan,
    690691#if !defined (VBOX_COM_INPROC)
    691                                       aParent,
     692                                     aParent,
    692693#endif
    693                                       aInitiator, aDescription, aId);
     694                                     aInitiator,
     695                                     strDescription,
     696                                     aId);
    694697    if (FAILED(rc)) return rc;
    695698
     
    700703    m_ulOperationsCompletedWeight = 0;
    701704    m_ulCurrentOperation = 0;
    702     m_bstrOperationDescription = bstrFirstOperationDescription;
     705    m_strOperationDescription = strFirstOperationDescription;
    703706    m_ulCurrentOperationWeight = ulFirstOperationWeight;
    704707    m_ulOperationPercent = 0;
     
    733736HRESULT Progress::init(BOOL aCancelable,
    734737                       ULONG aOperationCount,
    735                        CBSTR aOperationDescription)
    736 {
    737     LogFlowThisFunc(("aOperationDescription=\"%ls\"\n", aOperationDescription));
     738                       const Utf8Str &strOperationDescription)
     739{
     740    LogFlowThisFunc(("aOperationDescription=\"%s\"\n", strOperationDescription.c_str()));
    738741
    739742    /* Enclose the state transition NotReady->InInit->Ready */
     
    743746    HRESULT rc = S_OK;
    744747
    745     rc = ProgressBase::protectedInit (autoInitSpan);
     748    rc = ProgressBase::protectedInit(autoInitSpan);
    746749    if (FAILED(rc)) return rc;
    747750
     
    754757    m_ulOperationsCompletedWeight = 0;
    755758    m_ulCurrentOperation = 0;
    756     m_bstrOperationDescription = aOperationDescription;
     759    m_strOperationDescription = strOperationDescription;
    757760    m_ulCurrentOperationWeight = 1;
    758761    m_ulOperationPercent = 0;
    759762
    760     int vrc = RTSemEventMultiCreate (&mCompletedSem);
    761     ComAssertRCRet (vrc, E_FAIL);
    762 
    763     RTSemEventMultiReset (mCompletedSem);
     763    int vrc = RTSemEventMultiCreate(&mCompletedSem);
     764    ComAssertRCRet(vrc, E_FAIL);
     765
     766    RTSemEventMultiReset(mCompletedSem);
    764767
    765768    /* Confirm a successful initialization when it's the case */
     
    787790    if (mWaitersCount > 0)
    788791    {
    789         LogFlow (("WARNING: There are still %d threads waiting for '%ls' completion!\n",
    790                   mWaitersCount, mDescription.raw()));
    791         RTSemEventMultiSignal (mCompletedSem);
     792        LogFlow (("WARNING: There are still %d threads waiting for '%s' completion!\n",
     793                  mWaitersCount, m_strDescription.c_str()));
     794        RTSemEventMultiSignal(mCompletedSem);
    792795    }
    793796
    794     RTSemEventMultiDestroy (mCompletedSem);
    795 
    796     ProgressBase::protectedUninit (autoUninitSpan);
     797    RTSemEventMultiDestroy(mCompletedSem);
     798
     799    ProgressBase::protectedUninit(autoUninitSpan);
    797800}
    798801
     
    10041007    m_ulOperationsCompletedWeight += m_ulCurrentOperationWeight;
    10051008
    1006     m_bstrOperationDescription = bstrNextOperationDescription;
     1009    m_strOperationDescription = bstrNextOperationDescription;
    10071010    m_ulCurrentOperationWeight = ulNextOperationsWeight;
    10081011    m_ulOperationPercent = 0;
    10091012
    1010     Log(("Progress::setNextOperation(%ls): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeight is now %d\n",
    1011          m_bstrOperationDescription.raw(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight));
     1013    Log(("Progress::setNextOperation(%s): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeight is now %d\n",
     1014         m_strOperationDescription.c_str(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight));
    10121015
    10131016    /* wake up all waiting threads */
     
    12861289
    12871290    m_ulCurrentOperation = 0;
    1288     rc = mProgresses[0]->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
     1291    Bstr bstrOperationDescription;
     1292    rc = mProgresses[0]->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam());
     1293    m_strOperationDescription = bstrOperationDescription;
    12891294    if (FAILED(rc)) return rc;
    12901295
     
    17861791        {
    17871792            m_ulCurrentOperation = mCompletedOperations + operation;
    1788             rc = progress->COMGETTER(OperationDescription) (
    1789                 m_bstrOperationDescription.asOutParam());
     1793            Bstr bstrOperationDescription;
     1794            rc = progress->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam());
     1795            m_strOperationDescription = bstrOperationDescription;
    17901796        }
    17911797    }
  • trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp

    r26553 r26587  
    134134/////////////////////////////////////////////////////////////////////////////
    135135
    136 STDMETHODIMP RemoteUSBDevice::COMGETTER(Id) (BSTR *aId)
     136STDMETHODIMP RemoteUSBDevice::COMGETTER(Id)(BSTR *aId)
    137137{
    138138    CheckComArgOutPointerValid(aId);
     
    142142
    143143    /* this is const, no need to lock */
    144     Bstr(mData.id).cloneTo(aId);
     144    Bstr(mData.id.toUtf16()).cloneTo(aId);
    145145
    146146    return S_OK;
  • trunk/src/VBox/Main/SessionImpl.cpp

    r26553 r26587  
    682682}
    683683
    684 STDMETHODIMP Session::AccessGuestProperty(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags,
    685                                           BOOL aIsSetter, BSTR *aRetValue, ULONG64 *aRetTimestamp, BSTR *aRetFlags)
     684STDMETHODIMP Session::AccessGuestProperty(IN_BSTR aName,
     685                                          IN_BSTR aValue,
     686                                          IN_BSTR aFlags,
     687                                          BOOL aIsSetter,
     688                                          BSTR *aRetValue,
     689                                          ULONG64 *aRetTimestamp,
     690                                          BSTR *aRetFlags)
    686691{
    687692#ifdef VBOX_WITH_GUEST_PROPS
     
    694699                        Global::stringifySessionState(mState));
    695700    AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    696     CheckComArgNotNull(aName);
     701    CheckComArgStrNotEmptyOrNull(aName);
    697702    if (!aIsSetter && !VALID_PTR(aRetValue))
    698703        return E_POINTER;
  • trunk/src/VBox/Main/SharedFolderImpl.cpp

    r26553 r26587  
    333333    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    334334
    335     if (m.lastAccessError.isEmpty())
    336         Bstr("").cloneTo(aLastAccessError);
    337     else
    338         m.lastAccessError.cloneTo(aLastAccessError);
     335    m.lastAccessError.cloneTo(aLastAccessError);
    339336
    340337    return S_OK;
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r26553 r26587  
    342342STDMETHODIMP Snapshot::COMSETTER(Name)(IN_BSTR aName)
    343343{
    344     CheckComArgNotNull(aName);
     344    CheckComArgStrNotEmptyOrNull(aName);
    345345
    346346    AutoCaller autoCaller(this);
     
    378378STDMETHODIMP Snapshot::COMSETTER(Description)(IN_BSTR aDescription)
    379379{
    380     CheckComArgNotNull(aDescription);
    381 
    382380    AutoCaller autoCaller(this);
    383381    if (FAILED(autoCaller.rc())) return autoCaller.rc();
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r26553 r26587  
    814814 * @return ComObjPtr<MediumFormat>
    815815 */
    816 ComObjPtr<MediumFormat> SystemProperties::mediumFormat (CBSTR aFormat)
     816ComObjPtr<MediumFormat> SystemProperties::mediumFormat(CBSTR aFormat)
    817817{
    818818    ComObjPtr<MediumFormat> format;
     
    824824
    825825    for (MediumFormatList::const_iterator it = mMediumFormats.begin();
    826          it != mMediumFormats.end(); ++ it)
     826         it != mMediumFormats.end();
     827         ++it)
    827828    {
    828829        /* MediumFormat is all const, no need to lock */
    829830
    830         if ((*it)->id().compareIgnoreCase (aFormat) == 0)
     831        if ((*it)->id().compare(aFormat, Bstr::CaseInsensitive) == 0)
    831832        {
    832833            format = *it;
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r26553 r26587  
    11101110    rc = aUSBDevice->COMGETTER(Manufacturer) (manufacturer.asOutParam());
    11111111    ComAssertComRCRet(rc, false);
    1112     if (!manufacturer.isNull())
     1112    if (!manufacturer.isEmpty())
    11131113        USBFilterSetStringExact (&dev, USBFILTERIDX_MANUFACTURER_STR, Utf8Str(manufacturer).c_str(), true);
    11141114
     
    11161116    rc = aUSBDevice->COMGETTER(Product) (product.asOutParam());
    11171117    ComAssertComRCRet(rc, false);
    1118     if (!product.isNull())
     1118    if (!product.isEmpty())
    11191119        USBFilterSetStringExact (&dev, USBFILTERIDX_PRODUCT_STR, Utf8Str(product).c_str(), true);
    11201120
     
    11221122    rc = aUSBDevice->COMGETTER(SerialNumber) (serialNumber.asOutParam());
    11231123    ComAssertComRCRet(rc, false);
    1124     if (!serialNumber.isNull())
     1124    if (!serialNumber.isEmpty())
    11251125        USBFilterSetStringExact (&dev, USBFILTERIDX_SERIAL_NUMBER_STR, Utf8Str(serialNumber).c_str(), true);
    11261126
  • trunk/src/VBox/Main/USBDeviceImpl.cpp

    r26553 r26587  
    155155
    156156    /* this is const, no need to lock */
    157     Guid(mData.id).toString().cloneTo(aId);
     157    Guid(mData.id).toUtf16().cloneTo(aId);
    158158
    159159    return S_OK;
  • trunk/src/VBox/Main/VirtualBoxBase.cpp

    r26553 r26587  
    810810 */
    811811/* static */
    812 HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal (
    813     HRESULT aResultCode, const GUID &aIID,
    814     const Bstr &aComponent, const Bstr &aText,
    815     bool aWarning, bool aLogIt)
     812HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal(HRESULT aResultCode,
     813                                                             const GUID &aIID,
     814                                                             const Bstr &aComponent,
     815                                                             const Bstr &aText,
     816                                                             bool aWarning,
     817                                                             bool aLogIt)
    816818{
    817819    /* whether multi-error mode is turned on */
     
    825827
    826828    /* these are mandatory, others -- not */
    827     AssertReturn((!aWarning && FAILED(aResultCode)) ||
    828                   (aWarning && aResultCode != S_OK),
     829    AssertReturn(    (!aWarning && FAILED(aResultCode))
     830                  || (aWarning && aResultCode != S_OK),
    829831                  E_FAIL);
    830832    AssertReturn(!aText.isEmpty(), E_FAIL);
     
    914916
    915917            /* set the current error info and preserve the previous one if any */
    916             rc = info->init (aResultCode, aIID, aComponent, aText, curInfo);
     918            rc = info->init(aResultCode, aIID, aComponent.raw(), aText.raw(), curInfo);
    917919            if (FAILED(rc)) break;
    918920
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r26553 r26587  
    302302    LogFlowThisFuncEnter();
    303303
    304     if (sVersion.isNull())
     304    if (sVersion.isEmpty())
    305305        sVersion = VBOX_VERSION_STRING;
    306306    sRevision = RTBldCfgRevision();
    307     if (sPackageType.isNull())
     307    if (sPackageType.isEmpty())
    308308        sPackageType = VBOX_PACKAGE_STRING;
    309309    LogFlowThisFunc(("Version: %ls, Package: %ls\n", sVersion.raw(), sPackageType.raw()));
     
    323323    /* compose the VirtualBox.xml file name */
    324324    unconst(m->strSettingsFilePath) = Utf8StrFmt("%s%c%s",
    325                                                 m->strHomeDir.raw(),
    326                                                 RTPATH_DELIMITER,
    327                                                 VBOX_GLOBAL_SETTINGS_FILE);
     325                                                 m->strHomeDir.raw(),
     326                                                 RTPATH_DELIMITER,
     327                                                 VBOX_GLOBAL_SETTINGS_FILE);
    328328    HRESULT rc = S_OK;
    329329    bool fCreate = false;
     
    979979                               firmwareDesc[i].fileName);
    980980        rc = calculateFullPath(shortName, fullName); AssertRCReturn(rc, rc);
    981         if (RTFileExists(fullName.raw()))
     981        if (RTFileExists(fullName.c_str()))
    982982        {
    983983            *aResult = TRUE;
    984984             if (aFile)
    985                 Utf8Str(fullName).cloneTo(aFile);
     985                fullName.cloneTo(aFile);
    986986            break;
    987987        }
     
    993993                              RTPATH_DELIMITER,
    994994                              firmwareDesc[i].fileName);
    995         if (RTFileExists(fullName.raw()))
     995        if (RTFileExists(fullName.c_str()))
    996996        {
    997997            *aResult = TRUE;
    998998            if (aFile)
    999                 Utf8Str(fullName).cloneTo(aFile);
     999                fullName.cloneTo(aFile);
    10001000            break;
    10011001        }
     
    12251225    LogFlowThisFunc(("aName=\"%ls\", aMachine={%p}\n", aName, aMachine));
    12261226
    1227     CheckComArgNotNull(aName);
     1227    CheckComArgStrNotEmptyOrNull(aName);
    12281228    CheckComArgOutSafeArrayPointerValid(aMachine);
    12291229
     
    13461346                                      IMedium **aHardDisk)
    13471347{
    1348     CheckComArgNotNull(aLocation);
    1349     CheckComArgNotNull(aImageId);
    1350     CheckComArgNotNull(aParentId);
     1348    CheckComArgStrNotEmptyOrNull(aLocation);
    13511349    CheckComArgOutSafeArrayPointerValid(aHardDisk);
    13521350
     
    14231421                                      IMedium **aHardDisk)
    14241422{
    1425     CheckComArgNotNull(aLocation);
     1423    CheckComArgStrNotEmptyOrNull(aLocation);
    14261424    CheckComArgOutSafeArrayPointerValid(aHardDisk);
    14271425
     
    14301428
    14311429    ComObjPtr<Medium> hardDisk;
    1432     HRESULT rc = findHardDisk(NULL, aLocation, true /* setError */, &hardDisk);
     1430    Utf8Str strLocation(aLocation);
     1431    HRESULT rc = findHardDisk(NULL, &strLocation, true /* setError */, &hardDisk);
    14331432
    14341433    /* the below will set *aHardDisk to NULL if hardDisk is null */
     
    14791478
    14801479/** @note Locks objects! */
    1481 STDMETHODIMP VirtualBox::GetDVDImage (IN_BSTR aId, IMedium **aDVDImage)
     1480STDMETHODIMP VirtualBox::GetDVDImage(IN_BSTR aId, IMedium **aDVDImage)
    14821481{
    14831482    CheckComArgOutSafeArrayPointerValid(aDVDImage);
     
    14971496
    14981497/** @note Locks objects! */
    1499 STDMETHODIMP VirtualBox::FindDVDImage (IN_BSTR aLocation, IMedium **aDVDImage)
    1500 {
    1501     CheckComArgNotNull(aLocation);
     1498STDMETHODIMP VirtualBox::FindDVDImage(IN_BSTR aLocation, IMedium **aDVDImage)
     1499{
     1500    CheckComArgStrNotEmptyOrNull(aLocation);
    15021501    CheckComArgOutSafeArrayPointerValid(aDVDImage);
    15031502
     
    15061505
    15071506    ComObjPtr<Medium> image;
    1508     HRESULT rc = findDVDImage (NULL, aLocation, true /* setError */, &image);
     1507    Utf8Str strLocation(aLocation);
     1508    HRESULT rc = findDVDImage(NULL, &strLocation, true /* setError */, &image);
    15091509
    15101510    /* the below will set *aDVDImage to NULL if dvd is null */
     
    15151515
    15161516/** @note Doesn't lock anything. */
    1517 STDMETHODIMP VirtualBox::OpenFloppyImage (IN_BSTR aLocation, IN_BSTR aId,
    1518                                           IMedium **aFloppyImage)
     1517STDMETHODIMP VirtualBox::OpenFloppyImage(IN_BSTR aLocation, IN_BSTR aId,
     1518                                         IMedium **aFloppyImage)
    15191519{
    15201520    CheckComArgStrNotEmptyOrNull(aLocation);
     
    15551555
    15561556/** @note Locks objects! */
    1557 STDMETHODIMP VirtualBox::GetFloppyImage (IN_BSTR aId,
    1558                                          IMedium **aFloppyImage)
     1557STDMETHODIMP VirtualBox::GetFloppyImage(IN_BSTR aId,
     1558                                        IMedium **aFloppyImage)
    15591559
    15601560{
     
    15751575
    15761576/** @note Locks objects! */
    1577 STDMETHODIMP VirtualBox::FindFloppyImage (IN_BSTR aLocation,
    1578                                           IMedium **aFloppyImage)
    1579 {
    1580     CheckComArgNotNull(aLocation);
     1577STDMETHODIMP VirtualBox::FindFloppyImage(IN_BSTR aLocation,
     1578                                         IMedium **aFloppyImage)
     1579{
     1580    CheckComArgStrNotEmptyOrNull(aLocation);
    15811581    CheckComArgOutSafeArrayPointerValid(aFloppyImage);
    15821582
     
    15851585
    15861586    ComObjPtr<Medium> image;
    1587     HRESULT rc = findFloppyImage(NULL, aLocation, true /* setError */, &image);
     1587    Utf8Str strLocation(aLocation);
     1588    HRESULT rc = findFloppyImage(NULL, &strLocation, true /* setError */, &image);
    15881589
    15891590    /* the below will set *aFloppyImage to NULL if img is null */
     
    15941595
    15951596/** @note Locks this object for reading. */
    1596 STDMETHODIMP VirtualBox::GetGuestOSType (IN_BSTR aId, IGuestOSType **aType)
     1597STDMETHODIMP VirtualBox::GetGuestOSType(IN_BSTR aId, IGuestOSType **aType)
    15971598{
    15981599    /* Old ID to new ID conversion table. See r39691 for a source */
     
    16151616    };
    16161617
    1617     CheckComArgNotNull (aType);
     1618    CheckComArgNotNull(aType);
    16181619
    16191620    AutoCaller autoCaller(this);
     
    16391640    {
    16401641        const Bstr &typeId = (*it)->id();
    1641         AssertMsg (!!typeId, ("ID must not be NULL"));
    1642         if (typeId.compareIgnoreCase (id) == 0)
     1642        if (typeId.compare(id, Bstr::CaseInsensitive) == 0)
    16431643        {
    16441644            (*it).queryInterfaceTo(aType);
     
    17091709                                      BSTR *aValue)
    17101710{
    1711     CheckComArgNotNull(aKey);
     1711    CheckComArgStrNotEmptyOrNull(aKey);
    17121712    CheckComArgNotNull(aValue);
    17131713
     
    17161716
    17171717    /* start with nothing found */
    1718     Bstr bstrResult("");
     1718    Bstr bstrResult;
    17191719
    17201720    settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey));
     
    17351735                                      IN_BSTR aValue)
    17361736{
    1737     CheckComArgNotNull(aKey);
     1737    CheckComArgStrNotEmptyOrNull(aKey);
    17381738
    17391739    AutoCaller autoCaller(this);
     
    17661766        // lock to copy the list of callbacks to invoke
    17671767        Bstr error;
    1768         Bstr bstrValue;
    1769         if (aValue)
    1770             bstrValue = aValue;
    1771         else
    1772             bstrValue = (const char *)"";
     1768        Bstr bstrValue(aValue);
    17731769
    17741770        if (!onExtraDataCanChange(Guid::Empty, aKey, bstrValue, error))
    17751771        {
    17761772            const char *sep = error.isEmpty() ? "" : ": ";
    1777             CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw();
     1773            CBSTR err = error.raw();
    17781774            LogWarningFunc(("Someone vetoed! Change refused%s%ls\n",
    17791775                            sep, err));
     
    18661862    LogRel(("remotesession=%s\n", Utf8Str(aMachineId).c_str()));
    18671863
    1868     CheckComArgNotNull(aMachineId);
     1864    CheckComArgStrNotEmptyOrNull(aMachineId);
    18691865    CheckComArgNotNull(aSession);
    1870     CheckComArgNotNull(aType);
    18711866    CheckComArgOutSafeArrayPointerValid(aProgress);
    18721867
     
    18971892    ComObjPtr<Progress> progress;
    18981893    progress.createObject();
    1899     progress->init (this, static_cast <IMachine *> (machine),
    1900                     Bstr (tr ("Spawning session")),
    1901                     FALSE /* aCancelable */);
     1894    progress->init(this,
     1895                   static_cast<IMachine*>(machine),
     1896                   tr("Spawning session"),
     1897                   FALSE /* aCancelable */);
    19021898
    19031899    rc = machine->openRemoteSession (control, aType, aEnvironment, progress);
     
    24342430            case DataChanged:
    24352431                LogFlow (("OnMachineDataChange: id={%RTuuid}\n", id.ptr()));
    2436                 aCallback->OnMachineDataChange (id.toUtf16());
     2432                aCallback->OnMachineDataChange(id.toUtf16());
    24372433                break;
    24382434
     
    24402436                LogFlow (("OnMachineStateChange: id={%RTuuid}, state=%d\n",
    24412437                          id.ptr(), state));
    2442                 aCallback->OnMachineStateChange (id.toUtf16(), state);
     2438                aCallback->OnMachineStateChange(id.toUtf16(), state);
    24432439                break;
    24442440
     
    24462442                LogFlow (("OnMachineRegistered: id={%RTuuid}, registered=%d\n",
    24472443                          id.ptr(), registered));
    2448                 aCallback->OnMachineRegistered (id.toUtf16(), registered);
     2444                aCallback->OnMachineRegistered(id.toUtf16(), registered);
    24492445                break;
    24502446        }
     
    24972493    while ((it != list.end()) && allowChange)
    24982494    {
    2499         HRESULT rc = (*it++)->OnExtraDataCanChange (id, aKey, aValue,
    2500                                                     aError.asOutParam(), &allowChange);
     2495        HRESULT rc = (*it++)->OnExtraDataCanChange(id,
     2496                                                   aKey,
     2497                                                   aValue,
     2498                                                   aError.asOutParam(),
     2499                                                   &allowChange);
    25012500        if (FAILED(rc))
    25022501        {
     
    25272526        LogFlow (("OnExtraDataChange: machineId={%RTuuid}, key='%ls', val='%ls'\n",
    25282527                  machineId.ptr(), key.raw(), val.raw()));
    2529         aCallback->OnExtraDataChange (machineId.toUtf16(), key, val);
     2528        aCallback->OnExtraDataChange(machineId.toUtf16(), key, val);
    25302529    }
    25312530
     
    25542553{
    25552554    SessionEvent (VirtualBox *aVB, const Guid &aMachineId, SessionState_T aState)
    2556         : CallbackEvent (aVB), machineId (aMachineId), sessionState (aState)
     2555        : CallbackEvent (aVB), machineId(aMachineId), sessionState (aState)
    25572556        {}
    25582557
     
    25612560        LogFlow (("OnSessionStateChange: machineId={%RTuuid}, sessionState=%d\n",
    25622561                  machineId.ptr(), sessionState));
    2563         aCallback->OnSessionStateChange (machineId.toUtf16(), sessionState);
     2562        aCallback->OnSessionStateChange(machineId.toUtf16(), sessionState);
    25642563    }
    25652564
     
    25982597                LogFlow (("OnSnapshotTaken: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    25992598                          machineId.ptr(), snapshotId.ptr()));
    2600                 aCallback->OnSnapshotTaken (mid, sid);
     2599                aCallback->OnSnapshotTaken(mid, sid);
    26012600                break;
    26022601
     
    26042603                LogFlow (("OnSnapshotDiscarded: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    26052604                          machineId.ptr(), snapshotId.ptr()));
    2606                 aCallback->OnSnapshotDiscarded (mid, sid);
     2605                aCallback->OnSnapshotDiscarded(mid, sid);
    26072606                break;
    26082607
     
    26102609                LogFlow (("OnSnapshotChange: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    26112610                          machineId.ptr(), snapshotId.ptr()));
    2612                 aCallback->OnSnapshotChange (mid, sid);
     2611                aCallback->OnSnapshotChange(mid, sid);
    26132612                break;
    26142613        }
     
    26612660        LogFlow(("OnGuestPropertyChange: machineId={%RTuuid}, name='%ls', value='%ls', flags='%ls'\n",
    26622661                 machineId.ptr(), name.raw(), value.raw(), flags.raw()));
    2663         aCallback->OnGuestPropertyChange (machineId.toUtf16(), name, value, flags);
     2662        aCallback->OnGuestPropertyChange(machineId.toUtf16(), name, value, flags);
    26642663    }
    26652664
     
    27972796 *
    27982797 * @param aId           ID of the hard disk (unused when NULL).
    2799  * @param aLocation     Full location specification (unused NULL).
     2798 * @param pstrLocation  Full location specification (unused NULL).
    28002799 * @param aSetError     If @c true , the appropriate error info is set in case
    28012800 *                      when the hard disk is not found.
     
    28072806 */
    28082807HRESULT VirtualBox::findHardDisk(const Guid *aId,
    2809                                  CBSTR aLocation,
     2808                                 const Utf8Str *pstrLocation,
    28102809                                 bool aSetError,
    28112810                                 ComObjPtr<Medium> *aHardDisk /*= NULL*/)
    28122811{
    2813     AssertReturn(aId || aLocation, E_INVALIDARG);
     2812    AssertReturn(aId || pstrLocation, E_INVALIDARG);
    28142813
    28152814    // we use the hard disks map, but it is protected by the
     
    28312830    /* then iterate and search by location */
    28322831    int result = -1;
    2833     if (aLocation)
    2834     {
    2835         Utf8Str location = aLocation;
    2836 
     2832    if (pstrLocation)
     2833    {
    28372834        for (HardDiskMap::const_iterator it = m->mapHardDisks.begin();
    28382835             it != m->mapHardDisks.end();
     
    28412838            const ComObjPtr<Medium> &hd = (*it).second;
    28422839
    2843             HRESULT rc = hd->compareLocationTo(location.c_str(), result);
     2840            HRESULT rc = hd->compareLocationTo(pstrLocation->c_str(), result);
    28442841            if (FAILED(rc)) return rc;
    28452842
     
    28642861        else
    28652862            setError(rc,
    2866                      tr("Could not find a hard disk with location '%ls' in the media registry ('%s')"),
    2867                      aLocation,
     2863                     tr("Could not find a hard disk with location '%s' in the media registry ('%s')"),
     2864                     pstrLocation->c_str(),
    28682865                     m->strSettingsFilePath.raw());
    28692866    }
     
    28882885 */
    28892886HRESULT VirtualBox::findDVDImage(const Guid *aId,
    2890                                  CBSTR aLocation,
     2887                                 const Utf8Str *pstrLocation,
    28912888                                 bool aSetError,
    28922889                                 ComObjPtr<Medium> *aImage /* = NULL */)
    28932890{
    2894     AssertReturn(aId || aLocation, E_INVALIDARG);
     2891    AssertReturn(aId || pstrLocation, E_INVALIDARG);
    28952892
    28962893    Utf8Str location;
    28972894
    2898     if (aLocation != NULL)
    2899     {
    2900         int vrc = calculateFullPath(Utf8Str(aLocation), location);
     2895    if (pstrLocation != NULL)
     2896    {
     2897        int vrc = calculateFullPath(*pstrLocation, location);
    29012898        if (RT_FAILURE(vrc))
    29022899            return setError(VBOX_E_FILE_ERROR,
    2903                             tr("Invalid image file location '%ls' (%Rrc)"),
    2904                             aLocation,
     2900                            tr("Invalid image file location '%s' (%Rrc)"),
     2901                            pstrLocation->c_str(),
    29052902                            vrc);
    29062903    }
     
    29172914        AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS);
    29182915
    2919         found = (aId && (*it)->getId() == *aId) ||
    2920                 (aLocation != NULL &&
    2921                  RTPathCompare(location.c_str(),
    2922                                (*it)->getLocationFull().c_str()
    2923                               ) == 0);
     2916        found =    (aId && (*it)->getId() == *aId)
     2917                || (    pstrLocation != NULL
     2918                     && RTPathCompare(location.c_str(),
     2919                                      (*it)->getLocationFull().c_str()
     2920                                     ) == 0);
    29242921        if (found)
    29252922        {
     
    29412938        else
    29422939            setError(rc,
    2943                      tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"),
    2944                      aLocation,
     2940                     tr("Could not find a CD/DVD image with location '%s' in the media registry ('%s')"),
     2941                     pstrLocation->c_str(),
    29452942                     m->strSettingsFilePath.raw());
    29462943    }
     
    29662963 */
    29672964HRESULT VirtualBox::findFloppyImage(const Guid *aId,
    2968                                     CBSTR aLocation,
     2965                                    const Utf8Str *pstrLocation,
    29692966                                    bool aSetError,
    29702967                                    ComObjPtr<Medium> *aImage /* = NULL */)
    29712968{
    2972     AssertReturn(aId || aLocation, E_INVALIDARG);
     2969    AssertReturn(aId || pstrLocation, E_INVALIDARG);
    29732970
    29742971    Utf8Str location;
    29752972
    2976     if (aLocation != NULL)
    2977     {
    2978         int vrc = calculateFullPath(Utf8Str(aLocation), location);
     2973    if (pstrLocation != NULL)
     2974    {
     2975        int vrc = calculateFullPath(*pstrLocation, location);
    29792976        if (RT_FAILURE(vrc))
    29802977            return setError(VBOX_E_FILE_ERROR,
    2981                             tr("Invalid image file location '%ls' (%Rrc)"),
    2982                             aLocation, vrc);
     2978                            tr("Invalid image file location '%s' (%Rrc)"),
     2979                            pstrLocation->c_str(),
     2980                            vrc);
    29832981    }
    29842982
     
    29942992        AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS);
    29952993
    2996         found = (aId && (*it)->getId() == *aId) ||
    2997                 (aLocation != NULL &&
    2998                  RTPathCompare(location.c_str(),
    2999                                (*it)->getLocationFull().c_str()
    3000                               ) == 0);
     2994        found =    (aId && (*it)->getId() == *aId)
     2995                || (    pstrLocation != NULL
     2996                     && RTPathCompare(location.c_str(),
     2997                                      (*it)->getLocationFull().c_str()
     2998                                     ) == 0);
    30012999        if (found)
    30023000        {
     
    30183016        else
    30193017            setError(rc,
    3020                      tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"),
    3021                      aLocation,
     3018                     tr("Could not find a floppy image with location '%s' in the media registry ('%s')"),
     3019                     pstrLocation->c_str(),
    30223020                     m->strSettingsFilePath.raw());
    30233021    }
     
    31973195    HRESULT rc = S_OK;
    31983196
    3199     Bstr bstrLocation(aLocation);
    3200 
    32013197    {
    32023198        ComObjPtr<Medium> hardDisk;
    3203         rc = findHardDisk(&aId, bstrLocation, false /* aSetError */, &hardDisk);
     3199        rc = findHardDisk(&aId, &aLocation, false /* aSetError */, &hardDisk);
    32043200        if (SUCCEEDED(rc))
    32053201        {
     
    32153211    {
    32163212        ComObjPtr<Medium> image;
    3217         rc = findDVDImage(&aId, bstrLocation, false /* aSetError */, &image);
     3213        rc = findDVDImage(&aId, &aLocation, false /* aSetError */, &image);
    32183214        if (SUCCEEDED(rc))
    32193215        {
     
    32293225    {
    32303226        ComObjPtr<Medium> image;
    3231         rc = findFloppyImage(&aId, bstrLocation, false /* aSetError */, &image);
     3227        rc = findFloppyImage(&aId, &aLocation, false /* aSetError */, &image);
    32323228        if (SUCCEEDED(rc))
    32333229        {
     
    43594355STDMETHODIMP VirtualBox::CreateDHCPServer (IN_BSTR aName, IDHCPServer ** aServer)
    43604356{
    4361     CheckComArgNotNull(aName);
     4357    CheckComArgStrNotEmptyOrNull(aName);
    43624358    CheckComArgNotNull(aServer);
    43634359
     
    43804376STDMETHODIMP VirtualBox::FindDHCPServerByNetworkName(IN_BSTR aName, IDHCPServer ** aServer)
    43814377{
    4382     CheckComArgNotNull(aName);
     4378    CheckComArgStrNotEmptyOrNull(aName);
    43834379    CheckComArgNotNull(aServer);
    43844380
     
    44564452
    44574453    ComPtr<IDHCPServer> existing;
    4458     rc = FindDHCPServerByNetworkName(name.mutableRaw(), existing.asOutParam());
     4454    rc = FindDHCPServerByNetworkName(name, existing.asOutParam());
    44594455    if (SUCCEEDED(rc))
    44604456    {
  • trunk/src/VBox/Main/generic/NetIf-generic.cpp

    r26553 r26587  
    231231        Bstr ifname;
    232232        ComPtr<IHostNetworkInterface> iface;
    233         if (FAILED(host->FindHostNetworkInterfaceById (Guid(aId).toUtf16(), iface.asOutParam())))
     233        if (FAILED(host->FindHostNetworkInterfaceById(Guid(aId).toUtf16(), iface.asOutParam())))
    234234            return VERR_INVALID_PARAMETER;
    235         iface->COMGETTER(Name) (ifname.asOutParam());
    236         if (ifname.isNull())
     235        iface->COMGETTER(Name)(ifname.asOutParam());
     236        if (ifname.isEmpty())
    237237            return VERR_INTERNAL_ERROR;
    238238
    239         rc = progress->init (pVBox, host,
    240                             Bstr ("Removing host network interface"),
     239        rc = progress->init(pVBox,
     240                            host,
     241                            Bstr("Removing host network interface"),
    241242                            FALSE /* aCancelable */);
    242243        if(SUCCEEDED(rc))
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r26553 r26587  
    170170    {
    171171        mCalleeIID = aIID;
    172         GetInterfaceNameByIID (aIID, mCalleeName.asOutParam());
     172        GetInterfaceNameByIID(aIID, mCalleeName.asOutParam());
    173173    }
    174174}
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r26553 r26587  
    9696
    9797    void disksWeight(uint32_t &ulTotalMB, uint32_t &cDisks) const;
    98     HRESULT setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
    99     HRESULT setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
    100     HRESULT setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
     98    HRESULT setUpProgressFS(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);
     99    HRESULT setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);
     100    HRESULT setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription);
    101101
    102102    struct LocationInfo;
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r26553 r26587  
    5252    HRESULT protectedInit(AutoInitSpan &aAutoInitSpan,
    5353#if !defined (VBOX_COM_INPROC)
    54                   VirtualBox *aParent,
    55 #endif
    56                   IUnknown *aInitiator,
    57                   CBSTR aDescription, OUT_GUID aId = NULL);
     54                          VirtualBox *aParent,
     55#endif
     56                          IUnknown *aInitiator,
     57                          const Utf8Str &strDescription,
     58                          OUT_GUID aId = NULL);
    5859    HRESULT protectedInit(AutoInitSpan &aAutoInitSpan);
    5960    void protectedUninit(AutoUninitSpan &aAutoUninitSpan);
     
    105106
    106107    const Guid mId;
    107     const Bstr mDescription;
     108    const Utf8Str m_strDescription;
    108109
    109110    uint64_t m_ullTimestamp;                        // progress object creation timestamp, for ETA computation
     
    126127
    127128    ULONG m_ulCurrentOperation;                     // operations counter, incremented with each setNextOperation()
    128     Bstr m_bstrOperationDescription;                // name of current operation; initially from constructor, changed with setNextOperation()
     129    Utf8Str m_strOperationDescription;              // name of current operation; initially from constructor, changed with setNextOperation()
    129130    ULONG m_ulCurrentOperationWeight;               // weight of current operation, given to setNextOperation()
    130131    ULONG m_ulOperationPercent;                     // percentage of current operation, set with setCurrentOperationProgress()
     
    176177#endif
    177178                  IUnknown *aInitiator,
    178                   CBSTR aDescription,
     179                  const Utf8Str &strDescription,
    179180                  BOOL aCancelable,
    180181                  OUT_GUID aId = NULL)
     
    185186#endif
    186187            aInitiator,
    187             aDescription,
     188            strDescription,
    188189            aCancelable,
    189190            1,      // cOperations
    190191            1,      // ulTotalOperationsWeight
    191             aDescription, // bstrFirstOperationDescription
     192            strDescription, // bstrFirstOperationDescription
    192193            1,      // ulFirstOperationWeight
    193194            aId);
     
    211212#endif
    212213                  IUnknown *aInitiator,
    213                   CBSTR aDescription, BOOL aCancelable,
     214                  const Utf8Str &strDescription,
     215                  BOOL aCancelable,
    214216                  ULONG cOperations,
    215                   CBSTR bstrFirstOperationDescription,
     217                  const Utf8Str &strFirstOperationDescription,
    216218                  OUT_GUID aId = NULL)
    217219    {
     
    221223#endif
    222224            aInitiator,
    223             aDescription,
     225            strDescription,
    224226            aCancelable,
    225227            cOperations,      // cOperations
    226228            cOperations,      // ulTotalOperationsWeight = cOperations
    227             bstrFirstOperationDescription, // bstrFirstOperationDescription
     229            strFirstOperationDescription, // bstrFirstOperationDescription
    228230            1,      // ulFirstOperationWeight: weigh them all the same
    229231            aId);
     
    235237#endif
    236238                  IUnknown *aInitiator,
    237                   CBSTR aDescription,
     239                  const Utf8Str &strDescription,
    238240                  BOOL aCancelable,
    239241                  ULONG cOperations,
    240242                  ULONG ulTotalOperationsWeight,
    241                   CBSTR bstrFirstOperationDescription,
     243                  const Utf8Str &strFirstOperationDescription,
    242244                  ULONG ulFirstOperationWeight,
    243245                  OUT_GUID aId = NULL);
     
    245247    HRESULT init(BOOL aCancelable,
    246248                 ULONG aOperationCount,
    247                  CBSTR aOperationDescription);
     249                 const Utf8Str &strOperationDescription);
    248250
    249251    void uninit();
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r26553 r26587  
    246246                         ComObjPtr<Machine> *machine = NULL);
    247247
    248     HRESULT findHardDisk(const Guid *aId, CBSTR aLocation,
     248    HRESULT findHardDisk(const Guid *aId, const Utf8Str *pstrLocation,
    249249                          bool aSetError, ComObjPtr<Medium> *aHardDisk = NULL);
    250     HRESULT findDVDImage(const Guid *aId, CBSTR aLocation,
     250    HRESULT findDVDImage(const Guid *aId, const Utf8Str *pstrLocation,
    251251                         bool aSetError, ComObjPtr<Medium> *aImage = NULL);
    252     HRESULT findFloppyImage(const Guid *aId, CBSTR aLocation,
     252    HRESULT findFloppyImage(const Guid *aId, const Utf8Str *pstrLocation,
    253253                            bool aSetError, ComObjPtr<Medium> *aImage = NULL);
    254254
  • trunk/src/VBox/Main/win/NetIf-win.cpp

    r26186 r26587  
    908908    if(hr == S_OK)
    909909    {
    910         size_t cUnicodeName = wcslen(lpszName) + 1;
    911         size_t uniLen = (cUnicodeName * 2 + sizeof (OLECHAR) - 1) / sizeof (OLECHAR);
    912         Bstr name (uniLen + 1 /* extra zero */);
    913         wcscpy((wchar_t *) name.mutableRaw(), lpszName);
     910        Bstr name(lpszName);
    914911
    915912        hr = pncc->GetInstanceGuid(&IfGuid);
  • trunk/src/VBox/Main/win/svcmain.cpp

    r26186 r26587  
    231231
    232232                if (*lpszToken != NULL)
    233                 {
    234                     Bstr str (lpszToken);
    235                     LPCTSTR lpszToken2 = FindOneOf(lpszToken, szTokens);
    236                     if (lpszToken2)
    237                         str.mutableRaw()[lpszToken2 - lpszToken] = '\0';
    238233                    pipeName = Utf8Str(lpszToken);
    239                 }
    240234            }
    241235
  • trunk/src/VBox/Main/xml/Settings.cpp

    r26553 r26587  
    195195            strLine = Utf8StrFmt(" (line %RU32)", pNode->getLineNumber());
    196196
    197         const char *pcsz = strLine.c_str();
    198197        Utf8StrFmt str(N_("Error in %s%s -- %s"),
    199198                       file->m->strFilename.c_str(),
    200                        (pcsz) ? pcsz : "",
     199                       strLine.c_str(),
    201200                       strWhat.c_str());
    202201
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