Changeset 36527 in vbox for trunk/include
- Timestamp:
- Apr 4, 2011 1:16:09 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 70949
- Location:
- trunk/include
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r36429 r36527 72 72 * 73 73 * 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. 75 75 * 76 76 * The one advantage of using the SysString* routines is that this makes it … … 117 117 #endif 118 118 119 Bstr(const iprt::MiniString &that)119 Bstr(const RTCString &that) 120 120 { 121 121 copyFrom(that.c_str()); … … 426 426 * String class used universally in Main for UTF-8 strings. 427 427 * 428 * This is based on iprt::MiniString, to which some functionality has been428 * This is based on RTCString, to which some functionality has been 429 429 * moved. Here we keep things that are specific to Main, such as conversions 430 430 * with UTF-16 strings (Bstr). 431 431 * 432 * Like iprt::MiniString, Utf8Str does not differentiate between NULL strings432 * Like RTCString, Utf8Str does not differentiate between NULL strings 433 433 * and empty strings. In other words, Utf8Str("") and Utf8Str(NULL) behave the 434 * same. In both cases, MiniString allocates no memory, reports434 * same. In both cases, RTCString allocates no memory, reports 435 435 * a zero length and zero allocated bytes for both, and returns an empty 436 436 * C string from c_str(). … … 440 440 * from external sources before passing them to Utf8Str or Bstr. 441 441 */ 442 class Utf8Str : public iprt::MiniString442 class Utf8Str : public RTCString 443 443 { 444 444 public: … … 446 446 Utf8Str() {} 447 447 448 Utf8Str(const MiniString &that)449 : MiniString(that)448 Utf8Str(const RTCString &that) 449 : RTCString(that) 450 450 {} 451 451 452 452 Utf8Str(const char *that) 453 : MiniString(that)453 : RTCString(that) 454 454 {} 455 455 … … 472 472 * @param a_va Argument vector containing the arguments 473 473 * specified by the format string. 474 * @sa iprt::MiniString::printfV474 * @sa RTCString::printfV 475 475 */ 476 476 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); 484 484 return *this; 485 485 } … … 487 487 Utf8Str& operator=(const char *that) 488 488 { 489 MiniString::operator=(that);489 RTCString::operator=(that); 490 490 return *this; 491 491 } … … 572 572 573 573 /** 574 * Class with iprt::MiniString::printf as constructor for your convenience.574 * Class with RTCString::printf as constructor for your convenience. 575 575 * 576 576 * Constructing a Utf8Str string object from a format string and a variable -
trunk/include/iprt/cpp/exception.h
r36523 r36527 49 49 } 50 50 51 RTCError(const iprt::MiniString &a_rstrMessage)51 RTCError(const RTCString &a_rstrMessage) 52 52 : m_strMsg(a_rstrMessage) 53 53 { … … 87 87 88 88 /** The exception message. */ 89 iprt::MiniString m_strMsg;89 RTCString m_strMsg; 90 90 }; 91 91 -
trunk/include/iprt/cpp/list.h
r36526 r36527 54 54 * preallocated. To minimize the memory overhead, native types (that is 55 55 * 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 an57 * array ofpointers to the objects.56 * If bigger types are used (e.g. RTCString) the internal array is an array of 57 * pointers to the objects. 58 58 * 59 59 * The size of the internal array will usually not shrink, but grow -
trunk/include/iprt/cpp/ministring.h
r36508 r36527 1 1 /** @file 2 * IPRT - MiniC++ string class.2 * IPRT - C++ string class. 3 3 */ 4 4 … … 24 24 */ 25 25 26 #ifndef ___ VBox_ministring_h27 #define ___ VBox_ministring_h26 #ifndef ___iprt_cpp_ministring_h 27 #define ___iprt_cpp_ministring_h 28 28 29 29 #include <iprt/mem.h> … … 34 34 #include <new> 35 35 36 namespace iprt37 {38 36 39 37 /** @defgroup grp_rt_cpp_string C++ String support … … 42 40 */ 43 41 44 /** @brief MiniC++ string class.45 * 46 * "MiniString" is a small C++ string class that does not depend on anything47 * else except IPRT memory management functions. Semantics are like in48 * std::string, except itcan do a lot less.49 * 50 * Note that MiniString does not differentiate between NULL strings and51 * empty strings. In other words, MiniString("") and MiniString(NULL)52 * behave the same. In both cases, MiniString allocates no memory, reports42 /** @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 53 51 * a zero length and zero allocated bytes for both, and returns an empty 54 52 * C string from c_str(). 55 53 * 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. 57 55 * The caller is responsible for not breaking this assumption. 58 56 */ 59 57 #ifdef VBOX 60 58 /** @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 code59 * com::Utf8Str can now derive from RTCString and only contain code 62 60 * that is COM-specific, such as com::Bstr conversions. Compared to 63 * the old Utf8Str though, MiniString always knows the length of its61 * the old Utf8Str though, RTCString always knows the length of its 64 62 * member string and the size of the buffer so it can use memcpy() 65 63 * instead of strdup(). 66 64 */ 67 65 #endif 68 class RT_DECL_CLASS MiniString66 class RT_DECL_CLASS RTCString 69 67 { 70 68 public: … … 72 70 * Creates an empty string that has no memory allocated. 73 71 */ 74 MiniString()72 RTCString() 75 73 : m_psz(NULL), 76 74 m_cch(0), … … 80 78 81 79 /** 82 * Creates a copy of another MiniString.80 * Creates a copy of another RTCString. 83 81 * 84 82 * This allocates s.length() + 1 bytes for the new instance, unless s is empty. … … 88 86 * @throws std::bad_alloc 89 87 */ 90 MiniString(const MiniString &a_rSrc)88 RTCString(const RTCString &a_rSrc) 91 89 { 92 90 copyFromN(a_rSrc.m_psz, a_rSrc.m_cch); … … 102 100 * @throws std::bad_alloc 103 101 */ 104 MiniString(const char *pcsz)102 RTCString(const char *pcsz) 105 103 { 106 104 copyFromN(pcsz, pcsz ? strlen(pcsz) : 0); … … 108 106 109 107 /** 110 * Create a partial copy of another MiniString.108 * Create a partial copy of another RTCString. 111 109 * 112 110 * @param a_rSrc The source string. … … 115 113 * to copy from the source string. 116 114 */ 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) 118 116 { 119 117 if (a_offSrc < a_rSrc.m_cch) … … 136 134 * that for the va_list constructor. 137 135 */ 138 MiniString(const char *a_pszSrc, size_t a_cchSrc)136 RTCString(const char *a_pszSrc, size_t a_cchSrc) 139 137 { 140 138 size_t cchMax = a_pszSrc ? RTStrNLen(a_pszSrc, a_cchSrc) : 0; … … 149 147 * @param a_ch The character to fill the string with. 150 148 */ 151 MiniString(size_t a_cTimes, char a_ch)149 RTCString(size_t a_cTimes, char a_ch) 152 150 : m_psz(NULL), 153 151 m_cch(0), … … 174 172 * @remarks Not part of std::string. 175 173 */ 176 MiniString(const char *a_pszFormat, va_list a_va)174 RTCString(const char *a_pszFormat, va_list a_va) 177 175 : m_psz(NULL), 178 176 m_cch(0), … … 185 183 * Destructor. 186 184 */ 187 virtual ~ MiniString()185 virtual ~RTCString() 188 186 { 189 187 cleanup(); … … 280 278 * @returns Reference to the object. 281 279 */ 282 MiniString &operator=(const char *pcsz)280 RTCString &operator=(const char *pcsz) 283 281 { 284 282 if (m_psz != pcsz) … … 300 298 * @returns Reference to the object. 301 299 */ 302 MiniString &operator=(const MiniString &s)300 RTCString &operator=(const RTCString &s) 303 301 { 304 302 if (this != &s) … … 322 320 * @returns Reference to the object. 323 321 */ 324 MiniString &printf(const char *pszFormat, ...);322 RTCString &printf(const char *pszFormat, ...); 325 323 326 324 /** … … 336 334 * @returns Reference to the object. 337 335 */ 338 MiniString &printfV(const char *pszFormat, va_list va);336 RTCString &printfV(const char *pszFormat, va_list va); 339 337 340 338 /** … … 347 345 * @returns Reference to the object. 348 346 */ 349 MiniString &append(const MiniString &that);347 RTCString &append(const RTCString &that); 350 348 351 349 /** … … 358 356 * @returns Reference to the object. 359 357 */ 360 MiniString &append(const char *pszThat);358 RTCString &append(const char *pszThat); 361 359 362 360 /** … … 369 367 * @returns Reference to the object. 370 368 */ 371 MiniString &append(char ch);369 RTCString &append(char ch); 372 370 373 371 /** … … 380 378 * @returns Reference to the object. 381 379 */ 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. 386 384 * 387 385 * @param that The string to append. … … 389 387 * @returns Reference to the object. 390 388 */ 391 MiniString &operator+=(const MiniString &that)389 RTCString &operator+=(const RTCString &that) 392 390 { 393 391 return append(that); … … 401 399 * @returns Reference to the object. 402 400 */ 403 MiniString &operator+=(const char *pszThat)401 RTCString &operator+=(const char *pszThat) 404 402 { 405 403 return append(pszThat); … … 413 411 * @returns Reference to the object. 414 412 */ 415 MiniString &operator+=(char c)413 RTCString &operator+=(char c) 416 414 { 417 415 return append(c); … … 423 421 * @returns Reference to the object. 424 422 */ 425 MiniString &toUpper()423 RTCString &toUpper() 426 424 { 427 425 if (length()) … … 442 440 * @returns Reference to the object. 443 441 */ 444 MiniString &toLower()442 RTCString &toLower() 445 443 { 446 444 if (length()) … … 494 492 * capacity() to find out how large that buffer is. 495 493 * -# After any operation that modifies the length of the string, 496 * you _must_ call MiniString::jolt(), or subsequent copy operations494 * you _must_ call RTCString::jolt(), or subsequent copy operations 497 495 * may go nowhere. Better not use mutableRaw() at all. 498 496 */ … … 582 580 583 581 /** 584 * Compares the member string to another MiniString.582 * Compares the member string to another RTCString. 585 583 * 586 584 * @param pcszThat The string to compare with. … … 589 587 * if larger. 590 588 */ 591 int compare(const MiniString &that, CaseSensitivity cs = CaseSensitive) const589 int compare(const RTCString &that, CaseSensitivity cs = CaseSensitive) const 592 590 { 593 591 if (cs == CaseSensitive) … … 602 600 * @param that The string to compare with. 603 601 */ 604 bool equals(const MiniString &that) const602 bool equals(const RTCString &that) const 605 603 { 606 604 return that.length() == length() … … 629 627 * @param that The string to compare with. 630 628 */ 631 bool equalsIgnoreCase(const MiniString &that) const629 bool equalsIgnoreCase(const RTCString &that) const 632 630 { 633 631 /* Unfolded upper and lower case characters may require different … … 653 651 /** @name Comparison operators. 654 652 * @{ */ 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; } 659 657 660 658 bool operator==(const char *pszThat) const { return equals(pszThat); } … … 709 707 * n bytes have been copied. 710 708 */ 711 iprt::MiniString substr(size_t pos = 0, size_t n = npos) const712 { 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); 714 712 } 715 713 … … 725 723 * been copied. 726 724 */ 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; 728 726 729 727 /** … … 734 732 * @returns true if match, false if mismatch. 735 733 */ 736 bool endsWith(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;734 bool endsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const; 737 735 738 736 /** … … 742 740 * @returns true if match, false if mismatch. 743 741 */ 744 bool startsWith(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;742 bool startsWith(const RTCString &that, CaseSensitivity cs = CaseSensitive) const; 745 743 746 744 /** … … 751 749 * @returns true if match, false if mismatch. 752 750 */ 753 bool contains(const iprt::MiniString &that, CaseSensitivity cs = CaseSensitive) const;751 bool contains(const RTCString &that, CaseSensitivity cs = CaseSensitive) const; 754 752 755 753 /** … … 827 825 * @returns separated strings as string list. 828 826 */ 829 iprt::list< iprt::MiniString, iprt::MiniString *> split(const iprt::MiniString &a_rstrSep,830 827 iprt::list<RTCString, RTCString *> split(const RTCString &a_rstrSep, 828 SplitMode a_enmMode = RemoveEmptyParts); 831 829 832 830 /** … … 837 835 * @returns joined string. 838 836 */ 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 = ""); 841 839 842 840 protected: … … 917 915 /** @} */ 918 916 919 } /* namespace iprt */920 917 921 918 /** @addtogroup grp_rt_cpp_string … … 930 927 * @returns the concatenate string. 931 928 * 932 * @relates iprt::MiniString929 * @relates RTCString 933 930 */ 934 RTDECL(const iprt::MiniString) operator+(const iprt::MiniString &a_rstr1, const iprt::MiniString &a_rstr2);931 RTDECL(const RTCString) operator+(const RTCString &a_rstr1, const RTCString &a_rstr2); 935 932 936 933 /** … … 941 938 * @returns the concatenate string. 942 939 * 943 * @relates iprt::MiniString940 * @relates RTCString 944 941 */ 945 RTDECL(const iprt::MiniString) operator+(const iprt::MiniString &a_rstr1, const char *a_psz2);942 RTDECL(const RTCString) operator+(const RTCString &a_rstr1, const char *a_psz2); 946 943 947 944 /** … … 952 949 * @returns the concatenate string. 953 950 * 954 * @relates iprt::MiniString951 * @relates RTCString 955 952 */ 956 RTDECL(const iprt::MiniString) operator+(const char *a_psz1, const iprt::MiniString &a_rstr2);953 RTDECL(const RTCString) operator+(const char *a_psz1, const RTCString &a_rstr2); 957 954 958 955 /** @} */ -
trunk/include/iprt/cpp/xml.h
r36523 r36527 465 465 const AttributeNode* findAttribute(const char *pcszMatch) const; 466 466 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; 469 469 bool getAttributeValue(const char *pcszMatch, int32_t &i) const; 470 470 bool getAttributeValue(const char *pcszMatch, uint32_t &i) const; … … 476 476 477 477 ContentNode* addContent(const char *pcszContent); 478 ContentNode* addContent(const iprt::MiniString &strContent)478 ContentNode* addContent(const RTCString &strContent) 479 479 { 480 480 return addContent(strContent.c_str()); … … 482 482 483 483 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) 485 485 { 486 486 return setAttribute(pcszName, strValue.c_str()); 487 487 } 488 AttributeNode* setAttributePath(const char *pcszName, const iprt::MiniString &strValue);488 AttributeNode* setAttributePath(const char *pcszName, const RTCString &strValue); 489 489 AttributeNode* setAttribute(const char *pcszName, int32_t i); 490 490 AttributeNode* setAttribute(const char *pcszName, uint32_t i); … … 550 550 AttributeNode(const AttributeNode &x); // no copying 551 551 552 iprt::MiniString m_strKey;552 RTCString m_strKey; 553 553 554 554 friend class Node; … … 651 651 ~XmlMemParser(); 652 652 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); 654 654 }; 655 655 … … 665 665 ~XmlFileParser(); 666 666 667 void read(const iprt::MiniString &strFilename, Document &doc);667 void read(const RTCString &strFilename, Document &doc); 668 668 669 669 private:
Note:
See TracChangeset
for help on using the changeset viewer.