Changeset 16558 in vbox
- Timestamp:
- Feb 6, 2009 4:41:43 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42504
- Location:
- trunk
- Files:
-
- 1 deleted
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/settings.h
r16557 r16558 44 44 45 45 #include <iprt/time.h> 46 47 #include <VBox/com/Guid.h>48 46 49 47 #include <VBox/xml.h> … … 441 439 */ 442 440 DECLEXPORT (stdx::char_auto_ptr) ToString (const void *aData, size_t aLen); 443 444 #if defined VBOX_MAIN_SETTINGS_ADDONS445 446 /// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the447 /// code below448 449 #if 0450 451 /** Specialization of FromString for Bstr. */452 template<> com::Bstr FromString <com::Bstr> (const char *aValue);453 454 #endif455 456 /** Specialization of ToString for Bstr. */457 template<> stdx::char_auto_ptr458 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_ptr465 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra);466 467 #endif // VBOX_MAIN_SETTINGS_ADDONS468 441 469 442 // the rest -
trunk/src/VBox/Main/AudioAdapterImpl.cpp
r16557 r16558 25 25 26 26 #include <iprt/cpputils.h> 27 28 #include <VBox/settings.h>29 27 30 28 // constructor / destructor -
trunk/src/VBox/Main/BIOSSettingsImpl.cpp
r16557 r16558 24 24 #include "Logging.h" 25 25 #include "GuestOSTypeImpl.h" 26 27 26 #include <iprt/cpputils.h> 28 #include <VBox/settings.h>29 27 30 28 // constructor / destructor -
trunk/src/VBox/Main/DVDDriveImpl.cpp
r16557 r16558 35 35 #include <iprt/string.h> 36 36 #include <iprt/cpputils.h> 37 38 #include <VBox/settings.h>39 37 40 38 // constructor / destructor -
trunk/src/VBox/Main/FloppyDriveImpl.cpp
r16557 r16558 35 35 #include <iprt/string.h> 36 36 #include <iprt/cpputils.h> 37 38 #include <VBox/settings.h>39 37 40 38 // constructor / destructor -
trunk/src/VBox/Main/HardDisk2Impl.cpp
r16557 r16558 33 33 34 34 #include <VBox/err.h> 35 #include <VBox/settings.h>36 35 37 36 #include <iprt/param.h> -
trunk/src/VBox/Main/HostImpl.cpp
r16557 r16558 102 102 103 103 104 #include <VBox/usb.h> 105 #include <VBox/x86.h> 106 #include <VBox/err.h> 104 107 #include <iprt/asm.h> 105 108 #include <iprt/string.h> … … 116 119 #include "netif.h" 117 120 #endif 118 119 #include <VBox/usb.h>120 #include <VBox/x86.h>121 #include <VBox/err.h>122 #include <VBox/settings.h>123 121 124 122 #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) -
trunk/src/VBox/Main/MachineImpl.cpp
r16557 r16558 27 27 #ifndef __STDC_CONSTANT_MACROS 28 28 # define __STDC_CONSTANT_MACROS 29 #endif 30 31 #if defined(RT_OS_WINDOWS) 32 #elif defined(RT_OS_LINUX) 29 33 #endif 30 34 … … 73 77 #include <VBox/err.h> 74 78 #include <VBox/param.h> 75 #include <VBox/settings.h>76 77 79 #ifdef VBOX_WITH_GUEST_PROPS 78 80 # include <VBox/HostServices/GuestPropertySvc.h> -
trunk/src/VBox/Main/MediumImpl.cpp
r16557 r16558 30 30 #include <VBox/com/array.h> 31 31 32 #include <VBox/err.h>33 #include <VBox/settings.h>34 35 32 #include <iprt/param.h> 36 33 #include <iprt/path.h> 37 34 #include <iprt/file.h> 35 36 #include <VBox/err.h> 38 37 39 38 //////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r16557 r16558 29 29 30 30 #include <VBox/err.h> 31 #include <VBox/settings.h>32 31 33 32 // constructor / destructor -
trunk/src/VBox/Main/ParallelPortImpl.cpp
r16557 r16558 27 27 #include <iprt/string.h> 28 28 #include <iprt/cpputils.h> 29 30 #include <VBox/settings.h>31 29 32 30 // constructor / destructor -
trunk/src/VBox/Main/PerformanceImpl.cpp
r16557 r16558 22 22 */ 23 23 24 #if defined(RT_OS_WINDOWS) 25 #elif defined(RT_OS_LINUX) 26 #endif 27 24 28 #include "PerformanceImpl.h" 25 29 26 30 #include "Logging.h" 27 31 32 #include <VBox/err.h> 28 33 #include <iprt/process.h> 29 30 #include <VBox/err.h>31 #include <VBox/settings.h>32 34 33 35 #include <vector> -
trunk/src/VBox/Main/SATAControllerImpl.cpp
r16557 r16558 22 22 */ 23 23 24 25 24 26 #include "SATAControllerImpl.h" 25 27 #include "MachineImpl.h" … … 29 31 #include <iprt/string.h> 30 32 #include <iprt/cpputils.h> 31 32 33 #include <VBox/err.h> 33 #include <VBox/settings.h>34 34 35 35 #include <algorithm> -
trunk/src/VBox/Main/SerialPortImpl.cpp
r16557 r16558 27 27 #include <iprt/string.h> 28 28 #include <iprt/cpputils.h> 29 30 #include <VBox/settings.h>31 29 32 30 // constructor / destructor -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r16557 r16558 32 32 #include <iprt/path.h> 33 33 #include <iprt/dir.h> 34 34 #include <VBox/param.h> 35 35 #include <VBox/err.h> 36 #include <VBox/param.h>37 #include <VBox/settings.h>38 36 39 37 // defines -
trunk/src/VBox/Main/USBControllerImpl.cpp
r16557 r16558 33 33 #include "Logging.h" 34 34 35 35 36 #include <iprt/string.h> 36 37 #include <iprt/cpputils.h> 37 38 38 #include <VBox/err.h> 39 #include <VBox/settings.h>40 39 41 40 #include <algorithm> -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r16557 r16558 1214 1214 } 1215 1215 1216 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: */ -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r16557 r16558 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_ptr47 48 #include <typeinfo>49 50 23 #include "VirtualBoxImpl.h" 51 #include "VirtualBoxImplExtra.h"52 24 53 25 #include "Global.h" … … 71 43 #endif 72 44 73 // #include <stdio.h> 74 // #include <stdlib.h> 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> 75 72 76 73 // defines -
trunk/src/VBox/Main/VirtualBoxImplExtra.cpp
r16557 r16558 24 24 */ 25 25 26 #include <VBox/settings.h>27 28 26 #include "VirtualBoxImpl.h" 29 #include "VirtualBoxImplExtra.h"30 27 31 28 #include "VirtualBoxXMLUtil.h" … … 72 69 */ 73 70 xml::Input * 74 SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID)71 VirtualBox::SettingsTreeHelper::resolveEntity (const char *aURI, const char *aID) 75 72 { 76 73 if (strcmp (aURI, VBOX_XML_SCHEMA_COMMON) == 0) … … 141 138 * freed by the caller using RTStrFree(). 142 139 */ 143 bool SettingsTreeHelper::140 bool VirtualBox::SettingsTreeHelper:: 144 141 needsConversion (const settings::Key &aRoot, char **aOldVersion) const 145 142 { … … 171 168 * returns @c true for this tree. 172 169 */ 173 const char *SettingsTreeHelper::templateUri() const170 const char *VirtualBox::SettingsTreeHelper::templateUri() const 174 171 { 175 172 return VBOX_XML_SETTINGS_CONVERTER; 176 173 } 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 */ 174 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/include/ApplianceImpl.h
r16557 r16558 27 27 #include "VirtualBoxBase.h" 28 28 29 namespace xml 30 { 31 class Node; 32 } 29 // #include <string> 33 30 34 31 class VirtualBox; -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r16557 r16558 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 25 39 #include <iprt/cdefs.h> 26 40 #include <iprt/critsect.h> … … 29 43 #include <list> 30 44 #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 classes38 namespace settings39 {40 class XmlTreeBackend;41 class TreeBackend;42 class Key;43 }44 45 namespace xml46 {47 class File;48 }49 50 #include "AutoLock.h"51 52 using namespace com;53 using namespace util;54 45 55 46 #if !defined (VBOX_WITH_XPCOM) … … 2834 2825 }; 2835 2826 2827 #if defined VBOX_MAIN_SETTINGS_ADDONS 2828 2829 /** 2830 * Settings API additions. 2831 */ 2832 namespace settings 2833 { 2834 2835 /// @todo once string data in Bstr and Utf8Str is auto_ref_ptr, enable the 2836 /// code below 2837 2838 #if 0 2839 2840 /** Specialization of FromString for Bstr. */ 2841 template<> com::Bstr FromString <com::Bstr> (const char *aValue); 2842 2843 #endif 2844 2845 /** Specialization of ToString for Bstr. */ 2846 template<> stdx::char_auto_ptr 2847 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_ptr 2854 ToString <com::Guid> (const com::Guid &aValue, unsigned int aExtra); 2855 2856 } /* namespace settings */ 2857 2858 #endif /* VBOX_MAIN_SETTINGS_ADDONS */ 2859 2836 2860 #endif // ____H_VIRTUALBOXBASEIMPL 2861 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r16557 r16558 40 40 #include "PerformanceImpl.h" 41 41 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 42 42 43 43 44 class Machine; … … 274 275 static HRESULT ensureFilePathExists (const char *aFileName); 275 276 277 class SettingsTreeHelper : public settings::XmlTreeBackend::InputResolver 278 , public settings::XmlTreeBackend::AutoConverter 279 { 280 public: 281 282 // InputResolver interface 283 xml::Input *resolveEntity (const char *aURI, const char *aID); 284 285 // AutoConverter interface 286 bool needsConversion (const settings::Key &aRoot, char **aOldVersion) const; 287 const char *templateUri() const; 288 }; 289 276 290 static HRESULT loadSettingsTree (settings::XmlTreeBackend &aTree, 277 291 xml::File &aFile, -
trunk/src/VBox/Main/xml/Settings.cpp
r16557 r16558 1156 1156 } 1157 1157 1158 1159 1158 } /* namespace settings */ 1160 1159
Note:
See TracChangeset
for help on using the changeset viewer.