Changeset 16539 in vbox for trunk/include/VBox
- Timestamp:
- Feb 5, 2009 11:31:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/xml.h
r16538 r16539 31 31 #define ___VBox_vboxxml_h 32 32 33 #include <iprt/cdefs.h>34 #include <iprt/cpputils.h>35 36 /* these conflict with numeric_digits<>::min and max */37 #undef min38 #undef max39 40 #include <iprt/mem.h>41 42 33 #ifndef IN_RING3 43 34 # error "There are no XML APIs available in Ring-0 Context!" … … 112 103 113 104 Error(const char *aMsg = NULL) 114 : m (aMsg ? Str::New (aMsg) : NULL) {}105 : m(aMsg) {} 115 106 116 107 virtual ~Error() throw() {} 117 108 118 void setWhat (const char *aMsg) { m = aMsg ? Str::New (aMsg) : NULL; }119 120 const char *what() const throw() { return m.is_null() ? NULL : m->str; }109 void setWhat (const char *aMsg) { m = aMsg; } 110 111 const char* what() const throw() { return m.c_str(); } 121 112 122 113 private: … … 124 115 // Error() {}; // hide the default constructor to make sure the extended one above is always used 125 116 126 /** smart string with support for reference counting */ 127 struct Str 128 { 129 size_t ref() { return ++ refs; } 130 size_t unref() { return -- refs; } 131 132 size_t refs; 133 char str [1]; 134 135 static Str *New (const char *aStr) 136 { 137 Str *that = (Str *) RTMemAllocZ (sizeof (Str) + strlen (aStr)); 138 AssertReturn (that, NULL); 139 strcpy (that->str, aStr); 140 return that; 141 } 142 143 void operator delete (void *that, size_t) { RTMemFree (that); } 144 }; 145 146 stdx::auto_ref_ptr <Str> m; 117 com::Utf8Str m; 147 118 }; 148 119
Note:
See TracChangeset
for help on using the changeset viewer.