Changeset 16557 in vbox
- Timestamp:
- Feb 6, 2009 4:35:42 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 23 edited
-
include/VBox/settings.h (modified) (2 diffs)
-
src/VBox/Main/AudioAdapterImpl.cpp (modified) (1 diff)
-
src/VBox/Main/BIOSSettingsImpl.cpp (modified) (1 diff)
-
src/VBox/Main/DVDDriveImpl.cpp (modified) (1 diff)
-
src/VBox/Main/FloppyDriveImpl.cpp (modified) (1 diff)
-
src/VBox/Main/HardDisk2Impl.cpp (modified) (1 diff)
-
src/VBox/Main/HostImpl.cpp (modified) (2 diffs)
-
src/VBox/Main/MachineImpl.cpp (modified) (2 diffs)
-
src/VBox/Main/MediumImpl.cpp (modified) (1 diff)
-
src/VBox/Main/NetworkAdapterImpl.cpp (modified) (1 diff)
-
src/VBox/Main/ParallelPortImpl.cpp (modified) (1 diff)
-
src/VBox/Main/PerformanceImpl.cpp (modified) (1 diff)
-
src/VBox/Main/SATAControllerImpl.cpp (modified) (2 diffs)
-
src/VBox/Main/SerialPortImpl.cpp (modified) (1 diff)
-
src/VBox/Main/SystemPropertiesImpl.cpp (modified) (1 diff)
-
src/VBox/Main/USBControllerImpl.cpp (modified) (1 diff)
-
src/VBox/Main/VirtualBoxBase.cpp (modified) (1 diff)
-
src/VBox/Main/VirtualBoxImpl.cpp (modified) (2 diffs)
-
src/VBox/Main/VirtualBoxImplExtra.cpp (modified) (4 diffs)
-
src/VBox/Main/include/ApplianceImpl.h (modified) (1 diff)
-
src/VBox/Main/include/VirtualBoxBase.h (modified) (3 diffs)
-
src/VBox/Main/include/VirtualBoxImpl.h (modified) (2 diffs)
-
src/VBox/Main/include/VirtualBoxImplExtra.h (added)
-
src/VBox/Main/xml/Settings.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r16538 r16557 44 44 45 45 #include <iprt/time.h> 46 47 #include <VBox/com/Guid.h> 46 48 47 49 #include <VBox/xml.h> … … 439 441 */ 440 442 DECLEXPORT (stdx::char_auto_ptr) ToString (const void *aData, size_t aLen); 443 444 #if defined VBOX_MAIN_SETTINGS_ADDONS 445 446 /// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the 447 /// code below 448 449 #if 0 450 451 /** Specialization of FromString for Bstr. */ 452 template<> com::Bstr FromString <com::Bstr> (const char *aValue); 453 454 #endif 455 456 /** Specialization of ToString for Bstr. */ 457 template<> stdx::char_auto_ptr 458 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra); 459 460 /** Specialization of FromString for Guid. */ 461 template<> com::Guid FromString <com::Guid> (const char *aValue); 462 463 /** Specialization of ToString for Guid. */ 464 template<> stdx::char_auto_ptr 465 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra); 466 467 #endif // VBOX_MAIN_SETTINGS_ADDONS 441 468 442 469 // the rest -
trunk/src/VBox/Main/AudioAdapterImpl.cpp
r14972 r16557 25 25 26 26 #include <iprt/cpputils.h> 27 28 #include <VBox/settings.h> 27 29 28 30 // constructor / destructor -
trunk/src/VBox/Main/BIOSSettingsImpl.cpp
r15051 r16557 24 24 #include "Logging.h" 25 25 #include "GuestOSTypeImpl.h" 26 26 27 #include <iprt/cpputils.h> 28 #include <VBox/settings.h> 27 29 28 30 // constructor / destructor -
trunk/src/VBox/Main/DVDDriveImpl.cpp
r15991 r16557 35 35 #include <iprt/string.h> 36 36 #include <iprt/cpputils.h> 37 38 #include <VBox/settings.h> 37 39 38 40 // constructor / destructor -
trunk/src/VBox/Main/FloppyDriveImpl.cpp
r15991 r16557 35 35 #include <iprt/string.h> 36 36 #include <iprt/cpputils.h> 37 38 #include <VBox/settings.h> 37 39 38 40 // constructor / destructor -
trunk/src/VBox/Main/HardDisk2Impl.cpp
r16118 r16557 33 33 34 34 #include <VBox/err.h> 35 #include <VBox/settings.h> 35 36 36 37 #include <iprt/param.h> -
trunk/src/VBox/Main/HostImpl.cpp
r16289 r16557 102 102 103 103 104 #include <VBox/usb.h>105 #include <VBox/x86.h>106 #include <VBox/err.h>107 104 #include <iprt/asm.h> 108 105 #include <iprt/string.h> … … 119 116 #include "netif.h" 120 117 #endif 118 119 #include <VBox/usb.h> 120 #include <VBox/x86.h> 121 #include <VBox/err.h> 122 #include <VBox/settings.h> 121 123 122 124 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) -
trunk/src/VBox/Main/MachineImpl.cpp
r16244 r16557 27 27 #ifndef __STDC_CONSTANT_MACROS 28 28 # define __STDC_CONSTANT_MACROS 29 #endif30 31 #if defined(RT_OS_WINDOWS)32 #elif defined(RT_OS_LINUX)33 29 #endif 34 30 … … 77 73 #include <VBox/err.h> 78 74 #include <VBox/param.h> 75 #include <VBox/settings.h> 76 79 77 #ifdef VBOX_WITH_GUEST_PROPS 80 78 # include <VBox/HostServices/GuestPropertySvc.h> -
trunk/src/VBox/Main/MediumImpl.cpp
r15215 r16557 30 30 #include <VBox/com/array.h> 31 31 32 #include <VBox/err.h> 33 #include <VBox/settings.h> 34 32 35 #include <iprt/param.h> 33 36 #include <iprt/path.h> 34 37 #include <iprt/file.h> 35 36 #include <VBox/err.h>37 38 38 39 //////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r16509 r16557 29 29 30 30 #include <VBox/err.h> 31 #include <VBox/settings.h> 31 32 32 33 // constructor / destructor -
trunk/src/VBox/Main/ParallelPortImpl.cpp
r15051 r16557 27 27 #include <iprt/string.h> 28 28 #include <iprt/cpputils.h> 29 30 #include <VBox/settings.h> 29 31 30 32 // constructor / destructor -
trunk/src/VBox/Main/PerformanceImpl.cpp
r15051 r16557 22 22 */ 23 23 24 #if defined(RT_OS_WINDOWS)25 #elif defined(RT_OS_LINUX)26 #endif27 28 24 #include "PerformanceImpl.h" 29 25 30 26 #include "Logging.h" 31 27 28 #include <iprt/process.h> 29 32 30 #include <VBox/err.h> 33 #include < iprt/process.h>31 #include <VBox/settings.h> 34 32 35 33 #include <vector> -
trunk/src/VBox/Main/SATAControllerImpl.cpp
r14972 r16557 22 22 */ 23 23 24 25 26 24 #include "SATAControllerImpl.h" 27 25 #include "MachineImpl.h" … … 31 29 #include <iprt/string.h> 32 30 #include <iprt/cpputils.h> 31 33 32 #include <VBox/err.h> 33 #include <VBox/settings.h> 34 34 35 35 #include <algorithm> -
trunk/src/VBox/Main/SerialPortImpl.cpp
r15051 r16557 27 27 #include <iprt/string.h> 28 28 #include <iprt/cpputils.h> 29 30 #include <VBox/settings.h> 29 31 30 32 // constructor / destructor -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r16081 r16557 32 32 #include <iprt/path.h> 33 33 #include <iprt/dir.h> 34 35 #include <VBox/err.h> 34 36 #include <VBox/param.h> 35 #include <VBox/ err.h>37 #include <VBox/settings.h> 36 38 37 39 // defines -
trunk/src/VBox/Main/USBControllerImpl.cpp
r15829 r16557 33 33 #include "Logging.h" 34 34 35 36 35 #include <iprt/string.h> 37 36 #include <iprt/cpputils.h> 37 38 38 #include <VBox/err.h> 39 #include <VBox/settings.h> 39 40 40 41 #include <algorithm> -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r16538 r16557 1214 1214 } 1215 1215 1216 // Settings API additions 1217 //////////////////////////////////////////////////////////////////////////////// 1218 1219 #if defined VBOX_MAIN_SETTINGS_ADDONS 1220 1221 namespace settings 1222 { 1223 1224 template<> stdx::char_auto_ptr 1225 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra) 1226 { 1227 stdx::char_auto_ptr result; 1228 1229 if (aValue.raw() == NULL) 1230 throw ENoValue(); 1231 1232 /* The only way to cause RTUtf16ToUtf8Ex return a number of bytes needed 1233 * w/o allocating the result buffer itself is to provide that both cch 1234 * and *ppsz are not NULL. */ 1235 char dummy [1]; 1236 char *dummy2 = dummy; 1237 size_t strLen = 1; 1238 1239 int vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, 1240 &dummy2, strLen, &strLen); 1241 if (RT_SUCCESS (vrc)) 1242 { 1243 /* the string only contains '\0' :) */ 1244 result.reset (new char [1]); 1245 result.get() [0] = '\0'; 1246 return result; 1247 } 1248 1249 if (vrc == VERR_BUFFER_OVERFLOW) 1250 { 1251 result.reset (new char [strLen + 1]); 1252 char *buf = result.get(); 1253 vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, &buf, strLen + 1, NULL); 1254 } 1255 1256 if (RT_FAILURE (vrc)) 1257 throw xml::LogicError (RT_SRC_POS); 1258 1259 return result; 1260 } 1261 1262 template<> com::Guid FromString <com::Guid> (const char *aValue) 1263 { 1264 if (aValue == NULL) 1265 throw ENoValue(); 1266 1267 /* For settings, the format is always {XXX...XXX} */ 1268 char buf [RTUUID_STR_LENGTH]; 1269 if (aValue == NULL || *aValue != '{' || 1270 strlen (aValue) != RTUUID_STR_LENGTH + 1 || 1271 aValue [RTUUID_STR_LENGTH] != '}') 1272 throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid", aValue)); 1273 1274 /* strip { and } */ 1275 memcpy (buf, aValue + 1, RTUUID_STR_LENGTH - 1); 1276 buf [RTUUID_STR_LENGTH - 1] = '\0'; 1277 /* we don't use Guid (const char *) because we want to throw 1278 * ENoConversion on format error */ 1279 RTUUID uuid; 1280 int vrc = RTUuidFromStr (&uuid, buf); 1281 if (RT_FAILURE (vrc)) 1282 throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid (%Rrc)", aValue, vrc)); 1283 1284 return com::Guid (uuid); 1285 } 1286 1287 template<> stdx::char_auto_ptr 1288 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra) 1289 { 1290 /* For settings, the format is always {XXX...XXX} */ 1291 stdx::char_auto_ptr result (new char [RTUUID_STR_LENGTH + 2]); 1292 1293 int vrc = RTUuidToStr (aValue.raw(), result.get() + 1, RTUUID_STR_LENGTH); 1294 if (RT_FAILURE (vrc)) 1295 throw xml::LogicError (RT_SRC_POS); 1296 1297 result.get() [0] = '{'; 1298 result.get() [RTUUID_STR_LENGTH] = '}'; 1299 result.get() [RTUUID_STR_LENGTH + 1] = '\0'; 1300 1301 return result; 1302 } 1303 1304 } /* namespace settings */ 1305 1306 #endif /* VBOX_MAIN_SETTINGS_ADDONS */ 1307 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ 1216 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r16216 r16557 21 21 */ 22 22 23 #include <iprt/path.h> 24 #include <iprt/dir.h> 25 #include <iprt/file.h> 26 #include <iprt/string.h> 27 #include <iprt/uuid.h> 28 #include <iprt/thread.h> 29 #include <iprt/process.h> 30 #include <iprt/env.h> 31 #include <iprt/cpputils.h> 32 33 #include <VBox/com/com.h> 34 #include <VBox/com/array.h> 35 36 #include <VBox/err.h> 37 #include <VBox/param.h> 38 #include <VBox/VBoxHDD-new.h> 39 #include <VBox/settings.h> 40 #include <VBox/version.h> 41 42 #include <package-generated.h> 43 44 #include <algorithm> 45 #include <set> 46 #include <memory> // for auto_ptr 47 48 #include <typeinfo> 49 23 50 #include "VirtualBoxImpl.h" 51 #include "VirtualBoxImplExtra.h" 24 52 25 53 #include "Global.h" … … 43 71 #endif 44 72 45 #include <stdio.h> 46 #include <stdlib.h> 47 48 #include <iprt/path.h> 49 #include <iprt/dir.h> 50 #include <iprt/file.h> 51 #include <iprt/string.h> 52 #include <iprt/uuid.h> 53 #include <iprt/thread.h> 54 #include <iprt/process.h> 55 #include <iprt/env.h> 56 #include <iprt/cpputils.h> 57 58 #include <VBox/err.h> 59 #include <VBox/param.h> 60 #include <VBox/VBoxHDD-new.h> 61 #include <VBox/version.h> 62 #include <package-generated.h> 63 64 #include <VBox/com/com.h> 65 #include <VBox/com/array.h> 66 67 #include <algorithm> 68 #include <set> 69 #include <memory> // for auto_ptr 70 71 #include <typeinfo> 73 // #include <stdio.h> 74 // #include <stdlib.h> 72 75 73 76 // defines -
trunk/src/VBox/Main/VirtualBoxImplExtra.cpp
r14904 r16557 24 24 */ 25 25 26 #include <VBox/settings.h> 27 26 28 #include "VirtualBoxImpl.h" 29 #include "VirtualBoxImplExtra.h" 27 30 28 31 #include "VirtualBoxXMLUtil.h" … … 69 72 */ 70 73 xml::Input * 71 VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)74 SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID) 72 75 { 73 76 if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0) … … 138 141 * freed by the caller using RTStrFree(). 139 142 */ 140 bool VirtualBox::SettingsTreeHelper::143 bool SettingsTreeHelper:: 141 144 needsConversion (const settings::Key &aRoot, char **aOldVersion) const 142 145 { … … 168 171 * returns @c true for this tree. 169 172 */ 170 const char *VirtualBox::SettingsTreeHelper::templateUri() const173 const char* SettingsTreeHelper::templateUri() const 171 174 { 172 175 return VBOX_XML_SETTINGS_CONVERTER; 173 176 } 174 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ 177 178 #if defined VBOX_MAIN_SETTINGS_ADDONS 179 180 // Settings API additions 181 //////////////////////////////////////////////////////////////////////////////// 182 183 namespace settings 184 { 185 186 template<> stdx::char_auto_ptr 187 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra) 188 { 189 stdx::char_auto_ptr result; 190 191 if (aValue.raw() == NULL) 192 throw ENoValue(); 193 194 /* The only way to cause RTUtf16ToUtf8Ex return a number of bytes needed 195 * w/o allocating the result buffer itself is to provide that both cch 196 * and *ppsz are not NULL. */ 197 char dummy [1]; 198 char *dummy2 = dummy; 199 size_t strLen = 1; 200 201 int vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, 202 &dummy2, strLen, &strLen); 203 if (RT_SUCCESS (vrc)) 204 { 205 /* the string only contains '\0' :) */ 206 result.reset (new char [1]); 207 result.get() [0] = '\0'; 208 return result; 209 } 210 211 if (vrc == VERR_BUFFER_OVERFLOW) 212 { 213 result.reset (new char [strLen + 1]); 214 char *buf = result.get(); 215 vrc = RTUtf16ToUtf8Ex (aValue.raw(), RTSTR_MAX, &buf, strLen + 1, NULL); 216 } 217 218 if (RT_FAILURE (vrc)) 219 throw xml::LogicError (RT_SRC_POS); 220 221 return result; 222 } 223 224 template<> com::Guid FromString <com::Guid> (const char *aValue) 225 { 226 if (aValue == NULL) 227 throw ENoValue(); 228 229 /* For settings, the format is always {XXX...XXX} */ 230 char buf [RTUUID_STR_LENGTH]; 231 if (aValue == NULL || *aValue != '{' || 232 strlen (aValue) != RTUUID_STR_LENGTH + 1 || 233 aValue [RTUUID_STR_LENGTH] != '}') 234 throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid", aValue)); 235 236 /* strip { and } */ 237 memcpy (buf, aValue + 1, RTUUID_STR_LENGTH - 1); 238 buf [RTUUID_STR_LENGTH - 1] = '\0'; 239 /* we don't use Guid (const char *) because we want to throw 240 * ENoConversion on format error */ 241 RTUUID uuid; 242 int vrc = RTUuidFromStr (&uuid, buf); 243 if (RT_FAILURE (vrc)) 244 throw ENoConversion(com::Utf8StrFmt("'%s' is not Guid (%Rrc)", aValue, vrc)); 245 246 return com::Guid (uuid); 247 } 248 249 template<> stdx::char_auto_ptr 250 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra) 251 { 252 /* For settings, the format is always {XXX...XXX} */ 253 stdx::char_auto_ptr result (new char [RTUUID_STR_LENGTH + 2]); 254 255 int vrc = RTUuidToStr (aValue.raw(), result.get() + 1, RTUUID_STR_LENGTH); 256 if (RT_FAILURE (vrc)) 257 throw xml::LogicError (RT_SRC_POS); 258 259 result.get() [0] = '{'; 260 result.get() [RTUUID_STR_LENGTH] = '}'; 261 result.get() [RTUUID_STR_LENGTH + 1] = '\0'; 262 263 return result; 264 } 265 266 #endif // VBOX_MAIN_SETTINGS_ADDONS 267 268 } /* namespace settings */ -
trunk/src/VBox/Main/include/ApplianceImpl.h
r16517 r16557 27 27 #include "VirtualBoxBase.h" 28 28 29 // #include <string> 29 namespace xml 30 { 31 class Node; 32 } 30 33 31 34 class VirtualBox; -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r14959 r16557 23 23 #define ____H_VIRTUALBOXBASEIMPL 24 24 25 #include "VBox/com/string.h"26 #include "VBox/com/Guid.h"27 #include "VBox/com/ptr.h"28 #include "VBox/com/ErrorInfo.h"29 30 #include "VBox/com/VirtualBox.h"31 32 #include <VBox/settings.h>33 34 #include "AutoLock.h"35 36 using namespace com;37 using namespace util;38 39 25 #include <iprt/cdefs.h> 40 26 #include <iprt/critsect.h> … … 43 29 #include <list> 44 30 #include <map> 31 32 #include "VBox/com/ErrorInfo.h" 33 34 #include "VBox/com/VirtualBox.h" 35 36 // avoid including VBox/settings.h and VBox/xml.h; 37 // only declare the classes 38 namespace settings 39 { 40 class XmlTreeBackend; 41 class TreeBackend; 42 class Key; 43 } 44 45 namespace xml 46 { 47 class File; 48 } 49 50 #include "AutoLock.h" 51 52 using namespace com; 53 using namespace util; 45 54 46 55 #if !defined (VBOX_WITH_XPCOM) … … 2825 2834 }; 2826 2835 2827 #if defined VBOX_MAIN_SETTINGS_ADDONS2828 2829 /**2830 * Settings API additions.2831 */2832 namespace settings2833 {2834 2835 /// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the2836 /// code below2837 2838 #if 02839 2840 /** Specialization of FromString for Bstr. */2841 template<> com::Bstr FromString <com::Bstr> (const char *aValue);2842 2843 #endif2844 2845 /** Specialization of ToString for Bstr. */2846 template<> stdx::char_auto_ptr2847 ToString <com::Bstr> (const com::Bstr &aValue, unsigned int aExtra);2848 2849 /** Specialization of FromString for Guid. */2850 template<> com::Guid FromString <com::Guid> (const char *aValue);2851 2852 /** Specialization of ToString for Guid. */2853 template<> stdx::char_auto_ptr2854 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);2855 2856 } /* namespace settings */2857 2858 #endif /* VBOX_MAIN_SETTINGS_ADDONS */2859 2860 2836 #endif // ____H_VIRTUALBOXBASEIMPL 2861 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r16191 r16557 40 40 #include "PerformanceImpl.h" 41 41 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 42 43 42 44 43 class Machine; … … 275 274 static HRESULT ensureFilePathExists (const char *aFileName); 276 275 277 class SettingsTreeHelper : public settings::XmlTreeBackend::InputResolver278 , public settings::XmlTreeBackend::AutoConverter279 {280 public:281 282 // InputResolver interface283 xml::Input *resolveEntity (const char *aURI, const char *aID);284 285 // AutoConverter interface286 bool needsConversion (const settings::Key &aRoot, char **aOldVersion) const;287 const char *templateUri() const;288 };289 290 276 static HRESULT loadSettingsTree (settings::XmlTreeBackend &aTree, 291 277 xml::File &aFile, -
trunk/src/VBox/Main/xml/Settings.cpp
r16538 r16557 1156 1156 } 1157 1157 1158 1158 1159 } /* namespace settings */ 1159 1160
Note:
See TracChangeset
for help on using the changeset viewer.

