Changeset 16325 in vbox for trunk/src/VBox
- Timestamp:
- Jan 28, 2009 6:24:17 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 42160
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r16309 r16325 44 44 struct DiskImage 45 45 { 46 string strDiskId;// value from DiskSection/Disk/@diskId46 Utf8Str strDiskId; // value from DiskSection/Disk/@diskId 47 47 int64_t iCapacity; // value from DiskSection/Disk/@capacity; 48 48 // (maximum size for dynamic images, I guess; we always translate this to bytes) … … 50 50 // (actual used size of disk, always in bytes; can be an estimate of used disk 51 51 // space, but cannot be larger than iCapacity) 52 string strFormat;// value from DiskSection/Disk/@format52 Utf8Str strFormat; // value from DiskSection/Disk/@format 53 53 // typically http://www.vmware.com/specifications/vmdk.html#sparse 54 54 55 55 // fields from /References/File; the spec says the file reference from disk can be empty, 56 56 // so in that case, strFilename will be empty, then a new disk should be created 57 string strHref;// value from /References/File/@href (filename); if empty, then the remaining fields are ignored57 Utf8Str strHref; // value from /References/File/@href (filename); if empty, then the remaining fields are ignored 58 58 int64_t iSize; // value from /References/File/@size (optional according to spec; then we set -1 here) 59 59 int64_t iChunkSize; // value from /References/File/@chunkSize (optional, unsupported) 60 string strCompression;// value from /References/File/@compression (optional, can be "gzip" according to spec)60 Utf8Str strCompression; // value from /References/File/@compression (optional, can be "gzip" according to spec) 61 61 }; 62 62 63 63 struct Network 64 64 { 65 string strNetworkName;// value from NetworkSection/Network/@name65 Utf8Str strNetworkName; // value from NetworkSection/Network/@name 66 66 // unfortunately the OVF spec is unspecific about how networks should be specified further 67 67 }; … … 69 69 struct VirtualHardwareItem 70 70 { 71 stringstrDescription;72 stringstrCaption;73 stringstrElementName;71 Utf8Str strDescription; 72 Utf8Str strCaption; 73 Utf8Str strElementName; 74 74 75 75 uint32_t ulInstanceID; … … 77 77 78 78 OVFResourceType_T resourceType; 79 stringstrOtherResourceType;80 stringstrResourceSubType;81 82 string strHostResource;// "Abstractly specifies how a device shall connect to a resource on the deployment platform.79 Utf8Str strOtherResourceType; 80 Utf8Str strResourceSubType; 81 82 Utf8Str strHostResource; // "Abstractly specifies how a device shall connect to a resource on the deployment platform. 83 83 // Not all devices need a backing." Used with disk items, for which this references a virtual 84 84 // disk from the Disks section. 85 85 bool fAutomaticAllocation; 86 86 bool fAutomaticDeallocation; 87 string strConnection;// "All Ethernet adapters that specify the same abstract network connection name within an OVF87 Utf8Str strConnection; // "All Ethernet adapters that specify the same abstract network connection name within an OVF 88 88 // package shall be deployed on the same network. The abstract network connection name shall be 89 89 // listed in the NetworkSection at the outermost envelope level." 90 string strAddress;// "Device-specific. For an Ethernet adapter, this specifies the MAC address."91 string strAddressOnParent;// "For a device, this specifies its location on the controller."92 string strAllocationUnits;// "Specifies the units of allocation used. For example, “byte * 2^20”."90 Utf8Str strAddress; // "Device-specific. For an Ethernet adapter, this specifies the MAC address." 91 Utf8Str strAddressOnParent; // "For a device, this specifies its location on the controller." 92 Utf8Str strAllocationUnits; // "Specifies the units of allocation used. For example, “byte * 2^20”." 93 93 uint64_t ullVirtualQuantity; // "Specifies the quantity of resources presented. For example, “256”." 94 94 uint64_t ullReservation; // "Specifies the minimum quantity of resources guaranteed to be available." … … 96 96 uint64_t ullWeight; // "Specifies a relative priority for this allocation in relation to other allocations." 97 97 98 stringstrConsumerVisibility;99 stringstrMappingBehavior;100 stringstrPoolID;98 Utf8Str strConsumerVisibility; 99 Utf8Str strMappingBehavior; 100 Utf8Str strPoolID; 101 101 uint32_t ulBusNumber; // seen with IDE controllers, but not listed in OVF spec 102 102 … … 108 108 }; 109 109 110 typedef map< string, DiskImage> DiskImagesMap;111 typedef map< string, Network> NetworksMap;110 typedef map<Utf8Str, DiskImage> DiskImagesMap; 111 typedef map<Utf8Str, Network> NetworksMap; 112 112 113 113 struct VirtualSystem; … … 134 134 uint32_t idController; // instance ID (Item/InstanceId); this gets referenced from HardDisk 135 135 ControllerSystemType controllerSystem; // one of IDE, SATA, SCSI 136 stringstrControllerType; // controllertype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE)137 stringstrAddress; // for IDE136 Utf8Str strControllerType; // controllertype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE) 137 Utf8Str strAddress; // for IDE 138 138 uint32_t ulBusNumber; // for IDE 139 139 … … 151 151 uint32_t idController; // SCSI (or IDE) controller this disk is connected to; 152 152 // points into VirtualSystem.mapControllers 153 stringstrDiskId; // if the hard disk has an ovf:/disk/<id> reference,153 Utf8Str strDiskId; // if the hard disk has an ovf:/disk/<id> reference, 154 154 // this receives the <id> component; points to one of the 155 155 // references in Appliance::Data.mapDisks 156 156 }; 157 157 158 typedef map< string, VirtualDisk> VirtualDisksMap;158 typedef map<Utf8Str, VirtualDisk> VirtualDisksMap; 159 159 160 160 struct VirtualSystem 161 161 { 162 stringstrName; // copy of VirtualSystem/@id162 Utf8Str strName; // copy of VirtualSystem/@id 163 163 164 164 CIMOSType_T cimos; 165 stringstrVirtualSystemType; // generic hardware description; OVF says this can be something like "vmx-4" or "xen";165 Utf8Str strVirtualSystemType; // generic hardware description; OVF says this can be something like "vmx-4" or "xen"; 166 166 // VMware Workstation 6.5 is "vmx-07" 167 167 … … 171 171 uint16_t cCPUs; // no. of CPUs, copied from llHardwareItems; default = 1 172 172 173 list< string>llNetworkNames;173 list<Utf8Str> llNetworkNames; 174 174 // list of strings referring to network names 175 175 // (one for each VirtualSystem/Item[@ResourceType=10]/Connection element) … … 186 186 bool fHasUsbController; // true if there's a USB controller item in mapHardwareItems 187 187 188 stringstrSoundCardType; // if not empty, then the system wants a soundcard; this then specifies the hardware;188 Utf8Str strSoundCardType; // if not empty, then the system wants a soundcard; this then specifies the hardware; 189 189 // VMware Workstation 6.5 uses "ensoniq1371" for example 190 190 191 stringstrLicenceInfo; // license info if any; receives contents of VirtualSystem/EulaSection/Info192 stringstrLicenceText; // license info if any; receives contents of VirtualSystem/EulaSection/License191 Utf8Str strLicenceInfo; // license info if any; receives contents of VirtualSystem/EulaSection/Info 192 Utf8Str strLicenceText; // license info if any; receives contents of VirtualSystem/EulaSection/License 193 193 194 194 VirtualSystem() … … 201 201 //////////////////////////////////////////////////////////////////////////////// 202 202 203 template <class T> inline std::string toString(const T& val) 204 { 203 template <class T> 204 inline 205 com::Utf8Str toString(const T& val) 206 { 207 // @todo optimize 205 208 std::ostringstream ss; 206 209 ss << val; 207 return ss.str();210 return Utf8Str(ss.str().c_str()); 208 211 } 209 212 … … 357 360 d.iPopulatedSize = -1; 358 361 359 stringstrFileRef;362 Utf8Str strFileRef; 360 363 if (pelmDisk->getAttributeValue("fileRef", strFileRef)) // optional 361 364 { … … 1005 1008 ComAssertComRCThrowRC(rc); 1006 1009 1007 stringosTypeVBox = SchemaDefs_OSTypeId_Other;1010 Utf8Str osTypeVBox = SchemaDefs_OSTypeId_Other; 1008 1011 /* Guest OS type */ 1009 1012 switch (vs.cimos) … … 1194 1197 /* If the there isn't any name specified create a default one out of 1195 1198 * the OS type */ 1196 stringnameVBox = vs.strName;1199 Utf8Str nameVBox = vs.strName; 1197 1200 if (nameVBox == "") 1198 1201 nameVBox = osTypeVBox; … … 1202 1205 /* Now that we know the base system get our internal defaults based on that. */ 1203 1206 ComPtr<IGuestOSType> osType; 1204 rc = mVirtualBox->GetGuestOSType(Bstr( Utf8Str(osTypeVBox.c_str())), osType.asOutParam());1207 rc = mVirtualBox->GetGuestOSType(Bstr(osTypeVBox), osType.asOutParam()); 1205 1208 ComAssertComRCThrowRC(rc); 1206 1209 … … 1262 1265 // @todo: figure out the SCSI types 1263 1266 # ifdef VBOX_WITH_LSILOGIC 1264 stringhdcController = "LsiLogic";1267 Utf8Str hdcController = "LsiLogic"; 1265 1268 # elif VBOX_WITH_BUSLOGIC 1266 stringhdcController = "BusLogic";1269 Utf8Str hdcController = "BusLogic"; 1267 1270 # else /* !VBOX_WITH_BUSLOGIC */ 1268 stringhdcController;1271 Utf8Str hdcController; 1269 1272 # endif 1270 1273 # ifdef VBOX_WITH_LSILOGIC … … 1320 1323 { 1321 1324 /* Construct the path */ 1322 string path = Utf8StrFmt("%ls%c%s", defaultHardDiskLocation, RTPATH_DELIMITER, di.strHref.c_str()).raw();1325 Utf8Str path = Utf8StrFmt("%ls%c%s", defaultHardDiskLocation, RTPATH_DELIMITER, di.strHref.c_str()); 1323 1326 /* Make the path unique to the VBox installation */ 1324 1327 searchUniqueDiskImageFilePath(path); … … 1336 1339 rc = osType->COMGETTER(AdapterType)(&nwAdapterVBox); 1337 1340 ComAssertComRCThrowRC(rc); 1338 list< string>::const_iterator nwIt;1341 list<Utf8Str>::const_iterator nwIt; 1339 1342 /* Iterate through all abstract networks. We support 8 network 1340 1343 * adapters at the maximum. (@todo: warn if it are more!) */ … … 1344 1347 ++nwIt, ++a) 1345 1348 { 1346 // stringnwController = *nwIt; // @todo: not used yet1349 // Utf8Str nwController = *nwIt; // @todo: not used yet 1347 1350 vsd->addEntry(VirtualSystemDescriptionType_NetworkAdapter, "", "", toString<ULONG>(nwAdapterVBox)); 1348 1351 } … … 1377 1380 std::list<VirtualSystemDescriptionEntry*> vsdeOS = vsd->findByType(VirtualSystemDescriptionType_OS); 1378 1381 Assert(vsdeOS.size() == 1); 1379 stringosTypeVBox = vsdeOS.front()->strFinalValue;1382 const Utf8Str &osTypeVBox = vsdeOS.front()->strFinalValue; 1380 1383 1381 1384 /* Now that we know the base system get our internal defaults based on that. */ 1382 1385 ComPtr<IGuestOSType> osType; 1383 rc = mVirtualBox->GetGuestOSType(Bstr( Utf8Str(osTypeVBox.c_str())), osType.asOutParam());1386 rc = mVirtualBox->GetGuestOSType(Bstr(osTypeVBox), osType.asOutParam()); 1384 1387 ComAssertComRCThrowRC(rc); 1385 1388 … … 1388 1391 std::list<VirtualSystemDescriptionEntry*> vsdeName = vsd->findByType(VirtualSystemDescriptionType_Name); 1389 1392 Assert(vsdeName.size() == 1); 1390 stringnameVBox = vsdeName.front()->strFinalValue;1393 const Utf8Str &nameVBox = vsdeName.front()->strFinalValue; 1391 1394 ComPtr<IMachine> newMachine; 1392 1395 rc = mVirtualBox->CreateMachine(Bstr(nameVBox.c_str()), Bstr(osTypeVBox.c_str()), … … 1403 1406 std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsd->findByType(VirtualSystemDescriptionType_Memory); 1404 1407 Assert(vsdeRAM.size() == 1); 1405 stringmemoryVBox = vsdeRAM.front()->strFinalValue;1408 const Utf8Str &memoryVBox = vsdeRAM.front()->strFinalValue; 1406 1409 uint64_t tt = RTStrToUInt64(memoryVBox.c_str()) / _1M; 1407 1410 … … 1440 1443 ++nwIt, ++a) 1441 1444 { 1442 stringnwTypeVBox = (*nwIt)->strFinalValue;1445 const Utf8Str &nwTypeVBox = (*nwIt)->strFinalValue; 1443 1446 uint32_t tt1 = RTStrToUInt32(nwTypeVBox.c_str()); 1444 1447 ComPtr<INetworkAdapter> nwVBox; … … 1474 1477 if (vsdeHDCSATA.size() > 0) 1475 1478 { 1476 stringhdcVBox = vsdeHDCIDE.front()->strFinalValue;1477 if ( !RTStrCmp(hdcVBox.c_str(), "AHCI"))1479 const Utf8Str &hdcVBox = vsdeHDCIDE.front()->strFinalValue; 1480 if (hdcVBox == "AHCI") 1478 1481 { 1479 1482 /* For now we have just to enable the AHCI controller. */ … … 1541 1544 // continue; 1542 1545 } 1543 const string&strRef = (*hdIt)->strRef;1546 const Utf8Str &strRef = (*hdIt)->strRef; 1544 1547 /* Get the associated disk image */ 1545 1548 if (m->mapDisks.find(strRef) == m->mapDisks.end()) … … 1547 1550 /* @todo: error: entry doesn't exists */ 1548 1551 } 1549 DiskImage di = m->mapDisks 1552 DiskImage di = m->mapDisks[strRef]; 1550 1553 /* Construct the source file path */ 1551 1554 char *srcFilePath; … … 1615 1618 } 1616 1619 1617 HRESULT Appliance::searchUniqueVMName( std::string& aName) const1620 HRESULT Appliance::searchUniqueVMName(Utf8Str& aName) const 1618 1621 { 1619 1622 IMachine *machine = NULL; … … 1633 1636 } 1634 1637 1635 HRESULT Appliance::searchUniqueDiskImageFilePath( std::string& aName) const1638 HRESULT Appliance::searchUniqueDiskImageFilePath(Utf8Str& aName) const 1636 1639 { 1637 1640 IHardDisk2 *harddisk = NULL; … … 1721 1724 ++it, ++i) 1722 1725 { 1723 VirtualSystemDescriptionEntryvsde = (*it);1726 const VirtualSystemDescriptionEntry &vsde = (*it); 1724 1727 /* Types */ 1725 1728 sfaTypes [i] = vsde.type; 1726 1729 /* Original value */ 1727 Bstr bstr = Utf8Str(vsde.strOriginalValue.c_str());1728 bstr.cloneTo(&sfaOrigValues 1730 Bstr bstr = vsde.strOriginalValue; 1731 bstr.cloneTo(&sfaOrigValues[i]); 1729 1732 /* Auto value */ 1730 bstr = Utf8Str(vsde.strAutoValue.c_str());1731 bstr.cloneTo(&sfaAutoValues 1733 bstr = vsde.strAutoValue; 1734 bstr.cloneTo(&sfaAutoValues[i]); 1732 1735 /* Configuration */ 1733 bstr = Utf8Str(vsde.strConfiguration.c_str());1734 bstr.cloneTo(&sfaConfigurations 1736 bstr = vsde.strConfiguration; 1737 bstr.cloneTo(&sfaConfigurations[i]); 1735 1738 } 1736 1739 … … 1763 1766 { 1764 1767 VirtualSystemDescriptionEntry vsde = (*it); 1765 vsde.strFinalValue = Utf8Str(values[i]).raw();1768 vsde.strFinalValue = values[i]; 1766 1769 } 1767 1770 … … 1770 1773 1771 1774 void VirtualSystemDescription::addEntry(VirtualSystemDescriptionType_T aType, 1772 const std::string&aRef,1773 const std::string&aOrigValue,1774 const std::string&aAutoValue,1775 const std::string&aConfig /* = "" */)1775 const Utf8Str &aRef, 1776 const Utf8Str &aOrigValue, 1777 const Utf8Str &aAutoValue, 1778 const Utf8Str &aConfig /* = "" */) 1776 1779 { 1777 1780 VirtualSystemDescriptionEntry vsde; -
trunk/src/VBox/Main/include/ApplianceImpl.h
r16309 r16325 27 27 #include "VirtualBoxBase.h" 28 28 29 #include <string>29 // #include <string> 30 30 31 31 class VirtualBox; … … 90 90 HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::Node *pContentElem); 91 91 92 HRESULT searchUniqueVMName (std::string& aName) const;93 HRESULT searchUniqueDiskImageFilePath( std::string& aName) const;92 HRESULT searchUniqueVMName(Utf8Str& aName) const; 93 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const; 94 94 }; 95 95 … … 97 97 { 98 98 VirtualSystemDescriptionType_T type; /* Of which type is this value */ 99 std::stringstrRef; /* Reference value to the internal implementation */100 std::stringstrOriginalValue; /* The original OVF value */101 std::stringstrAutoValue; /* The value which VBox suggest */102 std::stringstrFinalValue; /* The value the user select */103 std::stringstrConfiguration; /* Additional configuration data for this type */99 Utf8Str strRef; /* Reference value to the internal implementation */ 100 Utf8Str strOriginalValue; /* The original OVF value */ 101 Utf8Str strAutoValue; /* The value which VBox suggest */ 102 Utf8Str strFinalValue; /* The value the user select */ 103 Utf8Str strConfiguration; /* Additional configuration data for this type */ 104 104 }; 105 105 … … 151 151 private: 152 152 void addEntry(VirtualSystemDescriptionType_T aType, 153 const std::string&aRef,154 const std::string&aOrigValue,155 const std::string&aAutoValue,156 const std::string&aConfig = "");153 const Utf8Str &aRef, 154 const Utf8Str &aOrigValue, 155 const Utf8Str &aAutoValue, 156 const Utf8Str &aConfig = ""); 157 157 158 158 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType); -
trunk/src/VBox/Main/xml/xml.cpp
r16188 r16325 21 21 #include "Logging.h" 22 22 23 #include <boost/shared_ptr.hpp> 24 23 25 #include <iprt/err.h> 24 26 #include <iprt/file.h> … … 35 37 #include <libxml/xmlschemas.h> 36 38 37 #include <string>38 39 #include <list> 39 40 #include <map> 40 41 #include "boost/shared_ptr.hpp"42 41 43 42 #include "VBox/xml.h" … … 685 684 * @return TRUE if attribute was found and str was thus updated. 686 685 */ 687 bool Node::getAttributeValue(const char *pcszMatch, std::string&str) const686 bool Node::getAttributeValue(const char *pcszMatch, com::Utf8Str &str) const 688 687 { 689 688 const Node* pAttr; … … 709 708 bool Node::getAttributeValue(const char *pcszMatch, int64_t &i) const 710 709 { 711 std::stringstr;710 com::Utf8Str str; 712 711 if ( (getAttributeValue(pcszMatch, str)) 713 712 && (VINF_SUCCESS == RTStrToInt64Ex(str.c_str(), NULL, 10, &i)) … … 730 729 bool Node::getAttributeValue(const char *pcszMatch, uint64_t &i) const 731 730 { 732 std::stringstr;731 com::Utf8Str str; 733 732 if ( (getAttributeValue(pcszMatch, str)) 734 733 && (VINF_SUCCESS == RTStrToUInt64Ex(str.c_str(), NULL, 10, &i)) … … 907 906 { 908 907 xmlParserCtxtPtr ctxt; 909 std::stringstrXmlFilename;908 com::Utf8Str strXmlFilename; 910 909 911 910 Data() … … 935 934 { 936 935 File file; 937 std::stringerror;936 com::Utf8Str error; 938 937 939 938 ReadContext(const char *pcszFilename)
Note:
See TracChangeset
for help on using the changeset viewer.