VirtualBox

Changeset 21409 in vbox for trunk


Ignore:
Timestamp:
Jul 8, 2009 3:36:59 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49785
Message:

IPRT: rename ministring, add iprt:: namespace

Location:
trunk
Files:
5 edited

Legend:

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

    r21369 r21409  
    324324 *    afterwards.
    325325 */
    326 class Utf8Str : public ministring
     326class Utf8Str : public iprt::MiniString
    327327{
    328328public:
     
    331331
    332332    Utf8Str(const Utf8Str &that)
    333         : ministring(that)
     333        : MiniString(that)
    334334    {}
    335335
    336336    Utf8Str(const char *that)
    337         : ministring(that)
     337        : MiniString(that)
    338338    {}
    339339
     
    350350    Utf8Str& operator=(const Utf8Str &that)
    351351    {
    352         ministring::operator=(that);
     352        MiniString::operator=(that);
    353353        return *this;
    354354    }
     
    356356    Utf8Str& operator=(const char *that)
    357357    {
    358         ministring::operator=(that);
     358        MiniString::operator=(that);
    359359        return *this;
    360360    }
  • trunk/include/iprt/ministring_cpp.h

    r21404 r21409  
    3737#include <new>
    3838
     39namespace iprt
     40{
     41
    3942/**
    40  *  "ministring" is a small C++ string class that does not depend on anything
     43 *  "MiniString" is a small C++ string class that does not depend on anything
    4144 *  else except IPRT memory management functions. This is used as the base of
    4245 *  both the Utf8Str class that COM uses as well as C++ code in IPRT that
     
    4649 *
    4750 *  Much of the code in here used to be in com::Utf8Str so that com::Utf8Str
    48  *  can now derive from ministring and only contain code that is COM-specific,
    49  *  such as com::Bstr conversions. Compared to the old Utf8Str though, ministring
     51 *  can now derive from MiniString and only contain code that is COM-specific,
     52 *  such as com::Bstr conversions. Compared to the old Utf8Str though, MiniString
    5053 *  always knows the length of its member string and the size of the buffer
    5154 *  so it can use memcpy() instead of strdup().
    5255 */
    5356
    54 class RT_DECL_CLASS ministring
     57class RT_DECL_CLASS MiniString
    5558{
    5659public:
     
    5861     * Creates an empty string that has no memory allocated.
    5962     */
    60     ministring()
     63    MiniString()
    6164        : m_psz(NULL),
    6265          m_cbLength(0),
     
    6669
    6770    /**
    68      * Creates a copy of another ministring. This allocates
     71     * Creates a copy of another MiniString. This allocates
    6972     * s.length() + 1 bytes for the new instance.
    7073     * @param s
    7174     */
    72     ministring(const ministring &s)
     75    MiniString(const MiniString &s)
    7376    {
    7477        copyFrom(s);
     
    7679
    7780    /**
    78      * Creates a copy of another ministring. This allocates
     81     * Creates a copy of another MiniString. This allocates
    7982     * strlen(pcsz) + 1 bytes for the new instance.
    8083     * @param pcsz
    8184     */
    82     ministring(const char *pcsz)
     85    MiniString(const char *pcsz)
    8386    {
    8487        copyFrom(pcsz);
     
    8891     * Destructor.
    8992     */
    90     virtual ~ministring()
     93    virtual ~MiniString()
    9194    {
    9295        cleanup();
     
    149152     *          capacity() to find out how large that buffer is.
    150153     *      2)  After any operation that modifies the length of the string,
    151      *          you _must_ call ministring::jolt(), or subsequent copy operations
     154     *          you _must_ call MiniString::jolt(), or subsequent copy operations
    152155     *          may go nowhere. Better not use mutableRaw() at all.
    153156     */
     
    182185     * @return
    183186     */
    184     ministring& operator=(const char *pcsz)
     187    MiniString& operator=(const char *pcsz)
    185188    {
    186189        if (m_psz != pcsz)
     
    197200     * @return
    198201     */
    199     ministring& operator=(const ministring &s)
     202    MiniString& operator=(const MiniString &s)
    200203    {
    201204        if (this != &s)
     
    211214     * @param that
    212215     */
    213     void append(const ministring &that)
     216    void append(const MiniString &that)
    214217    {
    215218        size_t cbThis = length();
     
    290293    }
    291294
    292     int compare(const ministring &that, CaseSensitivity cs = CaseSensitive) const
     295    int compare(const MiniString &that, CaseSensitivity cs = CaseSensitive) const
    293296    {
    294297        return compare(that.m_psz, cs);
    295298    }
    296299
    297     bool operator==(const ministring &that) const { return !compare(that); }
    298     bool operator!=(const ministring &that) const { return !!compare(that); }
    299     bool operator<(const ministring &that) const { return compare(that) < 0; }
    300     bool operator>(const ministring &that) const { return compare(that) > 0; }
     300    bool operator==(const MiniString &that) const { return !compare(that); }
     301    bool operator!=(const MiniString &that) const { return !!compare(that); }
     302    bool operator<(const MiniString &that) const { return compare(that) < 0; }
     303    bool operator>(const MiniString &that) const { return compare(that) > 0; }
    301304
    302305    bool operator==(const char *that) const { return !compare(that); }
     
    335338     * after having called cleanup().
    336339     *
    337      * This variant copies from another ministring and is fast since
     340     * This variant copies from another MiniString and is fast since
    338341     * the length of source string is known.
    339342     *
    340343     * @param s
    341344     */
    342     void copyFrom(const ministring &s)
     345    void copyFrom(const MiniString &s)
    343346    {
    344347        if ((m_cbLength = s.m_cbLength))
     
    394397};
    395398
     399} // namespace iprt
     400
    396401#endif
  • trunk/include/iprt/xml_cpp.h

    r21085 r21409  
    9494    Error() {};     // hide the default constructor to make sure the extended one above is always used
    9595
    96     ministring m_s;
     96    iprt::MiniString m_s;
    9797};
    9898
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r21322 r21409  
    10851085{
    10861086    xmlParserCtxtPtr ctxt;
    1087     ministring strXmlFilename;
     1087    iprt::MiniString strXmlFilename;
    10881088
    10891089    Data()
     
    11151115{
    11161116    File file;
    1117     ministring error;
     1117    iprt::MiniString error;
    11181118
    11191119    IOContext(const char *pcszFilename, File::Mode mode)
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r21404 r21409  
    949949    } while (0)
    950950
    951     ministring empty;
     951    iprt::MiniString empty;
    952952    CHECK( (empty.length() == 0) );
    953953    CHECK( (empty.capacity() == 0) );
    954954
    955     ministring sixbytes("12345");
     955    iprt::MiniString sixbytes("12345");
    956956    CHECK( (sixbytes.length() == 5) );
    957957    CHECK( (sixbytes.capacity() == 6) );
     
    970970    CHECK( (sixbytes.capacity() == 7) );
    971971
    972     ministring morebytes("tobereplaced");
     972    iprt::MiniString morebytes("tobereplaced");
    973973    morebytes = "newstring ";
    974974    morebytes.append(sixbytes);
     
    976976    CHECK_DUMP( (morebytes == "newstring 123456"), morebytes.c_str() );
    977977
    978     ministring third(morebytes);
     978    iprt::MiniString third(morebytes);
    979979    third.reserve(100 * 1024);      // 100 KB
    980980    CHECK_DUMP( (third == "newstring 123456"), morebytes.c_str() );
     
    982982    CHECK( (third.length() == morebytes.length()) );        // must not have changed
    983983
    984     ministring copy1(morebytes);
    985     ministring copy2 = morebytes;
     984    iprt::MiniString copy1(morebytes);
     985    iprt::MiniString copy2 = morebytes;
    986986    CHECK( (copy1 == copy2) );
    987987
     
    992992    CHECK( (copy1.length() == 0) );
    993993
    994     CHECK( (ministring("abc") < ministring("def")) );
    995     CHECK( (ministring("abc") != ministring("def")) );
    996     CHECK_DUMP_I( (ministring("def") > ministring("abc")) );
     994    CHECK( (iprt::MiniString("abc") < iprt::MiniString("def")) );
     995    CHECK( (iprt::MiniString("abc") != iprt::MiniString("def")) );
     996    CHECK_DUMP_I( (iprt::MiniString("def") > iprt::MiniString("abc")) );
    997997
    998998    copy2.setNull();
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