- Timestamp:
- Jul 8, 2009 3:36:59 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 49785
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/string.h
r21369 r21409 324 324 * afterwards. 325 325 */ 326 class Utf8Str : public ministring326 class Utf8Str : public iprt::MiniString 327 327 { 328 328 public: … … 331 331 332 332 Utf8Str(const Utf8Str &that) 333 : ministring(that)333 : MiniString(that) 334 334 {} 335 335 336 336 Utf8Str(const char *that) 337 : ministring(that)337 : MiniString(that) 338 338 {} 339 339 … … 350 350 Utf8Str& operator=(const Utf8Str &that) 351 351 { 352 ministring::operator=(that);352 MiniString::operator=(that); 353 353 return *this; 354 354 } … … 356 356 Utf8Str& operator=(const char *that) 357 357 { 358 ministring::operator=(that);358 MiniString::operator=(that); 359 359 return *this; 360 360 } -
trunk/include/iprt/ministring_cpp.h
r21404 r21409 37 37 #include <new> 38 38 39 namespace iprt 40 { 41 39 42 /** 40 * " ministring" is a small C++ string class that does not depend on anything43 * "MiniString" is a small C++ string class that does not depend on anything 41 44 * else except IPRT memory management functions. This is used as the base of 42 45 * both the Utf8Str class that COM uses as well as C++ code in IPRT that … … 46 49 * 47 50 * 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, ministring51 * 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 50 53 * always knows the length of its member string and the size of the buffer 51 54 * so it can use memcpy() instead of strdup(). 52 55 */ 53 56 54 class RT_DECL_CLASS ministring57 class RT_DECL_CLASS MiniString 55 58 { 56 59 public: … … 58 61 * Creates an empty string that has no memory allocated. 59 62 */ 60 ministring()63 MiniString() 61 64 : m_psz(NULL), 62 65 m_cbLength(0), … … 66 69 67 70 /** 68 * Creates a copy of another ministring. This allocates71 * Creates a copy of another MiniString. This allocates 69 72 * s.length() + 1 bytes for the new instance. 70 73 * @param s 71 74 */ 72 ministring(const ministring &s)75 MiniString(const MiniString &s) 73 76 { 74 77 copyFrom(s); … … 76 79 77 80 /** 78 * Creates a copy of another ministring. This allocates81 * Creates a copy of another MiniString. This allocates 79 82 * strlen(pcsz) + 1 bytes for the new instance. 80 83 * @param pcsz 81 84 */ 82 ministring(const char *pcsz)85 MiniString(const char *pcsz) 83 86 { 84 87 copyFrom(pcsz); … … 88 91 * Destructor. 89 92 */ 90 virtual ~ ministring()93 virtual ~MiniString() 91 94 { 92 95 cleanup(); … … 149 152 * capacity() to find out how large that buffer is. 150 153 * 2) After any operation that modifies the length of the string, 151 * you _must_ call ministring::jolt(), or subsequent copy operations154 * you _must_ call MiniString::jolt(), or subsequent copy operations 152 155 * may go nowhere. Better not use mutableRaw() at all. 153 156 */ … … 182 185 * @return 183 186 */ 184 ministring& operator=(const char *pcsz)187 MiniString& operator=(const char *pcsz) 185 188 { 186 189 if (m_psz != pcsz) … … 197 200 * @return 198 201 */ 199 ministring& operator=(const ministring &s)202 MiniString& operator=(const MiniString &s) 200 203 { 201 204 if (this != &s) … … 211 214 * @param that 212 215 */ 213 void append(const ministring &that)216 void append(const MiniString &that) 214 217 { 215 218 size_t cbThis = length(); … … 290 293 } 291 294 292 int compare(const ministring &that, CaseSensitivity cs = CaseSensitive) const295 int compare(const MiniString &that, CaseSensitivity cs = CaseSensitive) const 293 296 { 294 297 return compare(that.m_psz, cs); 295 298 } 296 299 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; } 301 304 302 305 bool operator==(const char *that) const { return !compare(that); } … … 335 338 * after having called cleanup(). 336 339 * 337 * This variant copies from another ministring and is fast since340 * This variant copies from another MiniString and is fast since 338 341 * the length of source string is known. 339 342 * 340 343 * @param s 341 344 */ 342 void copyFrom(const ministring &s)345 void copyFrom(const MiniString &s) 343 346 { 344 347 if ((m_cbLength = s.m_cbLength)) … … 394 397 }; 395 398 399 } // namespace iprt 400 396 401 #endif -
trunk/include/iprt/xml_cpp.h
r21085 r21409 94 94 Error() {}; // hide the default constructor to make sure the extended one above is always used 95 95 96 ministring m_s;96 iprt::MiniString m_s; 97 97 }; 98 98 -
trunk/src/VBox/Runtime/r3/xml.cpp
r21322 r21409 1085 1085 { 1086 1086 xmlParserCtxtPtr ctxt; 1087 ministring strXmlFilename;1087 iprt::MiniString strXmlFilename; 1088 1088 1089 1089 Data() … … 1115 1115 { 1116 1116 File file; 1117 ministring error;1117 iprt::MiniString error; 1118 1118 1119 1119 IOContext(const char *pcszFilename, File::Mode mode) -
trunk/src/VBox/Runtime/testcase/tstUtf8.cpp
r21404 r21409 949 949 } while (0) 950 950 951 ministring empty;951 iprt::MiniString empty; 952 952 CHECK( (empty.length() == 0) ); 953 953 CHECK( (empty.capacity() == 0) ); 954 954 955 ministring sixbytes("12345");955 iprt::MiniString sixbytes("12345"); 956 956 CHECK( (sixbytes.length() == 5) ); 957 957 CHECK( (sixbytes.capacity() == 6) ); … … 970 970 CHECK( (sixbytes.capacity() == 7) ); 971 971 972 ministring morebytes("tobereplaced");972 iprt::MiniString morebytes("tobereplaced"); 973 973 morebytes = "newstring "; 974 974 morebytes.append(sixbytes); … … 976 976 CHECK_DUMP( (morebytes == "newstring 123456"), morebytes.c_str() ); 977 977 978 ministring third(morebytes);978 iprt::MiniString third(morebytes); 979 979 third.reserve(100 * 1024); // 100 KB 980 980 CHECK_DUMP( (third == "newstring 123456"), morebytes.c_str() ); … … 982 982 CHECK( (third.length() == morebytes.length()) ); // must not have changed 983 983 984 ministring copy1(morebytes);985 ministring copy2 = morebytes;984 iprt::MiniString copy1(morebytes); 985 iprt::MiniString copy2 = morebytes; 986 986 CHECK( (copy1 == copy2) ); 987 987 … … 992 992 CHECK( (copy1.length() == 0) ); 993 993 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")) ); 997 997 998 998 copy2.setNull();
Note:
See TracChangeset
for help on using the changeset viewer.