- Timestamp:
- Jun 30, 2009 3:59:22 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Config.kmk
r21077 r21079 490 490 ## Use the new version of liblzf. Remove with the old liblzf. 491 491 #VBOX_WITH_NEW_LIBLZF = 1 492 ## For experimenting with linking libxml2 into VBoxRT.493 VBOX_WITH_LIBXML2_IN_VBOXRT = 1494 492 495 493 ## For experimenting with disabling preemption instead of interrupts … … 1799 1797 # 1800 1798 SDK_VBOX_LIBXML2 = . 1801 #if1of ($(KBUILD_TARGET),win os2 solaris) 1802 SDK_VBOX_LIBXML2_INCS ?= $(PATH_ROOT)/src/libs/libxml2-2.6.30/include 1803 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT 1804 SDK_VBOX_LIBXML2_DEFS ?= _REENTRANT 1805 else 1806 SDK_VBOX_LIBXML2_DEFS ?= LIBXML_STATIC _REENTRANT 1807 SDK_VBOX_LIBXML2_LIBS ?= $(PATH_LIB)/VBox-libxml2$(VBOX_SUFF_LIB) 1808 endif 1809 SDK_VBOX_LIBXML2_DEFS.win += WIN32 _WINDOWS _MBCS 1810 #else if1of ($(KBUILD_TARGET),linux) 1811 # SDK_VBOX_LIBXML2_INCS ?= 1812 # SDK_VBOX_LIBXML2_LIBS ?= 1813 # SDK_VBOX_LIBXML2_CFLAGS ?= $(shell pkg-config libxml-2.0 --cflags) 1814 # SDK_VBOX_LIBXML2_CXXFLAGS ?= $(SDK_VBOX_LIBXML2_CFLAGS) 1815 # SDK_VBOX_LIBXML2_LDFLAGS ?= $(shell pkg-config libxml-2.0 --libs) 1816 #else 1817 # SDK_VBOX_LIBXML2_INCS ?= 1818 # SDK_VBOX_LIBXML2_LIBS ?= xml2 1819 #endif 1799 SDK_VBOX_LIBXML2_INCS ?= $(PATH_ROOT)/src/libs/libxml2-2.6.30/include 1800 SDK_VBOX_LIBXML2_DEFS ?= _REENTRANT 1801 SDK_VBOX_LIBXML2_DEFS.win += WIN32 _WINDOWS _MBCS 1802 # note: no linking to LIB here, we do that explicitly in src/VBox/Runtime/Makefile.kmk to link 1803 # libxml against VBoxRT 1820 1804 1821 1805 SDK_VBOX_LIBXSLT = . … … 1853 1837 SDK_VBOX_OPENSSL_INCS ?= $(SDK_VBOX_OPENSSL_VBOX_DEFAULT_INCS) 1854 1838 SDK_VBOX_OPENSSL_ORDERDEPS ?= $(crypto-headers_1_TARGET) 1855 ifndef VBOX_WITH_LIBXML2_IN_VBOXRT 1856 SDK_VBOX_OPENSSL_LIBS ?= $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB) 1857 endif 1839 SDK_VBOX_OPENSSL_LIBS ?= $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB) 1858 1840 # Build entire openssl library, not just the minimal subset. 1859 1841 if1of ($(KBUILD_TARGET), linux solaris) -
trunk/include/VBox/com/string.h
r21077 r21079 49 49 #include "VBox/com/assert.h" 50 50 51 #include <iprt/string.h>52 51 #include <iprt/cpputils.h> 53 52 #include <iprt/alloc.h> 53 #include <iprt/ministring_cpp.h> 54 54 55 55 namespace com … … 153 153 } 154 154 155 bool operator ==(const Bstr &that) const { return !compare (that.bstr); }156 bool operator !=(const Bstr &that) const { return !!compare (that.bstr); }157 bool operator ==(CBSTR that) const { return !compare (that); }158 bool operator ==(BSTR that) const { return !compare (that); }155 bool operator==(const Bstr &that) const { return !compare (that.bstr); } 156 bool operator!=(const Bstr &that) const { return !!compare (that.bstr); } 157 bool operator==(CBSTR that) const { return !compare (that); } 158 bool operator==(BSTR that) const { return !compare (that); } 159 159 160 160 #if defined (VBOX_WITH_XPCOM) 161 bool operator !=(const wchar_t *that) const161 bool operator!=(const wchar_t *that) const 162 162 { 163 163 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); 164 164 return !!compare ((CBSTR) that); 165 165 } 166 bool operator ==(const wchar_t *that) const166 bool operator==(const wchar_t *that) const 167 167 { 168 168 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); … … 171 171 #endif 172 172 173 bool operator !=(CBSTR that) const { return !!compare (that); }174 bool operator !=(BSTR that) const { return !!compare (that); }175 bool operator <(const Bstr &that) const { return compare (that.bstr) < 0; }176 bool operator <(CBSTR that) const { return compare (that) < 0; }177 bool operator <(BSTR that) const { return compare (that) < 0; }173 bool operator!=(CBSTR that) const { return !!compare (that); } 174 bool operator!=(BSTR that) const { return !!compare (that); } 175 bool operator<(const Bstr &that) const { return compare (that.bstr) < 0; } 176 bool operator<(CBSTR that) const { return compare (that) < 0; } 177 bool operator<(BSTR that) const { return compare (that) < 0; } 178 178 #if defined (VBOX_WITH_XPCOM) 179 bool operator <(const wchar_t *that) const179 bool operator<(const wchar_t *that) const 180 180 { 181 181 AssertCompile (sizeof (wchar_t) == sizeof (OLECHAR)); … … 303 303 304 304 /* symmetric compare operators */ 305 inline bool operator== 306 inline bool operator!= 307 inline bool operator== 308 inline bool operator!= 305 inline bool operator==(CBSTR l, const Bstr &r) { return r.operator== (l); } 306 inline bool operator!=(CBSTR l, const Bstr &r) { return r.operator!= (l); } 307 inline bool operator==(BSTR l, const Bstr &r) { return r.operator== (l); } 308 inline bool operator!=(BSTR l, const Bstr &r) { return r.operator!= (l); } 309 309 310 310 //////////////////////////////////////////////////////////////////////////////// … … 324 324 * afterwards. 325 325 */ 326 class Utf8Str 326 class Utf8Str : public ministring 327 327 { 328 328 public: 329 329 330 enum CaseSensitivity 331 { 332 CaseSensitive, 333 CaseInsensitive 334 }; 335 336 typedef char *String; 337 typedef const char *ConstString; 338 339 Utf8Str () : str (NULL) {} 340 341 Utf8Str (const Utf8Str &that) : str (NULL) { raw_copy (str, that.str); } 342 Utf8Str (const char *that) : str (NULL) { raw_copy (str, that); } 343 344 Utf8Str (const Bstr &that) : str (NULL) { raw_copy (str, that); } 345 Utf8Str (CBSTR that) : str (NULL) { raw_copy (str, that); } 346 347 /** Shortcut that calls #alloc(aSize) right after object creation. */ 348 Utf8Str (size_t aSize) : str (NULL) { alloc(aSize); } 349 350 virtual ~Utf8Str () { setNull(); } 351 352 Utf8Str &operator = (const Utf8Str &that) { safe_assign (that.str); return *this; } 353 Utf8Str &operator = (const char *that) { safe_assign (that); return *this; } 354 355 Utf8Str &operator = (const Bstr &that) 356 { 357 setNull(); 358 raw_copy (str, that); 359 return *this; 360 } 361 Utf8Str &operator = (CBSTR that) 362 { 363 setNull(); 364 raw_copy (str, that); 365 return *this; 366 } 367 368 Utf8Str &setNull() 369 { 370 if (str) 371 { 372 #if !defined (VBOX_WITH_XPCOM) 373 ::RTStrFree (str); 374 #else 375 nsMemory::Free (str); 376 #endif 377 str = NULL; 378 } 379 return *this; 380 } 381 382 Utf8Str &setNullIfEmpty() 383 { 384 if (str && *str == 0) 385 { 386 #if !defined (VBOX_WITH_XPCOM) 387 ::RTStrFree (str); 388 #else 389 nsMemory::Free (str); 390 #endif 391 str = NULL; 392 } 393 return *this; 394 } 395 396 /** 397 * Allocates memory for a string capable to store \a aSize - 1 bytes (not characters!); 398 * in other words, aSize includes the terminating zero character. If \a aSize 399 * is zero, or if a memory allocation error occurs, this object will become null. 400 */ 401 Utf8Str &alloc (size_t aSize) 402 { 403 setNull(); 404 if (aSize) 405 { 406 #if !defined (VBOX_WITH_XPCOM) 407 str = (char *) ::RTMemTmpAlloc (aSize); 408 #else 409 str = (char *) nsMemory::Alloc (aSize); 410 #endif 411 if (str) 412 str [0] = 0; 413 } 414 return *this; 415 } 416 417 void append(const Utf8Str &that) 418 { 419 size_t cbThis = length(); 420 size_t cbThat = that.length(); 421 422 if (cbThat) 423 { 424 size_t cbBoth = cbThis + cbThat + 1; 425 426 // @todo optimize with realloc() once the memory management is fixed 427 char *pszTemp; 428 #if !defined (VBOX_WITH_XPCOM) 429 pszTemp = (char*)::RTMemTmpAlloc(cbBoth); 430 #else 431 pszTemp = (char*)nsMemory::Alloc(cbBoth); 432 #endif 433 if (str) 434 { 435 memcpy(pszTemp, str, cbThis); 436 setNull(); 437 } 438 if (that.str) 439 memcpy(pszTemp + cbThis, that.str, cbThat); 440 pszTemp[cbThis + cbThat] = '\0'; 441 442 str = pszTemp; 443 } 444 } 445 446 int compare (const char *pcsz, CaseSensitivity cs = CaseSensitive) const 447 { 448 if (str == pcsz) 449 return 0; 450 if (str == NULL) 451 return -1; 452 if (pcsz == NULL) 453 return 1; 454 455 if (cs == CaseSensitive) 456 return ::RTStrCmp(str, pcsz); 457 else 458 return ::RTStrICmp(str, pcsz); 459 } 460 461 int compare (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 462 { 463 return compare (that.str, cs); 464 } 465 466 bool operator == (const Utf8Str &that) const { return !compare (that); } 467 bool operator != (const Utf8Str &that) const { return !!compare (that); } 468 bool operator == (const char *that) const { return !compare (that); } 469 bool operator != (const char *that) const { return !!compare (that); } 470 bool operator < (const Utf8Str &that) const { return compare (that) < 0; } 471 bool operator < (const char *that) const { return compare (that) < 0; } 472 473 bool endsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 474 { 475 if (isNull() || that.isNull()) 476 return false; 477 478 size_t l1 = length(); 479 size_t l2 = that.length(); 480 if (l1 < l2) 481 return false; 482 483 size_t l = l1 - l2; 484 if (cs == CaseSensitive) 485 return ::RTStrCmp(&str[l], that.str) == 0; 486 else 487 return ::RTStrICmp(&str[l], that.str) == 0; 488 } 489 490 bool startsWith (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 491 { 492 if (isNull() || that.isNull()) 493 return false; 494 495 size_t l1 = length(); 496 size_t l2 = that.length(); 497 if (l1 < l2) 498 return false; 499 500 if (cs == CaseSensitive) 501 return ::RTStrNCmp(str, that.str, l2) == 0; 502 else 503 return ::RTStrNICmp(str, that.str, l2) == 0; 504 } 505 506 bool contains (const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const 507 { 508 if (cs == CaseSensitive) 509 return ::RTStrStr (str, that.str) != NULL; 510 else 511 return ::RTStrIStr (str, that.str) != NULL; 512 } 513 514 Utf8Str& toLower() 515 { 516 if (isEmpty()) 517 return *this; 518 519 ::RTStrToLower(str); 520 521 return *this; 522 } 523 524 Utf8Str& toUpper() 525 { 526 if (isEmpty()) 527 return *this; 528 529 ::RTStrToUpper(str); 530 531 return *this; 532 } 533 534 bool isNull() const { return str == NULL; } 535 operator bool() const { return !isNull(); } 536 537 bool isEmpty() const { return isNull() || *str == 0; } 538 539 size_t length() const { return isNull() ? 0 : ::strlen (str); } 540 541 /** Intended to to pass instances as input (|char *|) parameters to methods. */ 542 operator const char *() const { return str; } 543 544 /** The same as operator const char *(), but for situations where the compiler 545 cannot typecast implicitly (for example, in printf() argument list). */ 546 const char *raw() const { return str; } 547 548 /** The same as operator const char *(), but for situations where the compiler 549 cannot typecast implicitly (for example, in printf() argument list). */ 550 const char *c_str() const { return str; } 551 552 /** 553 * Returns a non-const raw pointer that allows to modify the string directly. 554 * @warning 555 * Be sure not to modify data beyond the allocated memory! The 556 * guaranteed size of the allocated memory is at least #length() 557 * bytes after creation and after every assignment operation. 558 */ 559 char *mutableRaw() { return str; } 330 Utf8Str() {} 331 332 Utf8Str(const Utf8Str &that) 333 : ministring(that) 334 {} 335 336 Utf8Str(const char *that) 337 : ministring(that) 338 {} 339 340 Utf8Str(const Bstr &that) 341 { 342 copyFrom(that); 343 } 344 345 Utf8Str(CBSTR that) 346 { 347 copyFrom(that); 348 } 349 350 Utf8Str& operator=(const Utf8Str &that) 351 { 352 ministring::operator=(that); 353 return *this; 354 } 355 356 Utf8Str& operator=(const char *that) 357 { 358 ministring::operator=(that); 359 return *this; 360 } 361 362 Utf8Str& operator=(const Bstr &that) 363 { 364 cleanup(); 365 copyFrom(that); 366 return *this; 367 } 368 369 Utf8Str& operator=(CBSTR that) 370 { 371 cleanup(); 372 copyFrom(that); 373 return *this; 374 } 560 375 561 376 /** … … 564 379 * caller. 565 380 */ 566 const Utf8Str &cloneTo(char **pstr) const381 const Utf8Str& cloneTo(char **pstr) const 567 382 { 568 383 if (pstr) 569 { 570 *pstr = NULL; 571 raw_copy (*pstr, str); 572 } 384 *pstr = RTStrDup(m_psz); 573 385 return *this; 574 386 } … … 582 394 * string. 583 395 */ 584 Utf8Str &detachTo (char **pstr) 585 { 586 *pstr = str; 587 str = NULL; 396 Utf8Str& detachTo(char **pstr) 397 { 398 *pstr = m_psz; 399 m_psz = NULL; 400 m_cbAllocated = 0; 401 m_cbLength = 0; 588 402 return *this; 589 403 } … … 594 408 * caller. 595 409 */ 596 const Utf8Str &cloneTo(BSTR *pstr) const410 const Utf8Str& cloneTo(BSTR *pstr) const 597 411 { 598 412 if (pstr) 599 413 { 600 414 *pstr = NULL; 601 Bstr::raw_copy (*pstr, str);415 Bstr::raw_copy(*pstr, m_psz); 602 416 } 603 417 return *this; … … 623 437 624 438 /** 625 * Attempts to convert the member string into an 32-bit integer. 439 * Returns true if "this" ends with "that". 440 * @param that 441 * @param cs 442 * @return 443 */ 444 bool endsWith(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const; 445 446 /** 447 * Returns true if "this" begins with "that". 448 * @return 449 */ 450 bool startsWith(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const; 451 452 /** 453 * Returns true if "this" contains "that" (strstr). 454 * @param that 455 * @param cs 456 * @return 457 */ 458 bool contains(const Utf8Str &that, CaseSensitivity cs = CaseSensitive) const; 459 460 /** 461 * Converts "this" to lower case by calling RTStrToLower(). 462 * @return 463 */ 464 Utf8Str& toLower(); 465 466 /** 467 * Converts "this" to upper case by calling RTStrToUpper(). 468 * @return 469 */ 470 Utf8Str& toUpper(); 471 472 /** 473 * Removes a trailing slash from the member string, if present. 474 * Calls RTPathStripTrailingSlash() without having to mess with mutableRaw(). 475 */ 476 void stripTrailingSlash(); 477 478 /** 479 * Removes a trailing filename from the member string, if present. 480 * Calls RTPathStripFilename() without having to mess with mutableRaw(). 481 */ 482 void stripFilename(); 483 484 /** 485 * Removes a trailing file name extension from the member string, if present. 486 * Calls RTPathStripExt() without having to mess with mutableRaw(). 487 */ 488 void stripExt(); 489 490 /** 491 * Attempts to convert the member string into a 32-bit integer. 626 492 * 627 493 * @returns 32-bit unsigned number on success. … … 630 496 int toInt32() const 631 497 { 632 return RTStrToInt32( str);498 return RTStrToInt32(m_psz); 633 499 } 634 500 … … 641 507 int toUInt32() const 642 508 { 643 return RTStrToUInt32( str);509 return RTStrToUInt32(m_psz); 644 510 } 645 511 … … 652 518 int64_t toInt64() const 653 519 { 654 return RTStrToInt64( str);520 return RTStrToInt64(m_psz); 655 521 } 656 522 … … 663 529 uint64_t toUInt64() const 664 530 { 665 return RTStrToUInt64( str);531 return RTStrToUInt64(m_psz); 666 532 } 667 533 … … 684 550 * Takes the ownership of the returned data. 685 551 */ 686 char **asOutParam() { setNull(); return &str; } 552 char **asOutParam() 553 { 554 cleanup(); 555 return &m_psz; 556 } 687 557 688 558 /** … … 693 563 protected: 694 564 695 void safe_assign (const char *s) 696 { 697 if (str != s) 698 { 699 setNull(); 700 raw_copy (str, s); 701 } 702 } 703 704 inline static void raw_copy (char *&ls, const char *rs) 705 { 706 if (rs) 707 #if !defined (VBOX_WITH_XPCOM) 708 ::RTStrDupEx (&ls, rs); 709 #else 710 ls = (char *) nsMemory::Clone (rs, strlen (rs) + 1); 711 #endif 712 } 713 714 inline static void raw_copy (char *&ls, CBSTR rs) 715 { 716 if (rs) 717 { 718 #if !defined (VBOX_WITH_XPCOM) 719 ::RTUtf16ToUtf8 ((PRTUTF16) rs, &ls); 720 #else 721 char *s = NULL; 722 ::RTUtf16ToUtf8 ((PRTUTF16) rs, &s); 723 raw_copy (ls, s); 724 ::RTStrFree (s); 725 #endif 726 } 727 } 728 729 char *str; 565 /** 566 * As with the ministring::copyFrom() variants, this unconditionally 567 * sets the members to a copy of the given other strings and makes 568 * no assumptions about previous contents. This can therefore be used 569 * both in copy constructors, when member variables have no defined 570 * value, and in assignments after having called cleanup(). 571 * 572 * This variant converts from a UTF-16 string, most probably from 573 * a Bstr assignment. 574 * 575 * @param rs 576 */ 577 void copyFrom(CBSTR s) 578 { 579 if (s) 580 { 581 RTUtf16ToUtf8((PRTUTF16)s, &m_psz); 582 m_cbLength = strlen(m_psz); // TODO optimize by using a different RTUtf* function 583 m_cbAllocated = m_cbLength + 1; 584 } 585 else 586 { 587 m_cbLength = 0; 588 m_cbAllocated = 0; 589 m_psz = NULL; 590 } 591 } 730 592 731 593 friend class Bstr; /* to access our raw_copy() */ 732 594 }; 733 734 // symmetric compare operators735 inline bool operator== (const char *l, const Utf8Str &r) { return r.operator== (l); }736 inline bool operator!= (const char *l, const Utf8Str &r) { return r.operator!= (l); }737 595 738 596 // work around error C2593 of the stupid MSVC 7.x ambiguity resolver … … 760 618 } 761 619 762 inline const Bstr &Bstr::cloneTo (char **pstr) const 763 { 764 if (pstr) { 765 *pstr = NULL; 766 Utf8Str::raw_copy (*pstr, bstr); 620 inline const Bstr& Bstr::cloneTo(char **pstr) const 621 { 622 if (pstr) 623 { 624 Utf8Str ustr(*this); 625 ustr.detachTo(pstr); 767 626 } 768 627 return *this; -
trunk/include/VBox/settings.h
r21077 r21079 31 31 #define ___VBox_settings_h 32 32 33 #include <limits> 34 33 35 #include <iprt/cdefs.h> 34 36 #include <iprt/cpputils.h> 35 #include <iprt/string.h>36 37 #include <list>38 #include <memory>39 #include <limits>40 41 37 #include <iprt/time.h> 38 #include <iprt/xml_cpp.h> 42 39 43 40 #include <VBox/com/Guid.h> 44 45 #include <VBox/xml.h>46 47 // #include <stdarg.h>48 41 49 42 /* these conflict with numeric_digits<>::min and max */ -
trunk/include/iprt/xml_cpp.h
r21077 r21079 4 4 5 5 /* 6 * Copyright (C) 2007-200 8Sun Microsystems, Inc.6 * Copyright (C) 2007-2009 Sun Microsystems, Inc. 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 35 #else /* IN_RING3 */ 36 36 37 #include <list> 38 #include <memory> 39 40 #include <iprt/ministring_cpp.h> 41 37 42 /** @def IN_VBOXXML_R3 38 43 * Used to indicate whether we're inside the same link module as the … … 54 59 #endif 55 60 56 /*57 * Shut up MSVC complaining that auto_ptr[_ref] template instantiations (as a58 * result of private data member declarations of some classes below) need to59 * be exported too to in order to be accessible by clients.60 *61 * The alternative is to instantiate a template before the data member62 * declaration with the VBOXXML_CLASS prefix, but the standard disables63 * explicit instantiations in a foreign namespace. In other words, a declaration64 * like:65 *66 * template class VBOXXML_CLASS std::auto_ptr <Data>;67 *68 * right before the member declaration makes MSVC happy too, but this is not a69 * valid C++ construct (and G++ spits it out). So, for now we just disable the70 * warning and will come back to this problem one day later.71 *72 * We also disable another warning (4275) saying that a DLL-exported class73 * inherits form a non-DLL-exported one (e.g. settings::ENoMemory ->74 * std::bad_alloc). I can't get how it can harm yet.75 */76 #if defined(_MSC_VER)77 #pragma warning (disable:4251)78 #pragma warning (disable:4275)79 #endif80 81 61 /* Forwards */ 82 62 typedef struct _xmlParserInput xmlParserInput; … … 90 70 { 91 71 92 // Little string class for XML only72 // Exceptions 93 73 ////////////////////////////////////////////////////////////////////////////// 94 74 95 class ministring 96 { 97 public: 98 ministring() 99 : m_psz(NULL) 75 /** 76 * Base exception class. 77 */ 78 class VBOXXML_CLASS Error : public std::exception 79 { 80 public: 81 82 Error(const char *pcszMessage) 83 : m_s(pcszMessage) 100 84 { 101 85 } 102 86 103 ministring(const ministring &s) 104 : m_psz(NULL) 87 Error(const Error &s) 88 : std::exception(s), 89 m_s(s.what()) 105 90 { 106 copyFrom(s.c_str());107 }108 109 ministring(const char *pcsz)110 : m_psz(NULL)111 {112 copyFrom(pcsz);113 }114 115 ~ministring()116 {117 cleanup();118 }119 120 void operator=(const char *pcsz)121 {122 cleanup();123 copyFrom(pcsz);124 }125 126 void operator=(const ministring &s)127 {128 cleanup();129 copyFrom(s.c_str());130 }131 132 const char* c_str() const133 {134 return m_psz;135 }136 137 private:138 void cleanup()139 {140 if (m_psz)141 {142 RTStrFree(m_psz);143 m_psz = NULL;144 }145 }146 147 void copyFrom(const char *pcsz)148 {149 if (pcsz)150 m_psz = RTStrDup(pcsz);151 }152 153 154 char *m_psz;155 };156 157 // Exceptions158 //////////////////////////////////////////////////////////////////////////////159 160 /**161 * Base exception class.162 */163 class VBOXXML_CLASS Error : public std::exception164 {165 public:166 167 Error(const char *pcszMessage)168 : m_pcsz(NULL)169 {170 copyFrom(pcszMessage);171 }172 173 Error(const Error &s)174 : std::exception(s)175 {176 copyFrom(s.what());177 91 } 178 92 179 93 virtual ~Error() throw() 180 94 { 181 cleanup();182 95 } 183 96 184 97 void operator=(const Error &s) 185 98 { 186 cleanup(); 187 copyFrom(s.what()); 99 m_s = s.what(); 188 100 } 189 101 190 102 void setWhat(const char *pcszMessage) 191 103 { 192 cleanup(); 193 copyFrom(pcszMessage); 104 m_s = pcszMessage; 194 105 } 195 106 196 107 virtual const char* what() const throw() 197 108 { 198 return m_ pcsz;109 return m_s.c_str(); 199 110 } 200 111 … … 202 113 Error() {}; // hide the default constructor to make sure the extended one above is always used 203 114 204 void cleanup() 205 { 206 if (m_pcsz) 207 { 208 RTStrFree(m_pcsz); 209 m_pcsz = NULL; 210 } 211 } 212 213 void copyFrom(const char *pcszMessage) 214 { 215 if (pcszMessage) 216 m_pcsz = RTStrDup(pcszMessage); 217 } 218 219 char *m_pcsz; 115 ministring m_s; 220 116 }; 221 117 … … 468 364 /* Obscure class data */ 469 365 struct Data; 470 std::auto_ptr <Data>m;366 Data *m; 471 367 472 368 /* auto_ptr data doesn't have proper copy semantics */ … … 495 391 /* Obscure class data */ 496 392 struct Data; 497 std::auto_ptr <Data>m;393 Data *m; 498 394 499 395 /* auto_ptr data doesn't have proper copy semantics */ -
trunk/src/VBox/Main/ApplianceImpl.cpp
r21077 r21079 26 26 #include <iprt/file.h> 27 27 #include <iprt/s3.h> 28 #include "iprt/xml_cpp.h" 28 29 29 30 #include <VBox/param.h> … … 39 40 40 41 #include "Logging.h" 41 42 #include "VBox/xml.h"43 42 44 43 using namespace std; … … 234 233 // 235 234 //////////////////////////////////////////////////////////////////////////////// 236 237 static Utf8Str stripFilename(const Utf8Str &strFile)238 {239 Utf8Str str2(strFile);240 RTPathStripFilename(str2.mutableRaw());241 return str2;242 }243 235 244 236 static const struct … … 2246 2238 /* The disk image has to be on the same place as the OVF file. So 2247 2239 * strip the filename out of the full file path. */ 2248 Utf8Str strSrcDir = stripFilename(pAppliance->m->strPath); 2240 Utf8Str strSrcDir(pAppliance->m->strPath); 2241 strSrcDir.stripFilename(); 2249 2242 2250 2243 /* Iterate over all given disk images */ … … 3522 3515 const Utf8Str &strTargetFileNameOnly = pDiskEntry->strOvf; 3523 3516 // target path needs to be composed from where the output OVF is 3524 Utf8Str strTargetFilePath = stripFilename(m->strPath); 3517 Utf8Str strTargetFilePath(m->strPath); 3518 strTargetFilePath.stripFilename(); 3525 3519 strTargetFilePath.append("/"); 3526 3520 strTargetFilePath.append(strTargetFileNameOnly); … … 3721 3715 const Utf8Str &strTargetFileNameOnly = (*itH)->strOvf; 3722 3716 /* Target path needs to be composed from where the output OVF is */ 3723 Utf8Str strTargetFilePath = stripFilename(m->strPath); 3717 Utf8Str strTargetFilePath(m->strPath); 3718 strTargetFilePath.stripFilename(); 3724 3719 strTargetFilePath.append("/"); 3725 3720 strTargetFilePath.append(strTargetFileNameOnly); … … 4736 4731 4737 4732 Utf8Str strTargetVmdkName(bstrName); 4738 RTPathStripExt(strTargetVmdkName.mutableRaw());4733 strTargetVmdkName.stripExt(); 4739 4734 strTargetVmdkName.append(".vmdk"); 4740 4735 -
trunk/src/VBox/Main/ConsoleImpl.cpp
r21077 r21079 1073 1073 for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i) 1074 1074 { 1075 Utf8Buf. alloc(cchBuf + 1024);1075 Utf8Buf.reserve(cchBuf + 1024); 1076 1076 if (Utf8Buf.isNull()) 1077 1077 return E_OUTOFMEMORY; … … 1081 1081 vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3, 1082 1082 &parm[0]); 1083 Utf8Buf.jolt(); 1083 1084 if (parm[2].type != VBOX_HGCM_SVC_PARM_32BIT) 1084 1085 return setError (E_FAIL, tr ("Internal application error")); … … 1717 1718 { 1718 1719 Utf8Str dir = stateFilePath; 1719 RTPathStripFilename (dir.mutableRaw());1720 if (!RTDirExists 1720 dir.stripFilename(); 1721 if (!RTDirExists(dir)) 1721 1722 { 1722 1723 int vrc = RTDirCreateFullPath (dir, 0777); … … 3865 3866 3866 3867 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3867 /* To save doing a const cast, we use the mutableRaw() member. */ 3868 parm[0].u.pointer.addr = Utf8Name.mutableRaw(); 3868 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3869 3869 /* The + 1 is the null terminator */ 3870 3870 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; … … 3882 3882 if (vrc != VERR_NOT_FOUND) 3883 3883 { 3884 size_t iFlags = strlen(pszBuffer) + 1; 3885 Utf8Str(pszBuffer).cloneTo (aValue); 3884 Utf8Str strBuffer(pszBuffer); 3885 strBuffer.cloneTo(aValue); 3886 3886 3887 *aTimestamp = parm[2].u.uint64; 3887 Utf8Str(pszBuffer + iFlags).cloneTo (aFlags); 3888 3889 size_t iFlags = strBuffer.length() + 1; 3890 Utf8Str(pszBuffer + iFlags).cloneTo(aFlags); 3888 3891 } 3889 3892 else … … 3930 3933 3931 3934 parm[0].type = VBOX_HGCM_SVC_PARM_PTR; 3932 /* To save doing a const cast, we use the mutableRaw() member. */ 3933 parm[0].u.pointer.addr = Utf8Name.mutableRaw(); 3935 parm[0].u.pointer.addr = (void*)Utf8Name.c_str(); 3934 3936 /* The + 1 is the null terminator */ 3935 3937 parm[0].u.pointer.size = (uint32_t)Utf8Name.length() + 1; … … 3938 3940 { 3939 3941 parm[1].type = VBOX_HGCM_SVC_PARM_PTR; 3940 /* To save doing a const cast, we use the mutableRaw() member. */ 3941 parm[1].u.pointer.addr = Utf8Value.mutableRaw(); 3942 parm[1].u.pointer.addr = (void*)Utf8Value.c_str(); 3942 3943 /* The + 1 is the null terminator */ 3943 3944 parm[1].u.pointer.size = (uint32_t)Utf8Value.length() + 1; … … 3947 3948 { 3948 3949 parm[2].type = VBOX_HGCM_SVC_PARM_PTR; 3949 /* To save doing a const cast, we use the mutableRaw() member. */ 3950 parm[2].u.pointer.addr = Utf8Flags.mutableRaw(); 3950 parm[2].u.pointer.addr = (void*)Utf8Flags.c_str(); 3951 3951 /* The + 1 is the null terminator */ 3952 3952 parm[2].u.pointer.size = (uint32_t)Utf8Flags.length() + 1; -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r21077 r21079 1814 1814 { 1815 1815 /* Pull over the properties from the server. */ 1816 SafeArray 1817 SafeArray 1818 SafeArray 1819 SafeArray 1816 SafeArray<BSTR> namesOut; 1817 SafeArray<BSTR> valuesOut; 1818 SafeArray<ULONG64> timestampsOut; 1819 SafeArray<BSTR> flagsOut; 1820 1820 hrc = pConsole->mControl->PullGuestProperties(ComSafeArrayAsOutParam(namesOut), 1821 1821 ComSafeArrayAsOutParam(valuesOut), … … 1829 1829 rc = VERR_INVALID_PARAMETER; 1830 1830 1831 std::vector 1832 std::vector 1833 std::vector 1831 std::vector<Utf8Str> utf8Names, utf8Values, utf8Flags; 1832 std::vector<char *> names, values, flags; 1833 std::vector<ULONG64> timestamps; 1834 1834 for (unsigned i = 0; i < cProps && RT_SUCCESS(rc); ++i) 1835 1835 if ( !VALID_PTR(namesOut[i]) -
trunk/src/VBox/Main/MachineImpl.cpp
r21077 r21079 3450 3450 AssertReturn (!mData->mConfigFileFull.isNull(), VERR_GENERAL_FAILURE); 3451 3451 3452 Utf8Str s ettingsDir = mData->mConfigFileFull;3453 3454 RTPathStripFilename (settingsDir.mutableRaw());3455 char folder 3456 int vrc = RTPathAbsEx (settingsDir, aPath, folder, sizeof(folder));3457 if (RT_SUCCESS 3452 Utf8Str strSettingsDir = mData->mConfigFileFull; 3453 3454 strSettingsDir.stripFilename(); 3455 char folder[RTPATH_MAX]; 3456 int vrc = RTPathAbsEx(strSettingsDir, aPath, folder, sizeof(folder)); 3457 if (RT_SUCCESS(vrc)) 3458 3458 aResult = folder; 3459 3459 … … 3483 3483 Utf8Str settingsDir = mData->mConfigFileFull; 3484 3484 3485 RTPathStripFilename (settingsDir.mutableRaw());3486 if (RTPathStartsWith 3485 settingsDir.stripFilename(); 3486 if (RTPathStartsWith(aPath, settingsDir)) 3487 3487 { 3488 3488 /* when assigning, we create a separate Utf8Str instance because both … … 3491 3491 * first, and since its the same as aPath, an attempt to copy garbage 3492 3492 * will be made. */ 3493 aResult = Utf8Str 3493 aResult = Utf8Str(aPath + settingsDir.length() + 1); 3494 3494 } 3495 3495 } … … 5949 5949 /* first, rename the directory if it matches the machine name */ 5950 5950 configDir = configFile; 5951 RTPathStripFilename (configDir.mutableRaw());5951 configDir.stripFilename(); 5952 5952 newConfigDir = configDir; 5953 if (RTPathFilename 5953 if (RTPathFilename(configDir) == name) 5954 5954 { 5955 RTPathStripFilename (newConfigDir.mutableRaw());5955 newConfigDir.stripFilename(); 5956 5956 newConfigDir = Utf8StrFmt ("%s%c%s", 5957 5957 newConfigDir.raw(), RTPATH_DELIMITER, newName.raw()); … … 6078 6078 6079 6079 /* ensure the settings directory exists */ 6080 Utf8Str path = mData->mConfigFileFull;6081 RTPathStripFilename (path.mutableRaw());6082 if (!RTDirExists 6083 { 6084 vrc = RTDirCreateFullPath 6085 if (RT_FAILURE 6080 Utf8Str path(mData->mConfigFileFull); 6081 path.stripFilename(); 6082 if (!RTDirExists(path)) 6083 { 6084 vrc = RTDirCreateFullPath(path, 0777); 6085 if (RT_FAILURE(vrc)) 6086 6086 { 6087 6087 return setError (E_FAIL, … … 7655 7655 * @note Not thread safe (must be called from this object's lock). 7656 7656 */ 7657 bool Machine::isInOwnDir 7657 bool Machine::isInOwnDir(Utf8Str *aSettingsDir /* = NULL */) 7658 7658 { 7659 7659 Utf8Str settingsDir = mData->mConfigFileFull; 7660 RTPathStripFilename (settingsDir.mutableRaw());7661 char *dirName = RTPathFilename 7660 settingsDir.stripFilename(); 7661 char *dirName = RTPathFilename(settingsDir); 7662 7662 7663 7663 AssertReturn (dirName, false); -
trunk/src/VBox/Main/Makefile.kmk
r21077 r21079 519 519 include 520 520 VBoxSettings_SOURCES = \ 521 xml/xml.cpp \522 521 xml/Settings.cpp 523 522 VBoxSettings_LDFLAGS.darwin = -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/$(notdir $(LIB_SETTINGS)) -Wl,-x # no debug info please. -
trunk/src/VBox/Main/SharedFolderImpl.cpp
r21077 r21079 28 28 29 29 #include <iprt/param.h> 30 #include <iprt/cpputils.h> 30 31 #include <iprt/path.h> 31 #include <iprt/cpputils.h>32 32 33 33 // constructor / destructor … … 199 199 ; 200 200 #else 201 if (hostPathLen == 1 && RTPATH_IS_SEP 201 if (hostPathLen == 1 && RTPATH_IS_SEP(hostPath[0])) 202 202 ; 203 203 #endif 204 204 else 205 RTPathStripTrailingSlash (hostPath.mutableRaw());205 hostPath.stripTrailingSlash(); 206 206 207 207 /* Check whether the path is full (absolute) */ -
trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp
r21077 r21079 156 156 AssertComRC (rc); 157 157 Utf8Str message; 158 rc = aInfo->GetMessage (message.asOutParam()); 158 rc = aInfo->GetMessage(message.asOutParam()); 159 message.jolt(); 159 160 AssertComRC (rc); 160 161 mText = message; -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r21077 r21079 3870 3870 HRESULT VirtualBox::ensureFilePathExists (const char *aFileName) 3871 3871 { 3872 Utf8Str dir = aFileName;3873 RTPathStripFilename (dir.mutableRaw());3874 if (!RTDirExists (dir))3875 { 3876 int vrc = RTDirCreateFullPath (dir, 0777);3872 Utf8Str strDir(aFileName); 3873 strDir.stripFilename(); 3874 if (!RTDirExists(strDir)) 3875 { 3876 int vrc = RTDirCreateFullPath(strDir, 0777); 3877 3877 if (RT_FAILURE (vrc)) 3878 3878 { 3879 3879 return setError (E_FAIL, 3880 3880 tr ("Could not create the directory '%s' (%Rrc)"), 3881 dir.raw(), vrc);3881 strDir.c_str(), vrc); 3882 3882 } 3883 3883 } -
trunk/src/VBox/Main/glue/ErrorInfo.cpp
r21077 r21079 118 118 119 119 Utf8Str message; 120 rc = ex->GetMessage (message.asOutParam()); 120 rc = ex->GetMessage(message.asOutParam()); 121 message.jolt(); 121 122 gotSomething |= NS_SUCCEEDED (rc); 122 123 if (NS_SUCCEEDED (rc)) -
trunk/src/VBox/Main/glue/VirtualBoxErrorInfo.cpp
r21077 r21079 179 179 AssertComRC (rc); 180 180 Utf8Str message; 181 rc = aInfo->GetMessage (message.asOutParam()); 181 rc = aInfo->GetMessage(message.asOutParam()); 182 message.jolt(); 182 183 AssertComRC (rc); 183 184 mText = message; -
trunk/src/VBox/Main/glue/string.cpp
r21077 r21079 26 26 27 27 #include <iprt/err.h> 28 #include <iprt/path.h> 28 29 29 30 namespace com … … 85 86 86 87 size_t cbCopy = psz - pFirst; 87 ret. alloc(cbCopy + 1);88 memcpy(ret. str, pFirst, cbCopy);89 ret. str[cbCopy] = '\0';88 ret.reserve(cbCopy + 1); 89 memcpy(ret.m_psz, pFirst, cbCopy); 90 ret.m_psz[cbCopy] = '\0'; 90 91 } 91 92 } … … 95 96 } 96 97 98 bool Utf8Str::endsWith(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const 99 { 100 size_t l1 = length(); 101 if (l1 == 0) 102 return false; 103 104 size_t l2 = that.length(); 105 if (l1 < l2) 106 return false; 107 108 size_t l = l1 - l2; 109 if (cs == CaseSensitive) 110 return ::RTStrCmp(&m_psz[l], that.m_psz) == 0; 111 else 112 return ::RTStrICmp(&m_psz[l], that.m_psz) == 0; 113 } 114 115 bool Utf8Str::startsWith(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const 116 { 117 size_t l1 = length(); 118 size_t l2 = that.length(); 119 if (l1 == 0 || l2 == 0) 120 return false; 121 122 if (l1 < l2) 123 return false; 124 125 if (cs == CaseSensitive) 126 return ::RTStrNCmp(m_psz, that.m_psz, l2) == 0; 127 else 128 return ::RTStrNICmp(m_psz, that.m_psz, l2) == 0; 129 } 130 131 bool Utf8Str::contains(const Utf8Str &that, CaseSensitivity cs /*= CaseSensitive*/) const 132 { 133 if (cs == CaseSensitive) 134 return ::RTStrStr(m_psz, that.m_psz) != NULL; 135 else 136 return ::RTStrIStr(m_psz, that.m_psz) != NULL; 137 } 138 139 Utf8Str& Utf8Str::toLower() 140 { 141 if (!isEmpty()) 142 ::RTStrToLower(m_psz); 143 return *this; 144 } 145 146 Utf8Str& Utf8Str::toUpper() 147 { 148 if (!isEmpty()) 149 ::RTStrToUpper(m_psz); 150 return *this; 151 } 152 153 void Utf8Str::stripTrailingSlash() 154 { 155 RTPathStripTrailingSlash(m_psz); 156 jolt(); 157 } 158 159 void Utf8Str::stripFilename() 160 { 161 RTPathStripFilename(m_psz); 162 jolt(); 163 } 164 165 void Utf8Str::stripExt() 166 { 167 RTPathStripExt(m_psz); 168 jolt(); 169 } 170 97 171 int Utf8Str::toInt(uint64_t &i) const 98 172 { 99 if (! str)173 if (!m_psz) 100 174 return VERR_NO_DIGITS; 101 return RTStrToUInt64Ex( str, NULL, 0, &i);175 return RTStrToUInt64Ex(m_psz, NULL, 0, &i); 102 176 } 103 177 104 178 int Utf8Str::toInt(uint32_t &i) const 105 179 { 106 if (! str)180 if (!m_psz) 107 181 return VERR_NO_DIGITS; 108 return RTStrToUInt32Ex( str, NULL, 0, &i);182 return RTStrToUInt32Ex(m_psz, NULL, 0, &i); 109 183 } 110 184 -
trunk/src/VBox/Main/include/ApplianceImpl.h
r21077 r21079 92 92 const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox; 93 93 94 struct Data; // o bscure, defined in AppliannceImpl.cpp94 struct Data; // opaque, defined in ApplianceImpl.cpp 95 95 Data *m; 96 96 -
trunk/src/VBox/Main/webservice/vboxweb.cpp
r21077 r21079 603 603 * @return 604 604 */ 605 std::string ConvertComString(const com::Guid &bstr) 606 { 605 std::string ConvertComString(const com::Guid &uuid) 606 { 607 com::Bstr bstr(uuid); 607 608 com::Utf8Str ustr(bstr); 608 609 const char *pcsz; -
trunk/src/VBox/Runtime/Makefile.kmk
r21077 r21079 51 51 LIBRARIES += RuntimeR3 52 52 DLLS += VBoxRT 53 54 # Temporary(?) hack.55 VBOX_WITH_LIBXML2_IN_VBOXRT=56 53 57 54 else # !VBOX_ONLY_ADDITIONS && !VBOX_ONLY_DOCS … … 165 162 # 166 163 RuntimeR3_TEMPLATE = VBOXR3STATIC 164 RuntimeR3_SDKS = VBOX_LIBXML2 167 165 RuntimeR3_SDKS.win = WINPSDK W2K3DDK 168 166 RuntimeR3_DEFS = IN_RT_R3 IN_SUP_R3 LDR_WITH_NATIVE LDR_WITH_ELF32 LDR_WITH_PE RT_WITH_VBOX RT_NO_GIP … … 306 304 r3/test.cpp \ 307 305 r3/testi.cpp \ 308 r3/tcp.cpp 306 r3/tcp.cpp \ 307 r3/xml.cpp 309 308 310 309 #if1of ($(KBUILD_TARGET_ARCH),amd64 x86) … … 787 786 # 788 787 VBoxRT_TEMPLATE = VBOXR3 789 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT790 788 VBoxRT_SDKS = VBOX_OPENSSL VBOX_LIBXML2 VBOX_LIBCURL 791 endif792 789 VBoxRT_SDKS.win = WINPSDK W2K3DDK VBOX_NTDLL 793 790 ifeq ($(KBUILD_TARGET)$(VBOX_WITH_HARDENING),darwin) … … 799 796 VBox/VBoxRTDeps.cpp \ 800 797 $(RuntimeR3_SOURCES) 801 if defined(VBOX_WITH_LIBXML2_IN_VBOXRT)802 798 VBoxRT_SOURCES += \ 803 799 common/misc/s3.cpp 804 endif805 800 VBoxRT_SOURCES.$(KBUILD_TARGET) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET)) 806 801 VBoxRT_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) = $(RuntimeR3_SOURCES.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH)) … … 818 813 $(PATH_LIB)/VBox-kStuff$(VBOX_SUFF_LIB) 819 814 endif 820 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT 821 ifndef SDK_VBOX_LIBXML2_LIBS 822 VBoxRT_LIBS += \ 815 ifndef SDK_VBOX_LIBXML2_LIBS 816 VBoxRT_LIBS += \ 823 817 $(PATH_LIB)/VBox-libxml2$(VBOX_SUFF_LIB) 824 825 826 818 endif 819 ifndef SDK_VBOX_OPENSSL_LIBS 820 VBoxRT_LIBS += \ 827 821 $(PATH_LIB)/VBox-libcrypto$(VBOX_SUFF_LIB) 828 endif829 822 endif 830 823 VBoxRT_LIBS.darwin = \ … … 851 844 $(PATH_LIB)/RuntimeR3L4$(VBOX_SUFF_LIB) 852 845 853 ifdef VBOX_WITH_LIBXML2_IN_VBOXRT854 VBox/VBoxRTDeps.cpp_DEFS = VBOX_WITH_LIBXML2_IN_VBOXRT855 endif856 857 846 if1of ($(DLLS), VBoxRT) 858 847 $$(VBoxRT_0_OUTDIR)/VBoxRT.def: \ 859 848 $(PATH_SUB_CURRENT)/r3/win/VBoxRT-$$(if-expr $$(KBUILD_TARGET_ARCH) == amd64,win64,win32).def \ 860 $( if-expr defined(VBOX_WITH_LIBXML2_IN_VBOXRT),$(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def),)849 $(PATH_SUB_CURRENT)/r3/win/$(if $(VBOX_OSE),VBoxRT-openssl-ose.def,VBoxRT-openssl.def) 861 850 $(RM) -f -- $@ 862 851 $(REDIRECT) -wto $@ -- $(CAT_EXT) $^ -
trunk/src/VBox/Runtime/VBox/VBoxRTDeps.cpp
r21077 r21079 36 36 #include <iprt/assert.h> 37 37 #include <iprt/asm.h> 38 #ifdef VBOX_WITH_LIBXML2_IN_VBOXRT 38 39 39 # include <libxml/xmlmodule.h> 40 40 # include <libxml/globals.h> … … 44 44 # include <openssl/x509.h> 45 45 # include <openssl/rsa.h> 46 #endif47 46 48 47 … … 55 54 (PFNRT)SUPR3PageAllocEx, 56 55 (PFNRT)SUPSemEventCreate, 57 #ifdef VBOX_WITH_LIBXML2_IN_VBOXRT58 56 (PFNRT)xmlModuleOpen, 59 57 (PFNRT)MD5_Init, … … 65 63 (PFNRT)i2d_X509, 66 64 (PFNRT)RSA_generate_key, 67 #endif68 65 (PFNRT)RTAssertShouldPanic, 69 66 (PFNRT)ASMAtomicReadU64, -
trunk/src/VBox/Runtime/r3/xml.cpp
r21077 r21079 19 19 */ 20 20 21 #include "Logging.h"22 23 21 #include <iprt/cdefs.h> 24 22 #include <iprt/err.h> 25 23 #include <iprt/file.h> 26 24 #include <iprt/lock.h> 27 #include <iprt/ string.h>25 #include <iprt/xml_cpp.h> 28 26 29 27 #include <libxml/tree.h> … … 36 34 #include <libxml/xmlschemas.h> 37 35 38 #include <list>39 36 #include <map> 40 37 #include <boost/shared_ptr.hpp> 41 42 #include "VBox/xml.h"43 38 44 39 //////////////////////////////////////////////////////////////////////////////// … … 991 986 { 992 987 m->copyFrom(x.m); 993 } ;988 } 994 989 995 990 Document& Document::operator=(const Document &x) … … 998 993 m->copyFrom(x.m); 999 994 return *this; 1000 } ;995 } 1001 996 1002 997 Document::~Document() -
trunk/src/VBox/Runtime/testcase/tstUtf8.cpp
r21077 r21079 42 42 #include <iprt/err.h> 43 43 #include <iprt/test.h> 44 #include <iprt/ministring_cpp.h> 44 45 45 46 #include <stdlib.h> /** @todo use our random. */ … … 926 927 927 928 929 void testMinistring(RTTEST hTest) 930 { 931 RTTestSub(hTest, "class ministring"); 932 933 #define CHECK(expr) \ 934 do { \ 935 if (!(expr)) \ 936 RTTestFailed(hTest, "%d: FAILED %s", __LINE__, #expr); \ 937 } while (0) 938 939 #define CHECK_DUMP(expr, value) \ 940 do { \ 941 if (!(expr)) \ 942 RTTestFailed(hTest, "%d: FAILED %s, got \"%s\"", __LINE__, #expr, value); \ 943 } while (0) 944 945 #define CHECK_DUMP_I(expr) \ 946 do { \ 947 if (!(expr)) \ 948 RTTestFailed(hTest, "%d: FAILED %s, got \"%d\"", __LINE__, #expr, expr); \ 949 } while (0) 950 951 ministring empty; 952 CHECK( (empty.length() == 0) ); 953 CHECK( (empty.capacity() == 0) ); 954 955 ministring sixbytes("12345"); 956 CHECK( (sixbytes.length() == 5) ); 957 CHECK( (sixbytes.capacity() == 6) ); 958 959 sixbytes.append("678"); 960 CHECK( (sixbytes.length() == 8) ); 961 CHECK( (sixbytes.capacity() == 9) ); 962 963 char *psz = sixbytes.mutableRaw(); 964 // 12345678 965 // ^ 966 // 0123456 967 psz[6] = '\0'; 968 sixbytes.jolt(); 969 CHECK( (sixbytes.length() == 6) ); 970 CHECK( (sixbytes.capacity() == 7) ); 971 972 ministring morebytes("tobereplaced"); 973 morebytes = "newstring "; 974 morebytes.append(sixbytes); 975 976 CHECK_DUMP( (morebytes == "newstring 123456"), morebytes.c_str() ); 977 978 ministring third(morebytes); 979 third.reserve(100 * 1024); // 100 KB 980 CHECK_DUMP( (third == "newstring 123456"), morebytes.c_str() ); 981 CHECK( (third.capacity() == 100 * 1024) ); 982 CHECK( (third.length() == morebytes.length()) ); // must not have changed 983 984 ministring copy1(morebytes); 985 ministring copy2 = morebytes; 986 CHECK( (copy1 == copy2) ); 987 988 copy1 = NULL; 989 CHECK( (copy1.isNull()) ); 990 991 copy1 = ""; 992 CHECK( (copy1.isEmpty()) ); 993 994 CHECK( (ministring("abc") < ministring("def")) ); 995 CHECK( (ministring("abc") != ministring("def")) ); 996 CHECK_DUMP_I( (ministring("def") > ministring("abc")) ); 997 998 copy2.setNull(); 999 for (int i = 0; 1000 i < 100; 1001 ++i) 1002 { 1003 copy2.reserve(50); // should be ignored after 50 loops 1004 copy2.append("1"); 1005 } 1006 CHECK( (copy2.length() == 100) ); 1007 1008 #undef CHECK 1009 } 1010 928 1011 int main() 929 1012 { … … 946 1029 TstRTStrXCmp(hTest); 947 1030 testStrStr(hTest); 1031 1032 testMinistring(hTest); 1033 948 1034 Benchmarks(hTest); 949 1035
Note:
See TracChangeset
for help on using the changeset viewer.