VirtualBox

Changeset 26553 in vbox


Ignore:
Timestamp:
Feb 15, 2010 5:34:29 PM (15 years ago)
Author:
vboxsync
Message:

Main: backing out r57728 + r57730 which burn on windows

Location:
trunk
Files:
35 edited

Legend:

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

    r26550 r26553  
    9797    {
    9898        ::RTUuidClear (&uuid);
    99         if (!that.isEmpty())
     99        if (!that.isNull())
    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

    r26552 r26553  
    33/** @file
    44 * MS COM / XPCOM Abstraction Layer:
    5  * UTF-8 and UTF-16 string classes
     5 * Smart string classes declaration
    66 */
    77
     
    5959
    6060/**
    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().
     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.
    8972 */
    9073class Bstr
     
    9275public:
    9376
    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     }
     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); }
    12984
    13085#if defined (VBOX_WITH_XPCOM)
    131     Bstr(const wchar_t *pw)
     86    Bstr(const wchar_t *that) : bstr(NULL)
    13287    {
    13388        AssertCompile(sizeof(wchar_t) == sizeof(OLECHAR));
    134         copyFrom((CBSTR)pw);
     89        raw_copy(bstr, (CBSTR)that);
    13590    }
    13691#endif
    13792
    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     /** Case sensitivity selector. */
    211     enum CaseSensitivity
    212     {
    213         CaseSensitive,
    214         CaseInsensitive
    215     };
    216 
    217     int compare(CBSTR str, CaseSensitivity cs = CaseSensitive) const
    218     {
    219         if (m_bstr == str)
    220             return 0;
    221         if (m_bstr == NULL)
    222             return -1;
    223         if (str == NULL)
    224             return 1;
    225 
    226         if (cs == CaseSensitive)
    227             return ::RTUtf16Cmp((PRTUTF16)m_bstr, (PRTUTF16)str);
    228         else
    229             return ::RTUtf16ICmp((PRTUTF16)m_bstr, (PRTUTF16)str);
    230     }
    231 
    232     int compare(const Bstr &bstr, CaseSensitivity cs = CaseSensitive) const
    233     {
    234         return compare(bstr.raw(), cs);
    235     }
    236 
    237     /** @name Comparison operators.
    238      * @{  */
    239     bool operator==(const Bstr &that) const { return !compare(that.raw()); }
    240     bool operator!=(const Bstr &that) const { return !!compare(that.raw()); }
    241     bool operator<( const Bstr &that) const { return compare(that.raw()) < 0; }
    242     bool operator>( const Bstr &that) const { return compare(that.raw()) > 0; }
    243 
     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); }
    244157    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
    245173    bool operator!=(CBSTR that) const { return !!compare(that); }
    246     bool operator<( CBSTR that) const { return compare(that) < 0; }
    247     bool operator>( CBSTR that) const { return compare(that) > 0; }
    248 
    249     /** @} */
     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); }
    250197
    251198    /** Intended to to pass instances as |CBSTR| input parameters to methods. */
    252     operator CBSTR() const { return raw(); }
     199    operator CBSTR() const { return bstr; }
    253200
    254201    /**
     
    257204     * input BSTR parameters of interface methods are not const.
    258205     */
    259     operator BSTR() { return (BSTR)raw(); }
     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; }
    260222
    261223    /**
     
    263225     *  within the interface method. Transfers the ownership of the duplicated
    264226     *  string to the caller.
    265      *
    266      *  This allocates a single 0 byte in the target if the member string is empty.
    267      */
    268     const Bstr& cloneTo(BSTR *pstr) const
     227     */
     228    const Bstr &cloneTo(BSTR *pstr) const
    269229    {
    270230        if (pstr)
    271             *pstr = ::SysAllocString((const OLECHAR*)raw());
    272                     // raw() never returns NULL, so we always allocate something here
     231        {
     232            *pstr = NULL;
     233            raw_copy(*pstr, bstr);
     234        }
    273235        return *this;
    274236    }
     
    281243     *  As opposed to cloneTo(), this method doesn't create a copy of the
    282244     *  string.
    283      *
    284      *  This allocates a single 0 byte in the target if the member string is empty.
    285      */
    286     Bstr& detachTo(BSTR *pstr)
    287     {
    288         *pstr = (m_bstr) ? m_bstr : ::SysAllocString((const OLECHAR*)"");
    289         m_bstr = NULL;
    290         return *this;
    291     }
     245     */
     246    Bstr &detachTo(BSTR *pstr)
     247    {
     248        *pstr = bstr;
     249        bstr = NULL;
     250        return *this;
     251    }
     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;
    292259
    293260    /**
     
    295262     *  Takes the ownership of the returned data.
    296263     */
    297     BSTR* asOutParam()
    298     {
    299         cleanup();
    300         return &m_bstr;
    301     }
     264    BSTR *asOutParam() { setNull(); return &bstr; }
    302265
    303266    /**
     
    308271protected:
    309272
    310     /**
    311      * Destructor implementation, also used to clean up in operator=() before
    312      * assigning a new string.
    313      */
    314     void cleanup()
    315     {
    316         if (m_bstr)
    317         {
    318             ::SysFreeString(m_bstr);
    319             m_bstr = NULL;
    320         }
    321     }
    322 
    323     /**
    324      *  Protected internal helper which allocates memory for a string capable of
    325      *  storing \a aSize - 1 characters (not bytes, not codepoints); in other words,
    326      *  aSize includes the terminating null character.
    327      *
    328      *  Does NOT call cleanup() before allocating!
    329      *
    330      * @throws  std::bad_alloc  On allocation failure. The object is left describing
    331      *             a NULL string.
    332      */
    333     void alloc(size_t cw)
    334     {
    335         if (cw)
    336         {
    337             m_bstr = ::SysAllocStringLen(NULL, (unsigned int)cw - 1);
    338 #ifdef RT_EXCEPTIONS_ENABLED
    339             if (!m_bstr)
    340                 throw std::bad_alloc();
    341 #endif
    342         }
    343     }
    344 
    345     /**
    346      * Protected internal helper to copy a string, ignoring the previous object state.
    347      *
    348      * copyFrom() unconditionally sets the members to a copy of the given other
    349      * strings and makes no assumptions about previous contents. Can therefore be
    350      * used both in copy constructors, when member variables have no defined value,
    351      * and in assignments after having called cleanup().
    352      *
    353      * This variant copies from another Bstr. Since Bstr does _not_ cache string lengths,
    354      * this is not fast.
    355      *
    356      * @param   s               The source string.
    357      *
    358      * @throws  std::bad_alloc  On allocation failure. The object is left describing
    359      *             a NULL string.
    360      */
    361     void copyFrom(const Bstr &s)
    362     {
    363         copyFrom(s.raw());
    364     }
    365 
    366     /**
    367      * Protected internal helper to copy a string, ignoring the previous object state.
    368      *
    369      * See copyFrom() above.
    370      *
    371      * This variant copies from a wide char C string.
    372      *
    373      * @param   pcsz            The source string.
    374      *
    375      * @throws  std::bad_alloc  On allocation failure. The object is left describing
    376      *             a NULL string.
    377      */
    378     void copyFrom(CBSTR pw)
    379     {
    380         size_t cwLength;
    381         if (    (pw)
    382              && ((cwLength = ::SysStringLen((BSTR)pw)))
    383            )
    384         {
    385             size_t cwAllocated = cwLength + 1;
    386             alloc(cwAllocated);
    387             memcpy(m_bstr, pw, cwAllocated * sizeof(OLECHAR));     // include 0 terminator
    388         }
    389         else
    390             m_bstr = NULL;
    391     }
    392 
    393     /**
    394      * Protected internal helper to copy a string, ignoring the previous object state.
    395      *
    396      * See copyFrom() above.
    397      *
    398      * This variant converts from a Utf-8 C string.
    399      *
    400      * @param   pcsz            The source string.
    401      *
    402      * @throws  std::bad_alloc  On allocation failure. The object is left describing
    403      *             a NULL string.
    404      */
    405     void copyFrom(const char *pcsz)
    406     {
    407         if (pcsz && *pcsz)
    408         {
    409             // @todo r=dj apparently this was copied twice in the original because our buffers
    410             // use memory from SysAllocMem and IPRT doesn't, but check if this can be made faster
     273    void safe_assign(CBSTR str)
     274    {
     275        if (bstr != str)
     276        {
     277            setNull();
     278            raw_copy(bstr, str);
     279        }
     280    }
     281
     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)
     291        {
    411292            PRTUTF16 s = NULL;
    412             ::RTStrToUtf16(pcsz, &s);
    413             copyFrom((BSTR)s);              // @todo r=dj this is not exception safe
     293            ::RTStrToUtf16(rs, &s);
     294            raw_copy(ls, (BSTR)s);
    414295            ::RTUtf16Free(s);
    415296        }
    416         else
    417             m_bstr = NULL;
    418     }
    419 
    420     BSTR    m_bstr;                     /**< The string buffer. */
     297    }
     298
     299    BSTR bstr;
     300
     301    friend class Utf8Str; /* to access our raw_copy() */
    421302};
    422303
     
    430311
    431312/**
    432  *  String class used universally in Main for Utf-8 strings.
    433  *
    434  *  This is based on iprt::MiniString, to which some functionality has been
    435  *  moved. Here we keep things that are specific to Main, such as conversions
    436  *  with UTF-16 strings (Bstr).
    437  *
    438  *  Like iprt::MiniString, Utf8Str does not differentiate between NULL strings
    439  *  and empty strings. In other words, Utf8Str("") and Utf8Str(NULL)
    440  *  behave the same. In both cases, MiniString allocates no memory, reports
    441  *  a zero length and zero allocated bytes for both, and returns an empty
    442  *  C string from c_str().
     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.
    443325 */
    444326class Utf8Str : public iprt::MiniString
     
    458340    Utf8Str(const Bstr &that)
    459341    {
    460         copyFrom(that.raw());
     342        copyFrom(that);
    461343    }
    462344
     
    481363    {
    482364        cleanup();
    483         copyFrom(that.raw());
     365        copyFrom(that);
    484366        return *this;
    485367    }
     
    497379     * caller.
    498380     *
    499      * This allocates a single 0 byte in the target if the member string is empty.
    500      *
    501381     * @remarks The returned string must be freed by RTStrFree, not RTMemFree.
    502382     */
    503383    const Utf8Str& cloneTo(char **pstr) const
    504384    {
    505         if (pstr)
    506         {
    507             *pstr = RTStrDup(raw());
    508 #ifdef RT_EXCEPTIONS_ENABLED
    509             if (!*pstr)
    510                 throw std::bad_alloc();
    511 #endif
    512         }
     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;
    513404        return *this;
    514405    }
     
    518409     *  interface method. Transfers the ownership of the duplicated string to the
    519410     *  caller.
    520      *
    521      *  This allocates a single 0 byte in the target if the member string is empty.
    522411     */
    523412    const Utf8Str& cloneTo(BSTR *pstr) const
     
    525414        if (pstr)
    526415        {
    527             Bstr bstr(c_str());
    528416            *pstr = NULL;
    529             bstr.detachTo(pstr);
     417            Bstr::raw_copy(*pstr, m_psz);
    530418        }
    531419        return *this;
     
    619507        if (s)
    620508        {
    621             RTUtf16ToUtf8((PRTUTF16)s, &m_psz); /** @todo r=bird: This technically requires using RTStrFree, ministring::cleanup() uses RTMemFree. */
    622 #ifdef RT_EXCEPTIONS_ENABLED
    623             if (!m_psz)
    624                 throw std::bad_alloc();
    625 #endif
     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. */
    626511            m_cbLength = strlen(m_psz);         /** @todo optimize by using a different RTUtf* function */
    627512            m_cbAllocated = m_cbLength + 1;
     
    640525// work around error C2593 of the stupid MSVC 7.x ambiguity resolver
    641526WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP(Bstr)
     527
     528////////////////////////////////////////////////////////////////////////////////
     529
     530// inlined Bstr members that depend on Utf8Str
     531
     532inline Bstr::Bstr(const iprt::MiniString &that)
     533    : bstr(NULL)
     534{
     535    raw_copy(bstr, that.c_str());
     536}
     537
     538inline Bstr::Bstr(const char *that)
     539    : bstr(NULL)
     540{
     541    raw_copy(bstr, that);
     542}
     543
     544inline Bstr &Bstr::operator=(const Utf8Str &that)
     545{
     546    setNull();
     547    raw_copy(bstr, that.c_str());
     548    return *this;
     549}
     550inline Bstr &Bstr::operator=(const char *that)
     551{
     552    setNull();
     553    raw_copy(bstr, that);
     554    return *this;
     555}
     556
     557inline 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}
    642566
    643567////////////////////////////////////////////////////////////////////////////////
     
    730654        va_list args;
    731655        va_start(args, aFormat);
    732         copyFrom(Utf8StrFmtVA(aFormat, args).c_str());
     656        raw_copy(bstr, Utf8StrFmtVA(aFormat, args).c_str());
    733657        va_end(args);
    734658    }
     
    751675    BstrFmtVA(const char *aFormat, va_list aArgs)
    752676    {
    753         copyFrom(Utf8StrFmtVA(aFormat, aArgs).c_str());
     677        raw_copy(bstr, Utf8StrFmtVA(aFormat, aArgs).c_str());
    754678    }
    755679};
  • trunk/include/iprt/cpp/ministring.h

    r26550 r26553  
    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().
    5347 */
    5448#ifdef VBOX
     
    7771     * Creates a copy of another MiniString.
    7872     *
    79      * This allocates s.length() + 1 bytes for the new instance, unless s is empty.
     73     * This allocates s.length() + 1 bytes for the new instance.
    8074     *
    8175     * @param   s               The source string.
     
    8983
    9084    /**
    91      * Creates a copy of a C string.
    92      *
    93      * This allocates strlen(pcsz) + 1 bytes for the new instance, unless s is empty.
     85     * Creates a copy of another MiniString.
     86     *
     87     * This allocates strlen(pcsz) + 1 bytes for the new instance.
    9488     *
    9589     * @param   pcsz            The source string.
     
    129123     *
    130124     * Returns the number of bytes allocated in the internal string buffer, which is
    131      * at least length() + 1 if length() > 0. Returns 0 for an empty string.
     125     * at least length() + 1 if length() > 0.
    132126     *
    133127     * @returns m_cbAllocated.
     
    281275     * Returns the byte at the given index, or a null byte if the index is not
    282276     * smaller than length().  This does _not_ count codepoints but simply points
    283      * into the member C string; the result may not be a valid UTF-8 character.
     277     * into the member C string.
    284278     *
    285279     * @param   i       The index into the string buffer.
     
    295289    /**
    296290     * 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.
    299291     *
    300292     * @returns const pointer to C-style string.
     
    302294    inline const char *c_str() const
    303295    {
    304         return (m_psz) ? m_psz : "";
     296        return m_psz;
    305297    }
    306298
    307299    /**
    308300     * 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.
    311301     *
    312302     * @returns const pointer to C-style string.
     
    314304    inline const char *raw() const
    315305    {
    316         return (m_psz) ? m_psz : "";
    317     }
    318 
    319     /**
    320      * Empty string or not?
     306        return m_psz;
     307    }
     308
     309    /**
     310     * Emptry string or not?
    321311     *
    322312     * Returns true if the member string has no length.  This states nothing about
     
    482472
    483473    /**
     474     * Hide operator bool() to force people to use isEmpty() explicitly.
     475     */
     476    operator bool() const { return false; }
     477
     478    /**
    484479     * Destructor implementation, also used to clean up in operator=() before
    485480     * assigning a new string.
     
    497492
    498493    /**
    499      * Protected internal helper to copy a string, ignoring the previous object state.
     494     * Protected internal helper for copy a string that completely ignors the
     495     * current object state.
    500496     *
    501497     * copyFrom() unconditionally sets the members to a copy of the given other
     
    505501     *
    506502     * This variant copies from another MiniString and is fast since
    507      * the length of the source string is known.
     503     * the length of source string is known.
    508504     *
    509505     * @param   s               The source string.
     
    537533
    538534    /**
    539      * Protected internal helper to copy a string, ignoring the previous object state.
     535     * Protected internal helper for copy a string that completely ignors the
     536     * current object state.
    540537     *
    541538     * See copyFrom() above.
     
    575572    }
    576573
    577 private:
    578 
    579     /**
    580      * Hide operator bool() to force people to use isEmpty() explicitly.
    581      */
    582     operator bool() const;
    583 
    584 protected:
    585 
    586574    char    *m_psz;                     /**< The string buffer. */
    587575    size_t  m_cbLength;                 /**< strlen(m_psz) - i.e. no terminator included. */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDHCPServer.cpp

    r26550 r26553  
    230230
    231231        ComPtr<IHostNetworkInterface> hif;
    232         CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName), hif.asOutParam()));
     232        CHECK_ERROR(host, FindHostNetworkInterfaceByName(Bstr(pIfName).mutableRaw(), 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, svr.asOutParam());
     246    rc = a->virtualBox->FindDHCPServerByNetworkName(NetName.mutableRaw(), svr.asOutParam());
    247247    if(enmCode == OP_ADD)
    248248    {
     
    250250            return errorArgument("dhcp server already exists");
    251251
    252         CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName.raw(), svr.asOutParam()));
     252        CHECK_ERROR(a->virtualBox, CreateDHCPServer(NetName.mutableRaw(), 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).raw(), Bstr(pNetmask), Bstr(pLowerIp), Bstr(pUpperIp)));
     265            CHECK_ERROR(svr, SetConfiguration (Bstr(pIp).mutableRaw(), Bstr(pNetmask).mutableRaw(), Bstr(pLowerIp).mutableRaw(), Bstr(pUpperIp).mutableRaw()));
    266266            if(FAILED(rc))
    267267                return errorArgument("failed to set configuration");
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r26550 r26553  
    281281        bool doClose = false;
    282282
    283         if (!comment.isEmpty())
     283        if (!comment.isNull())
    284284        {
    285285            CHECK_ERROR(hardDisk,COMSETTER(Description)(comment));
     
    10381038        if (FAILED(rc)) break;
    10391039
    1040         if (!port.isEmpty())
     1040        if (!port.isNull())
    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.isEmpty())
     1049        target.detachTo (values.appendedRaw());
     1050
     1051        if (!lun.isNull())
    10521052        {
    10531053            Bstr ("LUN").detachTo (names.appendedRaw());
    10541054            lun.detachTo (values.appendedRaw());
    10551055        }
    1056         if (!username.isEmpty())
     1056        if (!username.isNull())
    10571057        {
    10581058            Bstr ("InitiatorUsername").detachTo (names.appendedRaw());
    10591059            username.detachTo (values.appendedRaw());
    10601060        }
    1061         if (!password.isEmpty())
     1061        if (!password.isNull())
    10621062        {
    10631063            Bstr ("InitiatorSecret").detachTo (names.appendedRaw());
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp

    r26550 r26553  
    441441                if (!f.mActive.isNull())
    442442                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    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));
     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()));
    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.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));
     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()));
    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.isEmpty())
    497                     CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName));
     496                if (!f.mName.isNull())
     497                    CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
    498498                if (!f.mActive.isNull())
    499499                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    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));
     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()));
    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.isEmpty())
    524                     CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName));
     523                if (!f.mName.isNull())
     524                    CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
    525525                if (!f.mActive.isNull())
    526526                    CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
    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));
     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()));
    539539                if (!f.mMaskedInterfaces.isNull())
    540540                    CHECK_ERROR_BREAK (flt, COMSETTER(MaskedInterfaces) (f.mMaskedInterfaces));
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r26550 r26553  
    228228            return E_INVALIDARG;
    229229
    230         if (com::asGuidStr(id).isEmpty())
     230        if (com::asGuidStr(id).isNull())
    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).isEmpty())
     312        if (com::asGuidStr(id).isNull())
    313313        {
    314314            QString sKey = QString::fromUtf16 (key);
  • trunk/src/VBox/HostServices/GuestProperties/service.cpp

    r26550 r26553  
    11581158 */
    11591159/* static */
    1160 DECLCALLBACK(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)
     1160DECLCALLBACK(int) Service::reqNotify(PFNHGCMSVCEXT pfnCallback, void *pvData,
     1161                                     char *pszName, char *pszValue, uint32_t u32TimeHigh,
     1162                                     uint32_t u32TimeLow, char *pszFlags)
    11671163{
    11681164    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

    r26550 r26553  
    370370    int i = 1;
    371371    /* @todo: Maybe too cost-intensive; try to find a lighter way */
    372     while (mVirtualBox->FindMachine(Bstr(tmpName).raw(), &machine) != VBOX_E_OBJECT_NOT_FOUND)
     372    while (mVirtualBox->FindMachine(Bstr(tmpName), &machine) != VBOX_E_OBJECT_NOT_FOUND)
    373373    {
    374374        RTStrFree(tmpName);
     
    391391    /* @todo: Maybe too cost-intensive; try to find a lighter way */
    392392    while (RTPathExists(tmpName) ||
    393            mVirtualBox->FindHardDisk(Bstr(tmpName).raw(), &harddisk) != VBOX_E_OBJECT_NOT_FOUND)
     393           mVirtualBox->FindHardDisk(Bstr(tmpName), &harddisk) != VBOX_E_OBJECT_NOT_FOUND)
    394394    {
    395395        RTStrFree(tmpName);
     
    501501}
    502502
    503 HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
     503HRESULT Appliance::setUpProgressFS(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
    504504{
    505505    HRESULT rc;
     
    532532
    533533    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    534                          strDescription,
     534                         bstrDescription,
    535535                         TRUE /* aCancelable */,
    536536                         cOperations, // ULONG cOperations,
    537537                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    538                          strDescription, // CBSTR bstrFirstOperationDescription,
     538                         bstrDescription, // CBSTR bstrFirstOperationDescription,
    539539                         m->ulWeightPerOperation); // ULONG ulFirstOperationWeight,
    540540    return rc;
    541541}
    542542
    543 HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
     543HRESULT Appliance::setUpProgressImportS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
    544544{
    545545    HRESULT rc;
     
    572572
    573573    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    574                          strDescription,
     574                         bstrDescription,
    575575                         TRUE /* aCancelable */,
    576576                         cOperations, // ULONG cOperations,
    577577                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    578                          tr("Init"), // CBSTR bstrFirstOperationDescription,
     578                         Bstr(tr("Init")), // CBSTR bstrFirstOperationDescription,
    579579                         ulInitWeight); // ULONG ulFirstOperationWeight,
    580580    return rc;
    581581}
    582582
    583 HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Utf8Str &strDescription)
     583HRESULT Appliance::setUpProgressWriteS3(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
    584584{
    585585    HRESULT rc;
     
    614614
    615615    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
    616                          strDescription,
     616                         bstrDescription,
    617617                         TRUE /* aCancelable */,
    618618                         cOperations, // ULONG cOperations,
    619619                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
    620                          strDescription, // CBSTR bstrFirstOperationDescription,
     620                         bstrDescription, // CBSTR bstrFirstOperationDescription,
    621621                         ulOVFCreationWeight); // ULONG ulFirstOperationWeight,
    622622    return rc;
     
    837837    task->locInfo = aLocInfo;
    838838
    839     Utf8Str progressDesc = Utf8StrFmt(tr("Import appliance '%s'"),
    840                                       aLocInfo.strPath.c_str());
     839    Bstr progressDesc = BstrFmt(tr("Import appliance '%s'"),
     840                                aLocInfo.strPath.c_str());
    841841
    842842    HRESULT rc = S_OK;
     
    15691569                                                    mhda.lDevice,
    15701570                                                    DeviceType_Floppy,
    1571                                                     NULL);
     1571                                                    Bstr(""));
    15721572                        if (FAILED(rc)) throw rc;
    15731573
     
    16181618                                                    mhda.lDevice,
    16191619                                                    DeviceType_DVD,
    1620                                                     NULL);
     1620                                                    Bstr(""));
    16211621                        if (FAILED(rc)) throw rc;
    16221622
     
    17441744                            rc = mVirtualBox->OpenHardDisk(Bstr(strSrcFilePath),
    17451745                                                           AccessMode_ReadOnly,
    1746                                                            false, NULL, false, NULL,
     1746                                                           false, Bstr(""), false, Bstr(""),
    17471747                                                           srcHdVBox.asOutParam());
    17481748                            if (FAILED(rc)) throw rc;
     
    42814281                                                      IN_BSTR aExtraConfigValue)
    42824282{
     4283    CheckComArgNotNull(aVboxValue);
     4284    CheckComArgNotNull(aExtraConfigValue);
     4285
    42834286    AutoCaller autoCaller(this);
    42844287    if (FAILED(autoCaller.rc())) return autoCaller.rc();
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r26550 r26553  
    584584    if (RT_SUCCESS(rc))
    585585    {
    586         mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
     586        mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
    587587        RTStrFree(pszPropertyName);
    588588    }
     
    591591    if (RT_SUCCESS(rc))
    592592    {
    593         mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
     593        mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
    594594        RTStrFree(pszPropertyName);
    595595    }
     
    598598    if (RT_SUCCESS(rc))
    599599    {
    600         mMachine->SetGuestProperty(Bstr(pszPropertyName), NULL, Bstr("RDONLYGUEST"));
     600        mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
    601601        RTStrFree(pszPropertyName);
    602602    }
     
    11901190
    11911191// static
    1192 DECLCALLBACK(int) Console::doGuestPropNotification(void *pvExtension,
    1193                                                   uint32_t u32Function,
    1194                                                    void *pvParms, uint32_t cbParms)
     1192DECLCALLBACK(int)
     1193Console::doGuestPropNotification(void *pvExtension, 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     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;
     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    }
    12211233    else
    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     }
     1234        rc = VERR_NO_MEMORY;
    12271235    return rc;
    12281236}
     
    25862594{
    25872595#ifdef VBOX_WITH_USB
    2588     CheckComArgStrNotEmptyOrNull(aAddress);
     2596    CheckComArgNotNull(aAddress);
    25892597    CheckComArgOutPointerValid(aDevice);
    25902598
     
    26532661}
    26542662
    2655 STDMETHODIMP Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
    2656 {
    2657     CheckComArgStrNotEmptyOrNull(aName);
    2658     CheckComArgStrNotEmptyOrNull(aHostPath);
     2663STDMETHODIMP
     2664Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
     2665{
     2666    CheckComArgNotNull(aName);
     2667    CheckComArgNotNull(aHostPath);
    26592668
    26602669    AutoCaller autoCaller(this);
     
    27232732STDMETHODIMP Console::RemoveSharedFolder(IN_BSTR aName)
    27242733{
    2725     CheckComArgStrNotEmptyOrNull(aName);
     2734    CheckComArgNotNull(aName);
    27262735
    27272736    AutoCaller autoCaller(this);
     
    27892798    LogFlowThisFunc(("aName='%ls' mMachineState=%08X\n", aName, mMachineState));
    27902799
    2791     CheckComArgStrNotEmptyOrNull(aName);
     2800    CheckComArgNotNull(aName);
    27922801    CheckComArgOutPointerValid(aProgress);
    27932802
     
    77167725         * (i.e. creating a snapshot online)
    77177726         */
    7718         ComAssertThrow(    (!pTask->bstrSavedStateFile.isEmpty() && pTask->fTakingSnapshotOnline)
    7719                         || (pTask->bstrSavedStateFile.isEmpty() && !pTask->fTakingSnapshotOnline),
     7727        ComAssertThrow(    (!pTask->bstrSavedStateFile.isNull() && pTask->fTakingSnapshotOnline)
     7728                        || (pTask->bstrSavedStateFile.isNull() && !pTask->fTakingSnapshotOnline),
    77207729                       rc = E_FAIL);
    77217730
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r26550 r26553  
    31553155                }
    31563156
    3157                 if (!networkName.isEmpty())
     3157                if (!networkName.isNull())
    31583158                {
    31593159                    /*
     
    31623162                     */
    31633163                    ComPtr<IDHCPServer> dhcpServer;
    3164                     hrc = virtualBox->FindDHCPServerByNetworkName(networkName.raw(), dhcpServer.asOutParam());
     3164                    hrc = virtualBox->FindDHCPServerByNetworkName(networkName.mutableRaw(), dhcpServer.asOutParam());
    31653165                    if (SUCCEEDED(hrc))
    31663166                    {
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

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

    r26550 r26553  
    127127
    128128    // redirect the call to IMachine if no additions are installed
    129     if (mData.mAdditionsVersion.isEmpty())
    130         return mParent->machine()->COMGETTER(OSTypeId)(aOSTypeId);
     129    if (mData.mAdditionsVersion.isNull())
     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
    264268    AutoCaller autoCaller(this);
    265269    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    274278
    275279        vmmDev->getVMMDevPort()->pfnSetCredentials(vmmDev->getVMMDevPort(),
    276                                                    Utf8Str(aUserName).raw(),
    277                                                    Utf8Str(aPassword).raw(),
    278                                                    Utf8Str(aDomain).raw(),
    279                                                    u32Flags);
     280            Utf8Str(aUserName).raw(), Utf8Str(aPassword).raw(),
     281            Utf8Str(aDomain).raw(), u32Flags);
    280282        return S_OK;
    281283    }
     
    315317void Guest::setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType)
    316318{
    317     Assert(aVersion.isEmpty() || !aVersion.isEmpty());
     319    Assert(aVersion.isNull() || !aVersion.isEmpty());
    318320
    319321    AutoCaller autoCaller(this);
     
    323325
    324326    mData.mAdditionsVersion = aVersion;
    325     mData.mAdditionsActive = !aVersion.isEmpty();
    326 
    327     mData.mOSTypeId = Global::OSTypeId(aOsType);
     327    mData.mAdditionsActive = !aVersion.isNull();
     328
     329    mData.mOSTypeId = Global::OSTypeId (aOsType);
    328330}
    329331
  • trunk/src/VBox/Main/HostImpl.cpp

    r26550 r26553  
    12901290STDMETHODIMP Host::FindHostDVDDrive(IN_BSTR aName, IMedium **aDrive)
    12911291{
    1292     CheckComArgStrNotEmptyOrNull(aName);
     1292    CheckComArgNotNull(aName);
    12931293    CheckComArgOutPointerValid(aDrive);
    12941294
     
    13171317STDMETHODIMP Host::FindHostFloppyDrive(IN_BSTR aName, IMedium **aDrive)
    13181318{
    1319     CheckComArgStrNotEmptyOrNull(aName);
     1319    CheckComArgNotNull(aName);
    13201320    CheckComArgOutPointerValid(aDrive);
    13211321
     
    14511451{
    14521452#ifdef VBOX_WITH_USB
    1453     CheckComArgStrNotEmptyOrNull(aAddress);
     1453    CheckComArgNotNull(aAddress);
    14541454    CheckComArgOutPointerValid(aDevice);
    14551455
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r26550 r26553  
    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()));
     61                      aInterfaceName.raw(), aGuid.toString().raw()));
    6262
    6363    ComAssertRet(aInterfaceName, E_INVALIDARG);
     
    423423            {
    424424                m.realIPAddress = 0;
    425                 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), NULL)))
     425                if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPAddress", mInterfaceName.raw())), Bstr(""))))
    426426                    return E_FAIL;
    427                 if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), NULL)))
     427                if (FAILED(mVBox->SetExtraData(Bstr(Utf8StrFmt("HostOnly/%ls/IPNetMask", mInterfaceName.raw())), Bstr(""))))
    428428                    return E_FAIL;
    429429                return S_OK;
  • trunk/src/VBox/Main/MachineImpl.cpp

    r26550 r26553  
    697697STDMETHODIMP Machine::COMSETTER(Name)(IN_BSTR aName)
    698698{
    699     if (!aName || !*aName)
     699    CheckComArgNotNull(aName);
     700
     701    if (!*aName)
    700702        return setError(E_INVALIDARG,
    701703                        tr("Machine name cannot be empty"));
     
    777779STDMETHODIMP Machine::COMSETTER(OSTypeId)(IN_BSTR aOSTypeId)
    778780{
    779     CheckComArgStrNotEmptyOrNull(aOSTypeId);
     781    CheckComArgNotNull(aOSTypeId);
    780782
    781783    AutoCaller autoCaller(this);
     
    19281930    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    19291931
    1930     mData->mSession.mType.cloneTo(aSessionType);
     1932    if (mData->mSession.mType.isNull())
     1933        Bstr("").cloneTo(aSessionType);
     1934    else
     1935        mData->mSession.mType.cloneTo(aSessionType);
    19311936
    19321937    return S_OK;
     
    19851990    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    19861991
    1987     mSSData->mStateFilePath.cloneTo(aStateFilePath);
     1992    if (mSSData->mStateFilePath.isEmpty())
     1993        Bstr("").cloneTo(aStateFilePath);
     1994    else
     1995        mSSData->mStateFilePath.cloneTo(aStateFilePath);
    19881996
    19891997    return S_OK;
     
    21262134}
    21272135
    2128 STDMETHODIMP Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
    2129 {
     2136STDMETHODIMP
     2137Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
     2138{
     2139    CheckComArgNotNull(aPatterns);
    21302140    AutoCaller autoCaller(this);
    21312141    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    23902400                                   IN_BSTR aId)
    23912401{
    2392     CheckComArgStrNotEmptyOrNull(aControllerName);
    2393 
    23942402    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aType=%d aId=\"%ls\"\n",
    23952403                     aControllerName, aControllerPort, aDevice, aType, aId));
     2404
     2405    CheckComArgNotNull(aControllerName);
     2406    CheckComArgNotNull(aId);
    23962407
    23972408    AutoCaller autoCaller(this);
     
    28152826                                   LONG aDevice)
    28162827{
    2817     CheckComArgStrNotEmptyOrNull(aControllerName);
     2828    CheckComArgNotNull(aControllerName);
    28182829
    28192830    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld\n",
     
    29002911                                        LONG aDevice, BOOL aPassthrough)
    29012912{
    2902     CheckComArgStrNotEmptyOrNull(aControllerName);
     2913    CheckComArgNotNull(aControllerName);
    29032914
    29042915    LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%ld aDevice=%ld aPassthrough=%d\n",
     
    29542965                     aControllerName, aControllerPort, aDevice, aForce));
    29552966
    2956     CheckComArgStrNotEmptyOrNull(aControllerName);
     2967    CheckComArgNotNull(aControllerName);
     2968    CheckComArgNotNull(aId);
    29572969
    29582970    AutoCaller autoCaller(this);
     
    30943106                     aControllerName, aControllerPort, aDevice));
    30953107
    3096     CheckComArgStrNotEmptyOrNull(aControllerName);
     3108    CheckComArgNotNull(aControllerName);
    30973109    CheckComArgOutPointerValid(aMedium);
    30983110
     
    31933205                                   BSTR *aValue)
    31943206{
    3195     CheckComArgStrNotEmptyOrNull(aKey);
     3207    CheckComArgNotNull(aKey);
    31963208    CheckComArgOutPointerValid(aValue);
    31973209
     
    32003212
    32013213    /* start with nothing found */
    3202     Bstr bstrResult;
     3214    Bstr bstrResult("");
    32033215
    32043216    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    32203232STDMETHODIMP Machine::SetExtraData(IN_BSTR aKey, IN_BSTR aValue)
    32213233{
    3222     CheckComArgStrNotEmptyOrNull(aKey);
     3234    CheckComArgNotNull(aKey);
    32233235
    32243236    AutoCaller autoCaller(this);
     
    32513263        // lock to copy the list of callbacks to invoke
    32523264        Bstr error;
    3253         Bstr bstrValue(aValue);
     3265        Bstr bstrValue;
     3266        if (aValue)
     3267            bstrValue = aValue;
     3268        else
     3269            bstrValue = (const char *)"";
    32543270
    32553271        if (!mParent->onExtraDataCanChange(mData->mUuid, aKey, bstrValue, error))
    32563272        {
    32573273            const char *sep = error.isEmpty() ? "" : ": ";
    3258             CBSTR err = error.raw();
     3274            CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw();
    32593275            LogWarningFunc(("Someone vetoed! Change refused%s%ls\n",
    32603276                            sep, err));
     
    34403456STDMETHODIMP Machine::FindSnapshot(IN_BSTR aName, ISnapshot **aSnapshot)
    34413457{
    3442     CheckComArgStrNotEmptyOrNull(aName);
     3458    CheckComArgNotNull(aName);
    34433459    CheckComArgOutPointerValid(aSnapshot);
    34443460
     
    34663482STDMETHODIMP Machine::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
    34673483{
    3468     CheckComArgStrNotEmptyOrNull(aName);
    3469     CheckComArgStrNotEmptyOrNull(aHostPath);
     3484    CheckComArgNotNull(aName);
     3485    CheckComArgNotNull(aHostPath);
    34703486
    34713487    AutoCaller autoCaller(this);
     
    35013517STDMETHODIMP Machine::RemoveSharedFolder(IN_BSTR aName)
    35023518{
    3503     CheckComArgStrNotEmptyOrNull(aName);
     3519    CheckComArgNotNull(aName);
    35043520
    35053521    AutoCaller autoCaller(this);
     
    35913607    ReturnComNotImplemented();
    35923608#else // VBOX_WITH_GUEST_PROPS
    3593     CheckComArgStrNotEmptyOrNull(aName);
     3609    CheckComArgNotNull(aName);
    35943610    CheckComArgOutPointerValid(aValue);
    35953611    CheckComArgOutPointerValid(aTimestamp);
     
    36703686    using namespace guestProp;
    36713687
    3672     CheckComArgStrNotEmptyOrNull(aName);
     3688    CheckComArgNotNull(aName);
     3689    CheckComArgNotNull(aValue);
    36733690    if ((aFlags != NULL) && !VALID_PTR(aFlags))
    36743691        return E_INVALIDARG;
     
    36793696    {
    36803697        Utf8Str utf8Name(aName);
    3681         Utf8Str utf8Value(aValue);
    36823698        Utf8Str utf8Flags(aFlags);
    36833699
     
    37353751            if (found && SUCCEEDED(rc))
    37363752            {
    3737                 if (utf8Value.length())
     3753                if (*aValue)
    37383754                {
    37393755                    RTTIMESPEC time;
    3740                     property.strValue = utf8Value;
     3756                    property.strValue = aValue;
    37413757                    property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
    37423758                    if (aFlags != NULL)
     
    37453761                }
    37463762            }
    3747             else if (SUCCEEDED(rc) && utf8Value.length())
     3763            else if (SUCCEEDED(rc) && *aValue)
    37483764            {
    37493765                RTTIMESPEC time;
     
    37513767                mHWData.backup();
    37523768                property.strName = aName;
    3753                 property.strValue = utf8Value;
     3769                property.strValue = aValue;
    37543770                property.mTimestamp = RTTimeSpecGetNano(RTTimeNow(&time));
    37553771                property.mFlags = fFlags;
     
    37693785        else
    37703786        {
    3771             ComPtr<IInternalSessionControl> directControl = mData->mSession.mDirectControl;
     3787            ComPtr<IInternalSessionControl> directControl =
     3788                mData->mSession.mDirectControl;
    37723789
    37733790            /* just be on the safe side when calling another process */
     
    37803797            else
    37813798                rc = directControl->AccessGuestProperty(aName,
    3782                                                         aValue,
     3799                                                        *aValue ? aValue : NULL,  /** @todo Fix when adding DeleteGuestProperty(), see defect. */
    37833800                                                        aFlags,
    37843801                                                        true /* isSetter */,
     
    39143931                     aControllerName, aControllerPort, aDevice));
    39153932
    3916     CheckComArgStrNotEmptyOrNull(aControllerName);
     3933    CheckComArgNotNull(aControllerName);
    39173934    CheckComArgOutPointerValid(aAttachment);
    39183935
     
    89308947#endif /* VBOX_WITH_USB */
    89318948
    8932     if (!mData->mSession.mType.isEmpty())
     8949    if (!mData->mSession.mType.isNull())
    89338950    {
    89348951        /* mType is not null when this machine's process has been started by
     
    96389655    using namespace guestProp;
    96399656
    9640     CheckComArgStrNotEmptyOrNull(aName);
    9641     if (aValue && *aValue && (!VALID_PTR(aValue) || !VALID_PTR(aFlags)))
     9657    CheckComArgNotNull(aName);
     9658    if (aValue != NULL && (!VALID_PTR(aValue) || !VALID_PTR(aFlags)))
    96429659        return E_POINTER;  /* aValue can be NULL to indicate deletion */
    96439660
  • trunk/src/VBox/Main/Matching.cpp

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

    r26550 r26553  
    13611361    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    13621362
    1363     m->strDescription.cloneTo(aDescription);
     1363    if (m->strDescription.isEmpty())
     1364        Bstr("").cloneTo(aDescription);
     1365    else
     1366        m->strDescription.cloneTo(aDescription);
    13641367
    13651368    return S_OK;
     
    13681371STDMETHODIMP Medium::COMSETTER(Description)(IN_BSTR aDescription)
    13691372{
     1373    CheckComArgNotNull(aDescription);
     1374
    13701375    AutoCaller autoCaller(this);
    13711376    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     
    14101415STDMETHODIMP Medium::COMSETTER(Location)(IN_BSTR aLocation)
    14111416{
    1412     CheckComArgStrNotEmptyOrNull(aLocation);
     1417    CheckComArgNotNull(aLocation);
    14131418
    14141419    AutoCaller autoCaller(this);
     
    17201725    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    17211726
    1722     m->strLastAccessError.cloneTo(aLastAccessError);
     1727    if (m->strLastAccessError.isEmpty())
     1728        Bstr("").cloneTo(aLastAccessError);
     1729    else
     1730        m->strLastAccessError.cloneTo(aLastAccessError);
    17231731
    17241732    return S_OK;
     
    20942102                        tr("Property '%ls' does not exist"), aName);
    20952103
    2096     it->second.cloneTo(aValue);
     2104    if (it->second.isEmpty())
     2105        Bstr("").cloneTo(aValue);
     2106    else
     2107        it->second.cloneTo(aValue);
    20972108
    20982109    return S_OK;
     
    21582169    {
    21592170        it->first.cloneTo(&names[i]);
    2160         it->second.cloneTo(&values[i]);
     2171        if (it->second.isEmpty())
     2172            Bstr("").cloneTo(&values[i]);
     2173        else
     2174            it->second.cloneTo(&values[i]);
    21612175        ++ i;
    21622176    }
     
    23482362
    23492363STDMETHODIMP Medium::CloneTo(IMedium *aTarget,
    2350                              MediumVariant_T aVariant,
    2351                              IMedium *aParent,
    2352                              IProgress **aProgress)
     2364                              MediumVariant_T aVariant,
     2365                              IMedium *aParent,
     2366                              IProgress **aProgress)
    23532367{
    23542368    CheckComArgNotNull(aTarget);
     
    30763090    {
    30773091        /* only save properties that have non-default values */
    3078         if (!it->second.isEmpty())
     3092        if (!it->second.isNull())
    30793093        {
    30803094            Utf8Str name = it->first;
     
    48444858
    48454859    /* we interpret null values as "no value" in Medium */
    4846     if (it->second.isEmpty())
     4860    if (it->second.isNull())
    48474861        return VERR_CFGM_VALUE_NOT_FOUND;
    48484862
     
    48714885
    48724886    /* we interpret null values as "no value" in Medium */
    4873     if (it->second.isEmpty())
     4887    if (it->second.isNull())
    48744888        return VERR_CFGM_VALUE_NOT_FOUND;
    48754889
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r26550 r26553  
    10261026        case NetworkAttachmentType_NAT:
    10271027            mData->mNATNetwork = data.strName;
     1028            if (mData->mNATNetwork.isNull())
     1029                mData->mNATNetwork = "";
    10281030            rc = AttachToNAT();
    10291031            if (FAILED(rc)) return rc;
     
    10391041        case NetworkAttachmentType_Internal:
    10401042            mData->mInternalNetwork = data.strName;
    1041             Assert(!mData->mInternalNetwork.isEmpty());
     1043            Assert(!mData->mInternalNetwork.isNull());
    10421044
    10431045            rc = AttachToInternalNetwork();
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r26550 r26553  
    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                                     const Utf8Str &strDescription,
    105                                     OUT_GUID aId /* = NULL */)
     103                            IUnknown *aInitiator,
     104                            CBSTR aDescription, OUT_GUID aId /* = NULL */)
    106105{
    107106    /* Guarantees subclasses call this method at the proper time */
     
    117116#endif
    118117
    119     AssertReturn(!strDescription.isEmpty(), E_INVALIDARG);
     118    AssertReturn(aDescription, E_INVALIDARG);
    120119
    121120#if !defined (VBOX_COM_INPROC)
     
    144143#endif
    145144
    146     unconst(m_strDescription) = strDescription;
     145    unconst(mDescription) = aDescription;
    147146
    148147    return S_OK;
     
    221220
    222221    /* mDescription is constant during life time, no need to lock */
    223     m_strDescription.cloneTo(aDescription);
     222    mDescription.cloneTo(aDescription);
    224223
    225224    return S_OK;
     
    466465    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    467466
    468     m_strOperationDescription.cloneTo(aOperationDescription);
     467    m_bstrOperationDescription.cloneTo(aOperationDescription);
    469468
    470469    return S_OK;
     
    664663#endif
    665664                        IUnknown *aInitiator,
    666                         const Utf8Str &strDescription,
     665                        CBSTR aDescription,
    667666                        BOOL aCancelable,
    668667                        ULONG cOperations,
    669668                        ULONG ulTotalOperationsWeight,
    670                         const Utf8Str &strFirstOperationDescription,
     669                        CBSTR bstrFirstOperationDescription,
    671670                        ULONG ulFirstOperationWeight,
    672671                        OUT_GUID aId /* = NULL */)
    673672{
    674     LogFlowThisFunc(("aDescription=\"%s\", cOperations=%d, ulTotalOperationsWeight=%d, strFirstOperationDescription=\"%s\", ulFirstOperationWeight=%d\n",
    675                      strDescription.c_str(),
     673    LogFlowThisFunc(("aDescription=\"%ls\", cOperations=%d, ulTotalOperationsWeight=%d, bstrFirstOperationDescription=\"%ls\", ulFirstOperationWeight=%d\n",
     674                     aDescription,
    676675                     cOperations,
    677676                     ulTotalOperationsWeight,
    678                      strFirstOperationDescription.c_str(),
     677                     bstrFirstOperationDescription,
    679678                     ulFirstOperationWeight));
    680679
    681     AssertReturn(!strFirstOperationDescription.isEmpty(), E_INVALIDARG);
     680    AssertReturn(bstrFirstOperationDescription, E_INVALIDARG);
    682681    AssertReturn(ulTotalOperationsWeight >= 1, E_INVALIDARG);
    683682
     
    688687    HRESULT rc = S_OK;
    689688
    690     rc = ProgressBase::protectedInit(autoInitSpan,
     689    rc = ProgressBase::protectedInit (autoInitSpan,
    691690#if !defined (VBOX_COM_INPROC)
    692                                      aParent,
     691                                      aParent,
    693692#endif
    694                                      aInitiator,
    695                                      strDescription,
    696                                      aId);
     693                                      aInitiator, aDescription, aId);
    697694    if (FAILED(rc)) return rc;
    698695
     
    703700    m_ulOperationsCompletedWeight = 0;
    704701    m_ulCurrentOperation = 0;
    705     m_strOperationDescription = strFirstOperationDescription;
     702    m_bstrOperationDescription = bstrFirstOperationDescription;
    706703    m_ulCurrentOperationWeight = ulFirstOperationWeight;
    707704    m_ulOperationPercent = 0;
     
    736733HRESULT Progress::init(BOOL aCancelable,
    737734                       ULONG aOperationCount,
    738                        const Utf8Str &strOperationDescription)
    739 {
    740     LogFlowThisFunc(("aOperationDescription=\"%s\"\n", strOperationDescription.c_str()));
     735                       CBSTR aOperationDescription)
     736{
     737    LogFlowThisFunc(("aOperationDescription=\"%ls\"\n", aOperationDescription));
    741738
    742739    /* Enclose the state transition NotReady->InInit->Ready */
     
    746743    HRESULT rc = S_OK;
    747744
    748     rc = ProgressBase::protectedInit(autoInitSpan);
     745    rc = ProgressBase::protectedInit (autoInitSpan);
    749746    if (FAILED(rc)) return rc;
    750747
     
    757754    m_ulOperationsCompletedWeight = 0;
    758755    m_ulCurrentOperation = 0;
    759     m_strOperationDescription = strOperationDescription;
     756    m_bstrOperationDescription = aOperationDescription;
    760757    m_ulCurrentOperationWeight = 1;
    761758    m_ulOperationPercent = 0;
    762759
    763     int vrc = RTSemEventMultiCreate(&mCompletedSem);
    764     ComAssertRCRet(vrc, E_FAIL);
    765 
    766     RTSemEventMultiReset(mCompletedSem);
     760    int vrc = RTSemEventMultiCreate (&mCompletedSem);
     761    ComAssertRCRet (vrc, E_FAIL);
     762
     763    RTSemEventMultiReset (mCompletedSem);
    767764
    768765    /* Confirm a successful initialization when it's the case */
     
    790787    if (mWaitersCount > 0)
    791788    {
    792         LogFlow (("WARNING: There are still %d threads waiting for '%s' completion!\n",
    793                   mWaitersCount, m_strDescription.c_str()));
    794         RTSemEventMultiSignal(mCompletedSem);
     789        LogFlow (("WARNING: There are still %d threads waiting for '%ls' completion!\n",
     790                  mWaitersCount, mDescription.raw()));
     791        RTSemEventMultiSignal (mCompletedSem);
    795792    }
    796793
    797     RTSemEventMultiDestroy(mCompletedSem);
    798 
    799     ProgressBase::protectedUninit(autoUninitSpan);
     794    RTSemEventMultiDestroy (mCompletedSem);
     795
     796    ProgressBase::protectedUninit (autoUninitSpan);
    800797}
    801798
     
    10071004    m_ulOperationsCompletedWeight += m_ulCurrentOperationWeight;
    10081005
    1009     m_strOperationDescription = bstrNextOperationDescription;
     1006    m_bstrOperationDescription = bstrNextOperationDescription;
    10101007    m_ulCurrentOperationWeight = ulNextOperationsWeight;
    10111008    m_ulOperationPercent = 0;
    10121009
    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));
     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));
    10151012
    10161013    /* wake up all waiting threads */
     
    12891286
    12901287    m_ulCurrentOperation = 0;
    1291     Bstr bstrOperationDescription;
    1292     rc = mProgresses[0]->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam());
    1293     m_strOperationDescription = bstrOperationDescription;
     1288    rc = mProgresses[0]->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
    12941289    if (FAILED(rc)) return rc;
    12951290
     
    17911786        {
    17921787            m_ulCurrentOperation = mCompletedOperations + operation;
    1793             Bstr bstrOperationDescription;
    1794             rc = progress->COMGETTER(OperationDescription)(bstrOperationDescription.asOutParam());
    1795             m_strOperationDescription = bstrOperationDescription;
     1788            rc = progress->COMGETTER(OperationDescription) (
     1789                m_bstrOperationDescription.asOutParam());
    17961790        }
    17971791    }
  • trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp

    r26550 r26553  
    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.toUtf16()).cloneTo(aId);
     144    Bstr(mData.id).cloneTo(aId);
    145145
    146146    return S_OK;
  • trunk/src/VBox/Main/SessionImpl.cpp

    r26550 r26553  
    682682}
    683683
    684 STDMETHODIMP 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)
     684STDMETHODIMP Session::AccessGuestProperty(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags,
     685                                          BOOL aIsSetter, BSTR *aRetValue, ULONG64 *aRetTimestamp, BSTR *aRetFlags)
    691686{
    692687#ifdef VBOX_WITH_GUEST_PROPS
     
    699694                        Global::stringifySessionState(mState));
    700695    AssertReturn(mType == SessionType_Direct, VBOX_E_INVALID_OBJECT_STATE);
    701     CheckComArgStrNotEmptyOrNull(aName);
     696    CheckComArgNotNull(aName);
    702697    if (!aIsSetter && !VALID_PTR(aRetValue))
    703698        return E_POINTER;
  • trunk/src/VBox/Main/SharedFolderImpl.cpp

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

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

    r26550 r26553  
    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();
    827          ++it)
     826         it != mMediumFormats.end(); ++ it)
    828827    {
    829828        /* MediumFormat is all const, no need to lock */
    830829
    831         if ((*it)->id().compare(aFormat, Bstr::CaseInsensitive) == 0)
     830        if ((*it)->id().compareIgnoreCase (aFormat) == 0)
    832831        {
    833832            format = *it;
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r26550 r26553  
    11101110    rc = aUSBDevice->COMGETTER(Manufacturer) (manufacturer.asOutParam());
    11111111    ComAssertComRCRet(rc, false);
    1112     if (!manufacturer.isEmpty())
     1112    if (!manufacturer.isNull())
    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.isEmpty())
     1118    if (!product.isNull())
    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.isEmpty())
     1124    if (!serialNumber.isNull())
    11251125        USBFilterSetStringExact (&dev, USBFILTERIDX_SERIAL_NUMBER_STR, Utf8Str(serialNumber).c_str(), true);
    11261126
  • trunk/src/VBox/Main/USBDeviceImpl.cpp

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

    r26550 r26553  
    810810 */
    811811/* static */
    812 HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal(HRESULT aResultCode,
    813                                                              const GUID &aIID,
    814                                                              const Bstr &aComponent,
    815                                                              const Bstr &aText,
    816                                                              bool aWarning,
    817                                                              bool aLogIt)
     812HRESULT VirtualBoxSupportErrorInfoImplBase::setErrorInternal (
     813    HRESULT aResultCode, const GUID &aIID,
     814    const Bstr &aComponent, const Bstr &aText,
     815    bool aWarning, bool aLogIt)
    818816{
    819817    /* whether multi-error mode is turned on */
     
    827825
    828826    /* these are mandatory, others -- not */
    829     AssertReturn(    (!aWarning && FAILED(aResultCode))
    830                   || (aWarning && aResultCode != S_OK),
     827    AssertReturn((!aWarning && FAILED(aResultCode)) ||
     828                  (aWarning && aResultCode != S_OK),
    831829                  E_FAIL);
    832830    AssertReturn(!aText.isEmpty(), E_FAIL);
     
    916914
    917915            /* set the current error info and preserve the previous one if any */
    918             rc = info->init(aResultCode, aIID, aComponent.raw(), aText.raw(), curInfo);
     916            rc = info->init (aResultCode, aIID, aComponent, aText, curInfo);
    919917            if (FAILED(rc)) break;
    920918
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r26550 r26553  
    302302    LogFlowThisFuncEnter();
    303303
    304     if (sVersion.isEmpty())
     304    if (sVersion.isNull())
    305305        sVersion = VBOX_VERSION_STRING;
    306306    sRevision = RTBldCfgRevision();
    307     if (sPackageType.isEmpty())
     307    if (sPackageType.isNull())
    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.c_str()))
     981        if (RTFileExists(fullName.raw()))
    982982        {
    983983            *aResult = TRUE;
    984984             if (aFile)
    985                 fullName.cloneTo(aFile);
     985                Utf8Str(fullName).cloneTo(aFile);
    986986            break;
    987987        }
     
    993993                              RTPATH_DELIMITER,
    994994                              firmwareDesc[i].fileName);
    995         if (RTFileExists(fullName.c_str()))
     995        if (RTFileExists(fullName.raw()))
    996996        {
    997997            *aResult = TRUE;
    998998            if (aFile)
    999                 fullName.cloneTo(aFile);
     999                Utf8Str(fullName).cloneTo(aFile);
    10001000            break;
    10011001        }
     
    12251225    LogFlowThisFunc(("aName=\"%ls\", aMachine={%p}\n", aName, aMachine));
    12261226
    1227     CheckComArgStrNotEmptyOrNull(aName);
     1227    CheckComArgNotNull(aName);
    12281228    CheckComArgOutSafeArrayPointerValid(aMachine);
    12291229
     
    13461346                                      IMedium **aHardDisk)
    13471347{
    1348     CheckComArgStrNotEmptyOrNull(aLocation);
     1348    CheckComArgNotNull(aLocation);
     1349    CheckComArgNotNull(aImageId);
     1350    CheckComArgNotNull(aParentId);
    13491351    CheckComArgOutSafeArrayPointerValid(aHardDisk);
    13501352
     
    14211423                                      IMedium **aHardDisk)
    14221424{
    1423     CheckComArgStrNotEmptyOrNull(aLocation);
     1425    CheckComArgNotNull(aLocation);
    14241426    CheckComArgOutSafeArrayPointerValid(aHardDisk);
    14251427
     
    14281430
    14291431    ComObjPtr<Medium> hardDisk;
    1430     Utf8Str strLocation(aLocation);
    1431     HRESULT rc = findHardDisk(NULL, &strLocation, true /* setError */, &hardDisk);
     1432    HRESULT rc = findHardDisk(NULL, aLocation, true /* setError */, &hardDisk);
    14321433
    14331434    /* the below will set *aHardDisk to NULL if hardDisk is null */
     
    14781479
    14791480/** @note Locks objects! */
    1480 STDMETHODIMP VirtualBox::GetDVDImage(IN_BSTR aId, IMedium **aDVDImage)
     1481STDMETHODIMP VirtualBox::GetDVDImage (IN_BSTR aId, IMedium **aDVDImage)
    14811482{
    14821483    CheckComArgOutSafeArrayPointerValid(aDVDImage);
     
    14961497
    14971498/** @note Locks objects! */
    1498 STDMETHODIMP VirtualBox::FindDVDImage(IN_BSTR aLocation, IMedium **aDVDImage)
    1499 {
    1500     CheckComArgStrNotEmptyOrNull(aLocation);
     1499STDMETHODIMP VirtualBox::FindDVDImage (IN_BSTR aLocation, IMedium **aDVDImage)
     1500{
     1501    CheckComArgNotNull(aLocation);
    15011502    CheckComArgOutSafeArrayPointerValid(aDVDImage);
    15021503
     
    15051506
    15061507    ComObjPtr<Medium> image;
    1507     Utf8Str strLocation(aLocation);
    1508     HRESULT rc = findDVDImage(NULL, &strLocation, true /* setError */, &image);
     1508    HRESULT rc = findDVDImage (NULL, aLocation, 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     CheckComArgStrNotEmptyOrNull(aLocation);
     1577STDMETHODIMP VirtualBox::FindFloppyImage (IN_BSTR aLocation,
     1578                                          IMedium **aFloppyImage)
     1579{
     1580    CheckComArgNotNull(aLocation);
    15811581    CheckComArgOutSafeArrayPointerValid(aFloppyImage);
    15821582
     
    15851585
    15861586    ComObjPtr<Medium> image;
    1587     Utf8Str strLocation(aLocation);
    1588     HRESULT rc = findFloppyImage(NULL, &strLocation, true /* setError */, &image);
     1587    HRESULT rc = findFloppyImage(NULL, aLocation, true /* setError */, &image);
    15891588
    15901589    /* the below will set *aFloppyImage to NULL if img is null */
     
    15951594
    15961595/** @note Locks this object for reading. */
    1597 STDMETHODIMP VirtualBox::GetGuestOSType(IN_BSTR aId, IGuestOSType **aType)
     1596STDMETHODIMP VirtualBox::GetGuestOSType (IN_BSTR aId, IGuestOSType **aType)
    15981597{
    15991598    /* Old ID to new ID conversion table. See r39691 for a source */
     
    16161615    };
    16171616
    1618     CheckComArgNotNull(aType);
     1617    CheckComArgNotNull (aType);
    16191618
    16201619    AutoCaller autoCaller(this);
     
    16401639    {
    16411640        const Bstr &typeId = (*it)->id();
    1642         if (typeId.compare(id, Bstr::CaseInsensitive) == 0)
     1641        AssertMsg (!!typeId, ("ID must not be NULL"));
     1642        if (typeId.compareIgnoreCase (id) == 0)
    16431643        {
    16441644            (*it).queryInterfaceTo(aType);
     
    17091709                                      BSTR *aValue)
    17101710{
    1711     CheckComArgStrNotEmptyOrNull(aKey);
     1711    CheckComArgNotNull(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     CheckComArgStrNotEmptyOrNull(aKey);
     1737    CheckComArgNotNull(aKey);
    17381738
    17391739    AutoCaller autoCaller(this);
     
    17661766        // lock to copy the list of callbacks to invoke
    17671767        Bstr error;
    1768         Bstr bstrValue(aValue);
     1768        Bstr bstrValue;
     1769        if (aValue)
     1770            bstrValue = aValue;
     1771        else
     1772            bstrValue = (const char *)"";
    17691773
    17701774        if (!onExtraDataCanChange(Guid::Empty, aKey, bstrValue, error))
    17711775        {
    17721776            const char *sep = error.isEmpty() ? "" : ": ";
    1773             CBSTR err = error.raw();
     1777            CBSTR err = error.isNull() ? (CBSTR) L"" : error.raw();
    17741778            LogWarningFunc(("Someone vetoed! Change refused%s%ls\n",
    17751779                            sep, err));
     
    18621866    LogRel(("remotesession=%s\n", Utf8Str(aMachineId).c_str()));
    18631867
    1864     CheckComArgStrNotEmptyOrNull(aMachineId);
     1868    CheckComArgNotNull(aMachineId);
    18651869    CheckComArgNotNull(aSession);
     1870    CheckComArgNotNull(aType);
    18661871    CheckComArgOutSafeArrayPointerValid(aProgress);
    18671872
     
    18921897    ComObjPtr<Progress> progress;
    18931898    progress.createObject();
    1894     progress->init(this,
    1895                    static_cast<IMachine*>(machine),
    1896                    tr("Spawning session"),
    1897                    FALSE /* aCancelable */);
     1899    progress->init (this, static_cast <IMachine *> (machine),
     1900                    Bstr (tr ("Spawning session")),
     1901                    FALSE /* aCancelable */);
    18981902
    18991903    rc = machine->openRemoteSession (control, aType, aEnvironment, progress);
     
    24302434            case DataChanged:
    24312435                LogFlow (("OnMachineDataChange: id={%RTuuid}\n", id.ptr()));
    2432                 aCallback->OnMachineDataChange(id.toUtf16());
     2436                aCallback->OnMachineDataChange (id.toUtf16());
    24332437                break;
    24342438
     
    24362440                LogFlow (("OnMachineStateChange: id={%RTuuid}, state=%d\n",
    24372441                          id.ptr(), state));
    2438                 aCallback->OnMachineStateChange(id.toUtf16(), state);
     2442                aCallback->OnMachineStateChange (id.toUtf16(), state);
    24392443                break;
    24402444
     
    24422446                LogFlow (("OnMachineRegistered: id={%RTuuid}, registered=%d\n",
    24432447                          id.ptr(), registered));
    2444                 aCallback->OnMachineRegistered(id.toUtf16(), registered);
     2448                aCallback->OnMachineRegistered (id.toUtf16(), registered);
    24452449                break;
    24462450        }
     
    24932497    while ((it != list.end()) && allowChange)
    24942498    {
    2495         HRESULT rc = (*it++)->OnExtraDataCanChange(id,
    2496                                                    aKey,
    2497                                                    aValue,
    2498                                                    aError.asOutParam(),
    2499                                                    &allowChange);
     2499        HRESULT rc = (*it++)->OnExtraDataCanChange (id, aKey, aValue,
     2500                                                    aError.asOutParam(), &allowChange);
    25002501        if (FAILED(rc))
    25012502        {
     
    25262527        LogFlow (("OnExtraDataChange: machineId={%RTuuid}, key='%ls', val='%ls'\n",
    25272528                  machineId.ptr(), key.raw(), val.raw()));
    2528         aCallback->OnExtraDataChange(machineId.toUtf16(), key, val);
     2529        aCallback->OnExtraDataChange (machineId.toUtf16(), key, val);
    25292530    }
    25302531
     
    25532554{
    25542555    SessionEvent (VirtualBox *aVB, const Guid &aMachineId, SessionState_T aState)
    2555         : CallbackEvent (aVB), machineId(aMachineId), sessionState (aState)
     2556        : CallbackEvent (aVB), machineId (aMachineId), sessionState (aState)
    25562557        {}
    25572558
     
    25602561        LogFlow (("OnSessionStateChange: machineId={%RTuuid}, sessionState=%d\n",
    25612562                  machineId.ptr(), sessionState));
    2562         aCallback->OnSessionStateChange(machineId.toUtf16(), sessionState);
     2563        aCallback->OnSessionStateChange (machineId.toUtf16(), sessionState);
    25632564    }
    25642565
     
    25972598                LogFlow (("OnSnapshotTaken: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    25982599                          machineId.ptr(), snapshotId.ptr()));
    2599                 aCallback->OnSnapshotTaken(mid, sid);
     2600                aCallback->OnSnapshotTaken (mid, sid);
    26002601                break;
    26012602
     
    26032604                LogFlow (("OnSnapshotDiscarded: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    26042605                          machineId.ptr(), snapshotId.ptr()));
    2605                 aCallback->OnSnapshotDiscarded(mid, sid);
     2606                aCallback->OnSnapshotDiscarded (mid, sid);
    26062607                break;
    26072608
     
    26092610                LogFlow (("OnSnapshotChange: machineId={%RTuuid}, snapshotId={%RTuuid}\n",
    26102611                          machineId.ptr(), snapshotId.ptr()));
    2611                 aCallback->OnSnapshotChange(mid, sid);
     2612                aCallback->OnSnapshotChange (mid, sid);
    26122613                break;
    26132614        }
     
    26602661        LogFlow(("OnGuestPropertyChange: machineId={%RTuuid}, name='%ls', value='%ls', flags='%ls'\n",
    26612662                 machineId.ptr(), name.raw(), value.raw(), flags.raw()));
    2662         aCallback->OnGuestPropertyChange(machineId.toUtf16(), name, value, flags);
     2663        aCallback->OnGuestPropertyChange (machineId.toUtf16(), name, value, flags);
    26632664    }
    26642665
     
    27962797 *
    27972798 * @param aId           ID of the hard disk (unused when NULL).
    2798  * @param pstrLocation  Full location specification (unused NULL).
     2799 * @param aLocation     Full location specification (unused NULL).
    27992800 * @param aSetError     If @c true , the appropriate error info is set in case
    28002801 *                      when the hard disk is not found.
     
    28062807 */
    28072808HRESULT VirtualBox::findHardDisk(const Guid *aId,
    2808                                  const Utf8Str *pstrLocation,
     2809                                 CBSTR aLocation,
    28092810                                 bool aSetError,
    28102811                                 ComObjPtr<Medium> *aHardDisk /*= NULL*/)
    28112812{
    2812     AssertReturn(aId || pstrLocation, E_INVALIDARG);
     2813    AssertReturn(aId || aLocation, E_INVALIDARG);
    28132814
    28142815    // we use the hard disks map, but it is protected by the
     
    28302831    /* then iterate and search by location */
    28312832    int result = -1;
    2832     if (pstrLocation)
    2833     {
     2833    if (aLocation)
     2834    {
     2835        Utf8Str location = aLocation;
     2836
    28342837        for (HardDiskMap::const_iterator it = m->mapHardDisks.begin();
    28352838             it != m->mapHardDisks.end();
     
    28382841            const ComObjPtr<Medium> &hd = (*it).second;
    28392842
    2840             HRESULT rc = hd->compareLocationTo(pstrLocation->c_str(), result);
     2843            HRESULT rc = hd->compareLocationTo(location.c_str(), result);
    28412844            if (FAILED(rc)) return rc;
    28422845
     
    28612864        else
    28622865            setError(rc,
    2863                      tr("Could not find a hard disk with location '%s' in the media registry ('%s')"),
    2864                      pstrLocation->c_str(),
     2866                     tr("Could not find a hard disk with location '%ls' in the media registry ('%s')"),
     2867                     aLocation,
    28652868                     m->strSettingsFilePath.raw());
    28662869    }
     
    28852888 */
    28862889HRESULT VirtualBox::findDVDImage(const Guid *aId,
    2887                                  const Utf8Str *pstrLocation,
     2890                                 CBSTR aLocation,
    28882891                                 bool aSetError,
    28892892                                 ComObjPtr<Medium> *aImage /* = NULL */)
    28902893{
    2891     AssertReturn(aId || pstrLocation, E_INVALIDARG);
     2894    AssertReturn(aId || aLocation, E_INVALIDARG);
    28922895
    28932896    Utf8Str location;
    28942897
    2895     if (pstrLocation != NULL)
    2896     {
    2897         int vrc = calculateFullPath(*pstrLocation, location);
     2898    if (aLocation != NULL)
     2899    {
     2900        int vrc = calculateFullPath(Utf8Str(aLocation), location);
    28982901        if (RT_FAILURE(vrc))
    28992902            return setError(VBOX_E_FILE_ERROR,
    2900                             tr("Invalid image file location '%s' (%Rrc)"),
    2901                             pstrLocation->c_str(),
     2903                            tr("Invalid image file location '%ls' (%Rrc)"),
     2904                            aLocation,
    29022905                            vrc);
    29032906    }
     
    29142917        AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS);
    29152918
    2916         found =    (aId && (*it)->getId() == *aId)
    2917                 || (    pstrLocation != NULL
    2918                      && RTPathCompare(location.c_str(),
    2919                                       (*it)->getLocationFull().c_str()
    2920                                      ) == 0);
     2919        found = (aId && (*it)->getId() == *aId) ||
     2920                (aLocation != NULL &&
     2921                 RTPathCompare(location.c_str(),
     2922                               (*it)->getLocationFull().c_str()
     2923                              ) == 0);
    29212924        if (found)
    29222925        {
     
    29382941        else
    29392942            setError(rc,
    2940                      tr("Could not find a CD/DVD image with location '%s' in the media registry ('%s')"),
    2941                      pstrLocation->c_str(),
     2943                     tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"),
     2944                     aLocation,
    29422945                     m->strSettingsFilePath.raw());
    29432946    }
     
    29632966 */
    29642967HRESULT VirtualBox::findFloppyImage(const Guid *aId,
    2965                                     const Utf8Str *pstrLocation,
     2968                                    CBSTR aLocation,
    29662969                                    bool aSetError,
    29672970                                    ComObjPtr<Medium> *aImage /* = NULL */)
    29682971{
    2969     AssertReturn(aId || pstrLocation, E_INVALIDARG);
     2972    AssertReturn(aId || aLocation, E_INVALIDARG);
    29702973
    29712974    Utf8Str location;
    29722975
    2973     if (pstrLocation != NULL)
    2974     {
    2975         int vrc = calculateFullPath(*pstrLocation, location);
     2976    if (aLocation != NULL)
     2977    {
     2978        int vrc = calculateFullPath(Utf8Str(aLocation), location);
    29762979        if (RT_FAILURE(vrc))
    29772980            return setError(VBOX_E_FILE_ERROR,
    2978                             tr("Invalid image file location '%s' (%Rrc)"),
    2979                             pstrLocation->c_str(),
    2980                             vrc);
     2981                            tr("Invalid image file location '%ls' (%Rrc)"),
     2982                            aLocation, vrc);
    29812983    }
    29822984
     
    29922994        AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS);
    29932995
    2994         found =    (aId && (*it)->getId() == *aId)
    2995                 || (    pstrLocation != NULL
    2996                      && RTPathCompare(location.c_str(),
    2997                                       (*it)->getLocationFull().c_str()
    2998                                      ) == 0);
     2996        found = (aId && (*it)->getId() == *aId) ||
     2997                (aLocation != NULL &&
     2998                 RTPathCompare(location.c_str(),
     2999                               (*it)->getLocationFull().c_str()
     3000                              ) == 0);
    29993001        if (found)
    30003002        {
     
    30163018        else
    30173019            setError(rc,
    3018                      tr("Could not find a floppy image with location '%s' in the media registry ('%s')"),
    3019                      pstrLocation->c_str(),
     3020                     tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"),
     3021                     aLocation,
    30203022                     m->strSettingsFilePath.raw());
    30213023    }
     
    31953197    HRESULT rc = S_OK;
    31963198
     3199    Bstr bstrLocation(aLocation);
     3200
    31973201    {
    31983202        ComObjPtr<Medium> hardDisk;
    3199         rc = findHardDisk(&aId, &aLocation, false /* aSetError */, &hardDisk);
     3203        rc = findHardDisk(&aId, bstrLocation, false /* aSetError */, &hardDisk);
    32003204        if (SUCCEEDED(rc))
    32013205        {
     
    32113215    {
    32123216        ComObjPtr<Medium> image;
    3213         rc = findDVDImage(&aId, &aLocation, false /* aSetError */, &image);
     3217        rc = findDVDImage(&aId, bstrLocation, false /* aSetError */, &image);
    32143218        if (SUCCEEDED(rc))
    32153219        {
     
    32253229    {
    32263230        ComObjPtr<Medium> image;
    3227         rc = findFloppyImage(&aId, &aLocation, false /* aSetError */, &image);
     3231        rc = findFloppyImage(&aId, bstrLocation, false /* aSetError */, &image);
    32283232        if (SUCCEEDED(rc))
    32293233        {
     
    43554359STDMETHODIMP VirtualBox::CreateDHCPServer (IN_BSTR aName, IDHCPServer ** aServer)
    43564360{
    4357     CheckComArgStrNotEmptyOrNull(aName);
     4361    CheckComArgNotNull(aName);
    43584362    CheckComArgNotNull(aServer);
    43594363
     
    43764380STDMETHODIMP VirtualBox::FindDHCPServerByNetworkName(IN_BSTR aName, IDHCPServer ** aServer)
    43774381{
    4378     CheckComArgStrNotEmptyOrNull(aName);
     4382    CheckComArgNotNull(aName);
    43794383    CheckComArgNotNull(aServer);
    43804384
     
    44524456
    44534457    ComPtr<IDHCPServer> existing;
    4454     rc = FindDHCPServerByNetworkName(name, existing.asOutParam());
     4458    rc = FindDHCPServerByNetworkName(name.mutableRaw(), existing.asOutParam());
    44554459    if (SUCCEEDED(rc))
    44564460    {
  • trunk/src/VBox/Main/generic/NetIf-generic.cpp

    r26550 r26553  
    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.isEmpty())
     235        iface->COMGETTER(Name) (ifname.asOutParam());
     236        if (ifname.isNull())
    237237            return VERR_INTERNAL_ERROR;
    238238
    239         rc = progress->init(pVBox,
    240                             host,
    241                             Bstr("Removing host network interface"),
     239        rc = progress->init (pVBox, host,
     240                            Bstr ("Removing host network interface"),
    242241                            FALSE /* aCancelable */);
    243242        if(SUCCEEDED(rc))
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

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

    r26550 r26553  
    9696
    9797    void disksWeight(uint32_t &ulTotalMB, uint32_t &cDisks) const;
    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);
     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);
    101101
    102102    struct LocationInfo;
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r26550 r26553  
    5252    HRESULT protectedInit(AutoInitSpan &aAutoInitSpan,
    5353#if !defined (VBOX_COM_INPROC)
    54                           VirtualBox *aParent,
    55 #endif
    56                           IUnknown *aInitiator,
    57                           const Utf8Str &strDescription,
    58                           OUT_GUID aId = NULL);
     54                  VirtualBox *aParent,
     55#endif
     56                  IUnknown *aInitiator,
     57                  CBSTR aDescription, OUT_GUID aId = NULL);
    5958    HRESULT protectedInit(AutoInitSpan &aAutoInitSpan);
    6059    void protectedUninit(AutoUninitSpan &aAutoUninitSpan);
     
    106105
    107106    const Guid mId;
    108     const Utf8Str m_strDescription;
     107    const Bstr mDescription;
    109108
    110109    uint64_t m_ullTimestamp;                        // progress object creation timestamp, for ETA computation
     
    127126
    128127    ULONG m_ulCurrentOperation;                     // operations counter, incremented with each setNextOperation()
    129     Utf8Str m_strOperationDescription;              // name of current operation; initially from constructor, changed with setNextOperation()
     128    Bstr m_bstrOperationDescription;                // name of current operation; initially from constructor, changed with setNextOperation()
    130129    ULONG m_ulCurrentOperationWeight;               // weight of current operation, given to setNextOperation()
    131130    ULONG m_ulOperationPercent;                     // percentage of current operation, set with setCurrentOperationProgress()
     
    177176#endif
    178177                  IUnknown *aInitiator,
    179                   const Utf8Str &strDescription,
     178                  CBSTR aDescription,
    180179                  BOOL aCancelable,
    181180                  OUT_GUID aId = NULL)
     
    186185#endif
    187186            aInitiator,
    188             strDescription,
     187            aDescription,
    189188            aCancelable,
    190189            1,      // cOperations
    191190            1,      // ulTotalOperationsWeight
    192             strDescription, // bstrFirstOperationDescription
     191            aDescription, // bstrFirstOperationDescription
    193192            1,      // ulFirstOperationWeight
    194193            aId);
     
    212211#endif
    213212                  IUnknown *aInitiator,
    214                   const Utf8Str &strDescription,
    215                   BOOL aCancelable,
     213                  CBSTR aDescription, BOOL aCancelable,
    216214                  ULONG cOperations,
    217                   const Utf8Str &strFirstOperationDescription,
     215                  CBSTR bstrFirstOperationDescription,
    218216                  OUT_GUID aId = NULL)
    219217    {
     
    223221#endif
    224222            aInitiator,
    225             strDescription,
     223            aDescription,
    226224            aCancelable,
    227225            cOperations,      // cOperations
    228226            cOperations,      // ulTotalOperationsWeight = cOperations
    229             strFirstOperationDescription, // bstrFirstOperationDescription
     227            bstrFirstOperationDescription, // bstrFirstOperationDescription
    230228            1,      // ulFirstOperationWeight: weigh them all the same
    231229            aId);
     
    237235#endif
    238236                  IUnknown *aInitiator,
    239                   const Utf8Str &strDescription,
     237                  CBSTR aDescription,
    240238                  BOOL aCancelable,
    241239                  ULONG cOperations,
    242240                  ULONG ulTotalOperationsWeight,
    243                   const Utf8Str &strFirstOperationDescription,
     241                  CBSTR bstrFirstOperationDescription,
    244242                  ULONG ulFirstOperationWeight,
    245243                  OUT_GUID aId = NULL);
     
    247245    HRESULT init(BOOL aCancelable,
    248246                 ULONG aOperationCount,
    249                  const Utf8Str &strOperationDescription);
     247                 CBSTR aOperationDescription);
    250248
    251249    void uninit();
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

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

    r26550 r26553  
    195195            strLine = Utf8StrFmt(" (line %RU32)", pNode->getLineNumber());
    196196
     197        const char *pcsz = strLine.c_str();
    197198        Utf8StrFmt str(N_("Error in %s%s -- %s"),
    198199                       file->m->strFilename.c_str(),
    199                        strLine.c_str(),
     200                       (pcsz) ? pcsz : "",
    200201                       strWhat.c_str());
    201202
Note: See TracChangeset for help on using the changeset viewer.

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