VirtualBox

Changeset 26587 in vbox for trunk/include/iprt


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

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

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

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

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

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