VirtualBox

Changeset 36527 in vbox for trunk/include


Ignore:
Timestamp:
Apr 4, 2011 1:16:09 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70949
Message:

iprt::MiniString -> RTCString.

Location:
trunk/include
Files:
5 edited

Legend:

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

    r36429 r36527  
    7272 *
    7373 * The Bstr class hides all this handling behind a std::string-like interface
    74  * and also provides automatic conversions to MiniString and Utf8Str instances.
     74 * and also provides automatic conversions to RTCString and Utf8Str instances.
    7575 *
    7676 * The one advantage of using the SysString* routines is that this makes it
     
    117117#endif
    118118
    119     Bstr(const iprt::MiniString &that)
     119    Bstr(const RTCString &that)
    120120    {
    121121        copyFrom(that.c_str());
     
    426426 * String class used universally in Main for UTF-8 strings.
    427427 *
    428  * This is based on iprt::MiniString, to which some functionality has been
     428 * This is based on RTCString, to which some functionality has been
    429429 * moved.  Here we keep things that are specific to Main, such as conversions
    430430 * with UTF-16 strings (Bstr).
    431431 *
    432  * Like iprt::MiniString, Utf8Str does not differentiate between NULL strings
     432 * Like RTCString, Utf8Str does not differentiate between NULL strings
    433433 * and empty strings.  In other words, Utf8Str("") and Utf8Str(NULL) behave the
    434  * same.  In both cases, MiniString allocates no memory, reports
     434 * same.  In both cases, RTCString allocates no memory, reports
    435435 * a zero length and zero allocated bytes for both, and returns an empty
    436436 * C string from c_str().
     
    440440 *          from external sources before passing them to Utf8Str or Bstr.
    441441 */
    442 class Utf8Str : public iprt::MiniString
     442class Utf8Str : public RTCString
    443443{
    444444public:
     
    446446    Utf8Str() {}
    447447
    448     Utf8Str(const MiniString &that)
    449         : MiniString(that)
     448    Utf8Str(const RTCString &that)
     449        : RTCString(that)
    450450    {}
    451451
    452452    Utf8Str(const char *that)
    453         : MiniString(that)
     453        : RTCString(that)
    454454    {}
    455455
     
    472472     * @param   a_va            Argument vector containing the arguments
    473473     *                          specified by the format string.
    474      * @sa      iprt::MiniString::printfV
     474     * @sa      RTCString::printfV
    475475     */
    476476    Utf8Str(const char *a_pszFormat, va_list a_va)
    477         : MiniString(a_pszFormat, a_va)
    478     {
    479     }
    480 
    481     Utf8Str& operator=(const MiniString &that)
    482     {
    483         MiniString::operator=(that);
     477        : RTCString(a_pszFormat, a_va)
     478    {
     479    }
     480
     481    Utf8Str& operator=(const RTCString &that)
     482    {
     483        RTCString::operator=(that);
    484484        return *this;
    485485    }
     
    487487    Utf8Str& operator=(const char *that)
    488488    {
    489         MiniString::operator=(that);
     489        RTCString::operator=(that);
    490490        return *this;
    491491    }
     
    572572
    573573/**
    574  * Class with iprt::MiniString::printf as constructor for your convenience.
     574 * Class with RTCString::printf as constructor for your convenience.
    575575 *
    576576 * Constructing a Utf8Str string object from a format string and a variable
  • trunk/include/iprt/cpp/exception.h

    r36523 r36527  
    4949    }
    5050
    51     RTCError(const iprt::MiniString &a_rstrMessage)
     51    RTCError(const RTCString &a_rstrMessage)
    5252        : m_strMsg(a_rstrMessage)
    5353    {
     
    8787
    8888    /** The exception message. */
    89     iprt::MiniString m_strMsg;
     89    RTCString m_strMsg;
    9090};
    9191
  • trunk/include/iprt/cpp/list.h

    r36526 r36527  
    5454 * preallocated. To minimize the memory overhead, native types (that is
    5555 * everything smaller then the size of void*) are directly saved in the array.
    56  * If bigger types are used (e.g. iprt::MiniString) the internal array is an
    57  * array of pointers to the objects.
     56 * If bigger types are used (e.g. RTCString) the internal array is an array of
     57 * pointers to the objects.
    5858 *
    5959 * The size of the internal array will usually not shrink, but grow
  • trunk/include/iprt/cpp/ministring.h

    r36508 r36527  
    11/** @file
    2  * IPRT - Mini C++ string class.
     2 * IPRT - C++ string class.
    33 */
    44
     
    2424 */
    2525
    26 #ifndef ___VBox_ministring_h
    27 #define ___VBox_ministring_h
     26#ifndef ___iprt_cpp_ministring_h
     27#define ___iprt_cpp_ministring_h
    2828
    2929#include <iprt/mem.h>
     
    3434#include <new>
    3535
    36 namespace iprt
    37 {
    3836
    3937/** @defgroup grp_rt_cpp_string     C++ String support
     
    4240 */
    4341
    44 /** @brief  Mini C++ string class.
    45  *
    46  * "MiniString" is a small C++ string class that does not depend on anything
    47  * else except IPRT memory management functions.  Semantics are like in
    48  * std::string, except it can do a lot less.
    49  *
    50  * Note that MiniString does not differentiate between NULL strings and
    51  * empty strings. In other words, MiniString("") and MiniString(NULL)
    52  * behave the same. In both cases, MiniString allocates no memory, reports
     42/** @brief  C++ string class.
     43 *
     44 * This is a C++ string class that does not depend on anything else except IPRT
     45 * memory management functions.  Semantics are like in std::string, except it
     46 * can do a lot less.
     47 *
     48 * Note that RTCString does not differentiate between NULL strings
     49 * and empty strings.  In other words, RTCString("") and RTCString(NULL)
     50 * behave the same.  In both cases, RTCString allocates no memory, reports
    5351 * a zero length and zero allocated bytes for both, and returns an empty
    5452 * C string from c_str().
    5553 *
    56  * @note    MiniString ASSUMES that all strings it deals with are valid UTF-8.
     54 * @note    RTCString ASSUMES that all strings it deals with are valid UTF-8.
    5755 *          The caller is responsible for not breaking this assumption.
    5856 */
    5957#ifdef VBOX
    6058 /** @remarks Much of the code in here used to be in com::Utf8Str so that
    61   *          com::Utf8Str can now derive from MiniString and only contain code
     59  *          com::Utf8Str can now derive from RTCString and only contain code
    6260  *          that is COM-specific, such as com::Bstr conversions.  Compared to
    63   *          the old Utf8Str though, MiniString always knows the length of its
     61  *          the old Utf8Str though, RTCString always knows the length of its
    6462  *          member string and the size of the buffer so it can use memcpy()
    6563  *          instead of strdup().
    6664  */
    6765#endif
    68 class RT_DECL_CLASS MiniString
     66class RT_DECL_CLASS RTCString
    6967{
    7068public:
     
    7270     * Creates an empty string that has no memory allocated.
    7371     */
    74     MiniString()
     72    RTCString()
    7573        : m_psz(NULL),
    7674          m_cch(0),
     
    8078
    8179    /**
    82      * Creates a copy of another MiniString.
     80     * Creates a copy of another RTCString.
    8381     *
    8482     * This allocates s.length() + 1 bytes for the new instance, unless s is empty.
     
    8886     * @throws  std::bad_alloc
    8987     */
    90     MiniString(const MiniString &a_rSrc)
     88    RTCString(const RTCString &a_rSrc)
    9189    {
    9290        copyFromN(a_rSrc.m_psz, a_rSrc.m_cch);
     
    102100     * @throws  std::bad_alloc
    103101     */
    104     MiniString(const char *pcsz)
     102    RTCString(const char *pcsz)
    105103    {
    106104        copyFromN(pcsz, pcsz ? strlen(pcsz) : 0);
     
    108106
    109107    /**
    110      * Create a partial copy of another MiniString.
     108     * Create a partial copy of another RTCString.
    111109     *
    112110     * @param   a_rSrc          The source string.
     
    115113     *                          to copy from the source string.
    116114     */
    117     MiniString(const MiniString &a_rSrc, size_t a_offSrc, size_t a_cchSrc = npos)
     115    RTCString(const RTCString &a_rSrc, size_t a_offSrc, size_t a_cchSrc = npos)
    118116    {
    119117        if (a_offSrc < a_rSrc.m_cch)
     
    136134     *                          that for the va_list constructor.
    137135     */
    138     MiniString(const char *a_pszSrc, size_t a_cchSrc)
     136    RTCString(const char *a_pszSrc, size_t a_cchSrc)
    139137    {
    140138        size_t cchMax = a_pszSrc ? RTStrNLen(a_pszSrc, a_cchSrc) : 0;
     
    149147     * @param   a_ch            The character to fill the string with.
    150148     */
    151     MiniString(size_t a_cTimes, char a_ch)
     149    RTCString(size_t a_cTimes, char a_ch)
    152150        : m_psz(NULL),
    153151          m_cch(0),
     
    174172     * @remarks Not part of std::string.
    175173     */
    176     MiniString(const char *a_pszFormat, va_list a_va)
     174    RTCString(const char *a_pszFormat, va_list a_va)
    177175        : m_psz(NULL),
    178176          m_cch(0),
     
    185183     * Destructor.
    186184     */
    187     virtual ~MiniString()
     185    virtual ~RTCString()
    188186    {
    189187        cleanup();
     
    280278     * @returns Reference to the object.
    281279     */
    282     MiniString &operator=(const char *pcsz)
     280    RTCString &operator=(const char *pcsz)
    283281    {
    284282        if (m_psz != pcsz)
     
    300298     * @returns Reference to the object.
    301299     */
    302     MiniString &operator=(const MiniString &s)
     300    RTCString &operator=(const RTCString &s)
    303301    {
    304302        if (this != &s)
     
    322320     * @returns Reference to the object.
    323321     */
    324     MiniString &printf(const char *pszFormat, ...);
     322    RTCString &printf(const char *pszFormat, ...);
    325323
    326324    /**
     
    336334     * @returns Reference to the object.
    337335     */
    338     MiniString &printfV(const char *pszFormat, va_list va);
     336    RTCString &printfV(const char *pszFormat, va_list va);
    339337
    340338    /**
     
    347345     * @returns Reference to the object.
    348346     */
    349     MiniString &append(const MiniString &that);
     347    RTCString &append(const RTCString &that);
    350348
    351349    /**
     
    358356     * @returns Reference to the object.
    359357     */
    360     MiniString &append(const char *pszThat);
     358    RTCString &append(const char *pszThat);
    361359
    362360    /**
     
    369367     * @returns Reference to the object.
    370368     */
    371     MiniString &append(char ch);
     369    RTCString &append(char ch);
    372370
    373371    /**
     
    380378     * @returns Reference to the object.
    381379     */
    382     MiniString &appendCodePoint(RTUNICP uc);
    383 
    384     /**
    385      * Shortcut to append(), MiniString variant.
     380    RTCString &appendCodePoint(RTUNICP uc);
     381
     382    /**
     383     * Shortcut to append(), RTCString variant.
    386384     *
    387385     * @param that              The string to append.
     
    389387     * @returns Reference to the object.
    390388     */
    391     MiniString &operator+=(const MiniString &that)
     389    RTCString &operator+=(const RTCString &that)
    392390    {
    393391        return append(that);
     
    401399     * @returns                 Reference to the object.
    402400     */
    403     MiniString &operator+=(const char *pszThat)
     401    RTCString &operator+=(const char *pszThat)
    404402    {
    405403        return append(pszThat);
     
    413411     * @returns                 Reference to the object.
    414412     */
    415     MiniString &operator+=(char c)
     413    RTCString &operator+=(char c)
    416414    {
    417415        return append(c);
     
    423421     * @returns Reference to the object.
    424422     */
    425     MiniString &toUpper()
     423    RTCString &toUpper()
    426424    {
    427425        if (length())
     
    442440     * @returns Reference to the object.
    443441     */
    444     MiniString &toLower()
     442    RTCString &toLower()
    445443    {
    446444        if (length())
     
    494492     *         capacity() to find out how large that buffer is.
    495493     *      -# After any operation that modifies the length of the string,
    496      *         you _must_ call MiniString::jolt(), or subsequent copy operations
     494     *         you _must_ call RTCString::jolt(), or subsequent copy operations
    497495     *         may go nowhere.  Better not use mutableRaw() at all.
    498496     */
     
    582580
    583581    /**
    584      * Compares the member string to another MiniString.
     582     * Compares the member string to another RTCString.
    585583     *
    586584     * @param   pcszThat    The string to compare with.
     
    589587     *          if larger.
    590588     */
    591     int compare(const MiniString &that, CaseSensitivity cs = CaseSensitive) const
     589    int compare(const RTCString &that, CaseSensitivity cs = CaseSensitive) const
    592590    {
    593591        if (cs == CaseSensitive)
     
    602600     * @param   that    The string to compare with.
    603601     */
    604     bool equals(const MiniString &that) const
     602    bool equals(const RTCString &that) const
    605603    {
    606604        return that.length() == length()
     
    629627     * @param   that    The string to compare with.
    630628     */
    631     bool equalsIgnoreCase(const MiniString &that) const
     629    bool equalsIgnoreCase(const RTCString &that) const
    632630    {
    633631        /* Unfolded upper and lower case characters may require different
     
    653651    /** @name Comparison operators.
    654652     * @{  */
    655     bool operator==(const MiniString &that) const { return equals(that); }
    656     bool operator!=(const MiniString &that) const { return !equals(that); }
    657     bool operator<( const MiniString &that) const { return compare(that) < 0; }
    658     bool operator>( const MiniString &that) const { return compare(that) > 0; }
     653    bool operator==(const RTCString &that) const { return equals(that); }
     654    bool operator!=(const RTCString &that) const { return !equals(that); }
     655    bool operator<( const RTCString &that) const { return compare(that) < 0; }
     656    bool operator>( const RTCString &that) const { return compare(that) > 0; }
    659657
    660658    bool operator==(const char *pszThat) const    { return equals(pszThat); }
     
    709707     *                          n bytes have been copied.
    710708     */
    711     iprt::MiniString substr(size_t pos = 0, size_t n = npos) const
    712     {
    713         return MiniString(*this, pos, n);
     709    RTCString substr(size_t pos = 0, size_t n = npos) const
     710    {
     711        return RTCString(*this, pos, n);
    714712    }
    715713
     
    725723     *                          been copied.
    726724     */
    727     iprt::MiniString substrCP(size_t pos = 0, size_t n = npos) const;
     725    RTCString substrCP(size_t pos = 0, size_t n = npos) const;
    728726
    729727    /**
     
    734732     * @returns true if match, false if mismatch.
    735733     */
    736     bool endsWith(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;
     734    bool endsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const;
    737735
    738736    /**
     
    742740     * @returns true if match, false if mismatch.
    743741     */
    744     bool startsWith(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;
     742    bool startsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const;
    745743
    746744    /**
     
    751749     * @returns true if match, false if mismatch.
    752750     */
    753     bool contains(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;
     751    bool contains(const RTCString &that, CaseSensitivity cs = CaseSensitive) const;
    754752
    755753    /**
     
    827825     * @returns separated strings as string list.
    828826     */
    829     iprt::list<iprt::MiniString, iprt::MiniString *> split(const iprt::MiniString &a_rstrSep,
    830                                                            SplitMode a_enmMode = RemoveEmptyParts);
     827    iprt::list<RTCString, RTCString *> split(const RTCString &a_rstrSep,
     828                                             SplitMode a_enmMode = RemoveEmptyParts);
    831829
    832830    /**
     
    837835     * @returns joined string.
    838836     */
    839     static iprt::MiniString join(const iprt::list<iprt::MiniString, iprt::MiniString *> &a_rList,
    840                                  const iprt::MiniString &a_rstrSep = "");
     837    static RTCString join(const iprt::list<RTCString, RTCString *> &a_rList,
     838                          const RTCString &a_rstrSep = "");
    841839
    842840protected:
     
    917915/** @} */
    918916
    919 } /* namespace iprt */
    920917
    921918/** @addtogroup grp_rt_cpp_string
     
    930927 * @returns the concatenate string.
    931928 *
    932  * @relates iprt::MiniString
     929 * @relates RTCString
    933930 */
    934 RTDECL(const iprt::MiniString) operator+(const iprt::MiniString &a_rstr1, const iprt::MiniString &a_rstr2);
     931RTDECL(const RTCString) operator+(const RTCString &a_rstr1, const RTCString &a_rstr2);
    935932
    936933/**
     
    941938 * @returns the concatenate string.
    942939 *
    943  * @relates iprt::MiniString
     940 * @relates RTCString
    944941 */
    945 RTDECL(const iprt::MiniString) operator+(const iprt::MiniString &a_rstr1, const char *a_psz2);
     942RTDECL(const RTCString) operator+(const RTCString &a_rstr1, const char *a_psz2);
    946943
    947944/**
     
    952949 * @returns the concatenate string.
    953950 *
    954  * @relates iprt::MiniString
     951 * @relates RTCString
    955952 */
    956 RTDECL(const iprt::MiniString) operator+(const char *a_psz1, const iprt::MiniString &a_rstr2);
     953RTDECL(const RTCString) operator+(const char *a_psz1, const RTCString &a_rstr2);
    957954
    958955/** @} */
  • trunk/include/iprt/cpp/xml.h

    r36523 r36527  
    465465    const AttributeNode* findAttribute(const char *pcszMatch) const;
    466466    bool getAttributeValue(const char *pcszMatch, const char *&ppcsz) const;
    467     bool getAttributeValue(const char *pcszMatch, iprt::MiniString &str) const;
    468     bool getAttributeValuePath(const char *pcszMatch, iprt::MiniString &str) const;
     467    bool getAttributeValue(const char *pcszMatch, RTCString &str) const;
     468    bool getAttributeValuePath(const char *pcszMatch, RTCString &str) const;
    469469    bool getAttributeValue(const char *pcszMatch, int32_t &i) const;
    470470    bool getAttributeValue(const char *pcszMatch, uint32_t &i) const;
     
    476476
    477477    ContentNode* addContent(const char *pcszContent);
    478     ContentNode* addContent(const iprt::MiniString &strContent)
     478    ContentNode* addContent(const RTCString &strContent)
    479479    {
    480480        return addContent(strContent.c_str());
     
    482482
    483483    AttributeNode* setAttribute(const char *pcszName, const char *pcszValue);
    484     AttributeNode* setAttribute(const char *pcszName, const iprt::MiniString &strValue)
     484    AttributeNode* setAttribute(const char *pcszName, const RTCString &strValue)
    485485    {
    486486        return setAttribute(pcszName, strValue.c_str());
    487487    }
    488     AttributeNode* setAttributePath(const char *pcszName, const iprt::MiniString &strValue);
     488    AttributeNode* setAttributePath(const char *pcszName, const RTCString &strValue);
    489489    AttributeNode* setAttribute(const char *pcszName, int32_t i);
    490490    AttributeNode* setAttribute(const char *pcszName, uint32_t i);
     
    550550    AttributeNode(const AttributeNode &x);      // no copying
    551551
    552     iprt::MiniString    m_strKey;
     552    RTCString    m_strKey;
    553553
    554554    friend class Node;
     
    651651    ~XmlMemParser();
    652652
    653     void read(const void* pvBuf, size_t cbSize, const iprt::MiniString &strFilename, Document &doc);
     653    void read(const void* pvBuf, size_t cbSize, const RTCString &strFilename, Document &doc);
    654654};
    655655
     
    665665    ~XmlFileParser();
    666666
    667     void read(const iprt::MiniString &strFilename, Document &doc);
     667    void read(const RTCString &strFilename, Document &doc);
    668668
    669669private:
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