VirtualBox

Changeset 16325 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 28, 2009 6:24:17 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
42160
Message:

OVF: make com::xml and IAppliance use Utf8Str instead of std::string

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r16309 r16325  
    4444struct DiskImage
    4545{
    46     string strDiskId;               // value from DiskSection/Disk/@diskId
     46    Utf8Str strDiskId;              // value from DiskSection/Disk/@diskId
    4747    int64_t iCapacity;              // value from DiskSection/Disk/@capacity;
    4848                                    // (maximum size for dynamic images, I guess; we always translate this to bytes)
     
    5050                                    // (actual used size of disk, always in bytes; can be an estimate of used disk
    5151                                    // space, but cannot be larger than iCapacity)
    52     string strFormat;               // value from DiskSection/Disk/@format
     52    Utf8Str strFormat;              // value from DiskSection/Disk/@format
    5353                // typically http://www.vmware.com/specifications/vmdk.html#sparse
    5454
    5555    // fields from /References/File; the spec says the file reference from disk can be empty,
    5656    // 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 ignored
     57    Utf8Str strHref;                // value from /References/File/@href (filename); if empty, then the remaining fields are ignored
    5858    int64_t iSize;                  // value from /References/File/@size (optional according to spec; then we set -1 here)
    5959    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)
    6161};
    6262
    6363struct Network
    6464{
    65     string strNetworkName;          // value from NetworkSection/Network/@name
     65    Utf8Str strNetworkName;         // value from NetworkSection/Network/@name
    6666            // unfortunately the OVF spec is unspecific about how networks should be specified further
    6767};
     
    6969struct VirtualHardwareItem
    7070{
    71     string strDescription;
    72     string strCaption;
    73     string strElementName;
     71    Utf8Str strDescription;
     72    Utf8Str strCaption;
     73    Utf8Str strElementName;
    7474
    7575    uint32_t ulInstanceID;
     
    7777
    7878    OVFResourceType_T resourceType;
    79     string strOtherResourceType;
    80     string strResourceSubType;
    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.
    8383                                        // Not all devices need a backing." Used with disk items, for which this references a virtual
    8484                                        // disk from the Disks section.
    8585    bool fAutomaticAllocation;
    8686    bool fAutomaticDeallocation;
    87     string strConnection;               // "All Ethernet adapters that specify the same abstract network connection name within an OVF
     87    Utf8Str strConnection;              // "All Ethernet adapters that specify the same abstract network connection name within an OVF
    8888                                        // package shall be deployed on the same network. The abstract network connection name shall be
    8989                                        // 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”."
    9393    uint64_t ullVirtualQuantity;        // "Specifies the quantity of resources presented. For example, “256”."
    9494    uint64_t ullReservation;            // "Specifies the minimum quantity of resources guaranteed to be available."
     
    9696    uint64_t ullWeight;                 // "Specifies a relative priority for this allocation in relation to other allocations."
    9797
    98     string strConsumerVisibility;
    99     string strMappingBehavior;
    100     string strPoolID;
     98    Utf8Str strConsumerVisibility;
     99    Utf8Str strMappingBehavior;
     100    Utf8Str strPoolID;
    101101    uint32_t ulBusNumber;               // seen with IDE controllers, but not listed in OVF spec
    102102
     
    108108};
    109109
    110 typedef map<string, DiskImage> DiskImagesMap;
    111 typedef map<string, Network> NetworksMap;
     110typedef map<Utf8Str, DiskImage> DiskImagesMap;
     111typedef map<Utf8Str, Network> NetworksMap;
    112112
    113113struct VirtualSystem;
     
    134134    uint32_t             idController;           // instance ID (Item/InstanceId); this gets referenced from HardDisk
    135135    ControllerSystemType controllerSystem;       // one of IDE, SATA, SCSI
    136     string               strControllerType;      // controllertype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE)
    137     string               strAddress;             // for IDE
     136    Utf8Str              strControllerType;      // controllertype (Item/ResourceSubType); e.g. "LsiLogic"; can be empty (esp. for IDE)
     137    Utf8Str              strAddress;             // for IDE
    138138    uint32_t             ulBusNumber;            // for IDE
    139139
     
    151151    uint32_t            idController;           // SCSI (or IDE) controller this disk is connected to;
    152152                                                // points into VirtualSystem.mapControllers
    153     string              strDiskId;              // if the hard disk has an ovf:/disk/<id> reference,
     153    Utf8Str             strDiskId;              // if the hard disk has an ovf:/disk/<id> reference,
    154154                                                // this receives the <id> component; points to one of the
    155155                                                // references in Appliance::Data.mapDisks
    156156};
    157157
    158 typedef map<string, VirtualDisk> VirtualDisksMap;
     158typedef map<Utf8Str, VirtualDisk> VirtualDisksMap;
    159159
    160160struct VirtualSystem
    161161{
    162     string              strName;                // copy of VirtualSystem/@id
     162    Utf8Str             strName;                // copy of VirtualSystem/@id
    163163
    164164    CIMOSType_T         cimos;
    165     string              strVirtualSystemType;   // 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";
    166166                                                // VMware Workstation 6.5 is "vmx-07"
    167167
     
    171171    uint16_t            cCPUs;                  // no. of CPUs, copied from llHardwareItems; default = 1
    172172
    173     list<string>        llNetworkNames;
     173    list<Utf8Str>       llNetworkNames;
    174174            // list of strings referring to network names
    175175            // (one for each VirtualSystem/Item[@ResourceType=10]/Connection element)
     
    186186    bool                fHasUsbController;      // true if there's a USB controller item in mapHardwareItems
    187187
    188     string              strSoundCardType;       // 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;
    189189                                                // VMware Workstation 6.5 uses "ensoniq1371" for example
    190190
    191     string              strLicenceInfo;         // license info if any; receives contents of VirtualSystem/EulaSection/Info
    192     string              strLicenceText;         // license info if any; receives contents of VirtualSystem/EulaSection/License
     191    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
    193193
    194194    VirtualSystem()
     
    201201////////////////////////////////////////////////////////////////////////////////
    202202
    203 template <class T> inline std::string toString(const T& val)
    204 {
     203template <class T>
     204inline
     205com::Utf8Str toString(const T& val)
     206{
     207    // @todo optimize
    205208    std::ostringstream ss;
    206209    ss << val;
    207     return ss.str();
     210    return Utf8Str(ss.str().c_str());
    208211}
    209212
     
    357360                d.iPopulatedSize = -1;
    358361
    359             string strFileRef;
     362            Utf8Str strFileRef;
    360363            if (pelmDisk->getAttributeValue("fileRef", strFileRef)) // optional
    361364            {
     
    10051008        ComAssertComRCThrowRC(rc);
    10061009
    1007         string osTypeVBox = SchemaDefs_OSTypeId_Other;
     1010        Utf8Str osTypeVBox = SchemaDefs_OSTypeId_Other;
    10081011        /* Guest OS type */
    10091012        switch (vs.cimos)
     
    11941197        /* If the there isn't any name specified create a default one out of
    11951198         * the OS type */
    1196         string nameVBox = vs.strName;
     1199        Utf8Str nameVBox = vs.strName;
    11971200        if (nameVBox == "")
    11981201            nameVBox = osTypeVBox;
     
    12021205        /* Now that we know the base system get our internal defaults based on that. */
    12031206        ComPtr<IGuestOSType> osType;
    1204         rc = mVirtualBox->GetGuestOSType(Bstr(Utf8Str(osTypeVBox.c_str())), osType.asOutParam());
     1207        rc = mVirtualBox->GetGuestOSType(Bstr(osTypeVBox), osType.asOutParam());
    12051208        ComAssertComRCThrowRC(rc);
    12061209
     
    12621265                        // @todo: figure out the SCSI types
    12631266# ifdef VBOX_WITH_LSILOGIC
    1264                         string hdcController = "LsiLogic";
     1267                        Utf8Str hdcController = "LsiLogic";
    12651268# elif VBOX_WITH_BUSLOGIC
    1266                         string hdcController = "BusLogic";
     1269                        Utf8Str hdcController = "BusLogic";
    12671270# else /* !VBOX_WITH_BUSLOGIC */
    1268                         string hdcController;
     1271                        Utf8Str hdcController;
    12691272# endif
    12701273# ifdef VBOX_WITH_LSILOGIC
     
    13201323                {
    13211324                    /* 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());
    13231326                    /* Make the path unique to the VBox installation */
    13241327                    searchUniqueDiskImageFilePath(path);
     
    13361339            rc = osType->COMGETTER(AdapterType)(&nwAdapterVBox);
    13371340            ComAssertComRCThrowRC(rc);
    1338             list<string>::const_iterator nwIt;
     1341            list<Utf8Str>::const_iterator nwIt;
    13391342            /* Iterate through all abstract networks. We support 8 network
    13401343             * adapters at the maximum. (@todo: warn if it are more!) */
     
    13441347                 ++nwIt, ++a)
    13451348            {
    1346                 // string nwController = *nwIt; // @todo: not used yet
     1349                // Utf8Str nwController = *nwIt; // @todo: not used yet
    13471350                vsd->addEntry(VirtualSystemDescriptionType_NetworkAdapter, "", "", toString<ULONG>(nwAdapterVBox));
    13481351            }
     
    13771380        std::list<VirtualSystemDescriptionEntry*> vsdeOS = vsd->findByType(VirtualSystemDescriptionType_OS);
    13781381        Assert(vsdeOS.size() == 1);
    1379         string osTypeVBox = vsdeOS.front()->strFinalValue;
     1382        const Utf8Str &osTypeVBox = vsdeOS.front()->strFinalValue;
    13801383
    13811384        /* Now that we know the base system get our internal defaults based on that. */
    13821385        ComPtr<IGuestOSType> osType;
    1383         rc = mVirtualBox->GetGuestOSType(Bstr(Utf8Str(osTypeVBox.c_str())), osType.asOutParam());
     1386        rc = mVirtualBox->GetGuestOSType(Bstr(osTypeVBox), osType.asOutParam());
    13841387        ComAssertComRCThrowRC(rc);
    13851388
     
    13881391        std::list<VirtualSystemDescriptionEntry*> vsdeName = vsd->findByType(VirtualSystemDescriptionType_Name);
    13891392        Assert(vsdeName.size() == 1);
    1390         string nameVBox = vsdeName.front()->strFinalValue;
     1393        const Utf8Str &nameVBox = vsdeName.front()->strFinalValue;
    13911394        ComPtr<IMachine> newMachine;
    13921395        rc = mVirtualBox->CreateMachine(Bstr(nameVBox.c_str()), Bstr(osTypeVBox.c_str()),
     
    14031406        std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsd->findByType(VirtualSystemDescriptionType_Memory);
    14041407        Assert(vsdeRAM.size() == 1);
    1405         string memoryVBox = vsdeRAM.front()->strFinalValue;
     1408        const Utf8Str &memoryVBox = vsdeRAM.front()->strFinalValue;
    14061409        uint64_t tt = RTStrToUInt64(memoryVBox.c_str()) / _1M;
    14071410
     
    14401443                 ++nwIt, ++a)
    14411444            {
    1442                 string nwTypeVBox = (*nwIt)->strFinalValue;
     1445                const Utf8Str &nwTypeVBox = (*nwIt)->strFinalValue;
    14431446                uint32_t tt1 = RTStrToUInt32(nwTypeVBox.c_str());
    14441447                ComPtr<INetworkAdapter> nwVBox;
     
    14741477        if (vsdeHDCSATA.size() > 0)
    14751478        {
    1476             string hdcVBox = vsdeHDCIDE.front()->strFinalValue;
    1477             if (!RTStrCmp(hdcVBox.c_str(), "AHCI"))
     1479            const Utf8Str &hdcVBox = vsdeHDCIDE.front()->strFinalValue;
     1480            if (hdcVBox == "AHCI")
    14781481            {
    14791482                /* For now we have just to enable the AHCI controller. */
     
    15411544//                    continue;
    15421545                }
    1543                 const string &strRef = (*hdIt)->strRef;
     1546                const Utf8Str &strRef = (*hdIt)->strRef;
    15441547                /* Get the associated disk image */
    15451548                if (m->mapDisks.find(strRef) == m->mapDisks.end())
     
    15471550                    /* @todo: error: entry doesn't exists */
    15481551                }
    1549                 DiskImage di = m->mapDisks [strRef];
     1552                DiskImage di = m->mapDisks[strRef];
    15501553                /* Construct the source file path */
    15511554                char *srcFilePath;
     
    16151618}
    16161619
    1617 HRESULT Appliance::searchUniqueVMName(std::string& aName) const
     1620HRESULT Appliance::searchUniqueVMName(Utf8Str& aName) const
    16181621{
    16191622    IMachine *machine = NULL;
     
    16331636}
    16341637
    1635 HRESULT Appliance::searchUniqueDiskImageFilePath(std::string& aName) const
     1638HRESULT Appliance::searchUniqueDiskImageFilePath(Utf8Str& aName) const
    16361639{
    16371640    IHardDisk2 *harddisk = NULL;
     
    17211724         ++it, ++i)
    17221725    {
    1723         VirtualSystemDescriptionEntry vsde = (*it);
     1726        const VirtualSystemDescriptionEntry &vsde = (*it);
    17241727        /* Types */
    17251728        sfaTypes [i] = vsde.type;
    17261729        /* Original value */
    1727         Bstr bstr = Utf8Str(vsde.strOriginalValue.c_str());
    1728         bstr.cloneTo(&sfaOrigValues [i]);
     1730        Bstr bstr = vsde.strOriginalValue;
     1731        bstr.cloneTo(&sfaOrigValues[i]);
    17291732        /* Auto value */
    1730         bstr = Utf8Str(vsde.strAutoValue.c_str());
    1731         bstr.cloneTo(&sfaAutoValues [i]);
     1733        bstr = vsde.strAutoValue;
     1734        bstr.cloneTo(&sfaAutoValues[i]);
    17321735        /* Configuration */
    1733         bstr = Utf8Str(vsde.strConfiguration.c_str());
    1734         bstr.cloneTo(&sfaConfigurations [i]);
     1736        bstr = vsde.strConfiguration;
     1737        bstr.cloneTo(&sfaConfigurations[i]);
    17351738    }
    17361739
     
    17631766    {
    17641767        VirtualSystemDescriptionEntry vsde = (*it);
    1765         vsde.strFinalValue = Utf8Str(values[i]).raw();
     1768        vsde.strFinalValue = values[i];
    17661769    }
    17671770
     
    17701773
    17711774void 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 /* = "" */)
    17761779{
    17771780    VirtualSystemDescriptionEntry vsde;
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r16309 r16325  
    2727#include "VirtualBoxBase.h"
    2828
    29 #include <string>
     29// #include <string>
    3030
    3131class VirtualBox;
     
    9090    HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::Node *pContentElem);
    9191
    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;
    9494};
    9595
     
    9797{
    9898    VirtualSystemDescriptionType_T type; /* Of which type is this value */
    99     std::string strRef; /* Reference value to the internal implementation */
    100     std::string strOriginalValue; /* The original OVF value */
    101     std::string strAutoValue; /* The value which VBox suggest */
    102     std::string strFinalValue; /* The value the user select */
    103     std::string strConfiguration; /* 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 */
    104104};
    105105
     
    151151private:
    152152    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 = "");
    157157
    158158    std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
  • trunk/src/VBox/Main/xml/xml.cpp

    r16188 r16325  
    2121#include "Logging.h"
    2222
     23#include <boost/shared_ptr.hpp>
     24
    2325#include <iprt/err.h>
    2426#include <iprt/file.h>
     
    3537#include <libxml/xmlschemas.h>
    3638
    37 #include <string>
    3839#include <list>
    3940#include <map>
    40 
    41 #include "boost/shared_ptr.hpp"
    4241
    4342#include "VBox/xml.h"
     
    685684 * @return TRUE if attribute was found and str was thus updated.
    686685 */
    687 bool Node::getAttributeValue(const char *pcszMatch, std::string &str) const
     686bool Node::getAttributeValue(const char *pcszMatch, com::Utf8Str &str) const
    688687{
    689688    const Node* pAttr;
     
    709708bool Node::getAttributeValue(const char *pcszMatch, int64_t &i) const
    710709{
    711     std::string str;
     710    com::Utf8Str str;
    712711    if (    (getAttributeValue(pcszMatch, str))
    713712         && (VINF_SUCCESS == RTStrToInt64Ex(str.c_str(), NULL, 10, &i))
     
    730729bool Node::getAttributeValue(const char *pcszMatch, uint64_t &i) const
    731730{
    732     std::string str;
     731    com::Utf8Str str;
    733732    if (    (getAttributeValue(pcszMatch, str))
    734733         && (VINF_SUCCESS == RTStrToUInt64Ex(str.c_str(), NULL, 10, &i))
     
    907906{
    908907    xmlParserCtxtPtr ctxt;
    909     std::string strXmlFilename;
     908    com::Utf8Str strXmlFilename;
    910909
    911910    Data()
     
    935934{
    936935    File file;
    937     std::string error;
     936    com::Utf8Str error;
    938937
    939938    ReadContext(const char *pcszFilename)
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette