VirtualBox

Changeset 49029 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 10, 2013 1:17:09 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
89795
Message:

ovfreader: Don't check for xsi:type, just look for type. Dropped a bunch of unnecesary parenthese. Changed throw(xxx) with RT_THROW(xxx) on method declarations and definitions MSVC has been complaining about this for years.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ovfreader.h

    r48955 r49029  
    3838 * that one catch() for all xml::LogicError can handle all possible errors.
    3939 */
    40 
    4140class OVFLogicError : public xml::LogicError
    4241{
     
    4443    OVFLogicError(const char *aFormat, ...);
    4544};
     45
    4646
    4747////////////////////////////////////////////////////////////////////////////////
     
    371371    }
    372372
    373     void checkConsistencyAndCompliance() throw (OVFLogicError)
     373    void checkConsistencyAndCompliance() RT_THROW(OVFLogicError)
    374374    {
    375375        _checkConsistencyAndCompliance();
     
    377377
    378378protected:
    379     virtual void _checkConsistencyAndCompliance() throw (OVFLogicError);
     379    virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
    380380    virtual const RTCString& getItemName()
    381381    {
     
    428428
    429429protected:
    430     virtual void _checkConsistencyAndCompliance() throw (OVFLogicError);
     430    virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
    431431private:
    432432    RTCString itemName;
     
    474474
    475475protected:
    476     virtual void _checkConsistencyAndCompliance() throw (OVFLogicError);
     476    virtual void _checkConsistencyAndCompliance() RT_THROW(OVFLogicError);
    477477private:
    478478    RTCString itemName;
     
    632632</code>
    633633 */
    634 
    635634class OVFReader
    636635{
  • trunk/src/VBox/Main/xml/ovfreader.cpp

    r49028 r49029  
    133133    {
    134134        const char *pcszElemName = pElem->getName();
    135         const char *pcszTypeAttr = "";
    136         const xml::AttributeNode *pTypeAttr;
    137         if (    (pTypeAttr = pElem->findAttribute("type", "xsi")) != NULL
    138              || (pTypeAttr = pElem->findAttribute("type")) != NULL
    139            )
    140             pcszTypeAttr = pTypeAttr->getValue();
    141 
    142         if (    (!strcmp(pcszElemName, "DiskSection"))
    143              || (    (!strcmp(pcszElemName, "Section"))
    144                   && (!strcmp(pcszTypeAttr, "ovf:DiskSection_Type"))
     135        const xml::AttributeNode *pTypeAttr = pElem->findAttribute("type");
     136        const char *pcszTypeAttr = pTypeAttr ? pTypeAttr->getValue() : "";
     137
     138        if (    !strcmp(pcszElemName, "DiskSection")
     139             || (    !strcmp(pcszElemName, "Section")
     140                  && !strcmp(pcszTypeAttr, "ovf:DiskSection_Type")
    145141                )
    146142           )
     
    148144            HandleDiskSection(pReferencesElem, pElem);
    149145        }
    150         else if (    (!strcmp(pcszElemName, "NetworkSection"))
    151                   || (    (!strcmp(pcszElemName, "Section"))
    152                        && (!strcmp(pcszTypeAttr, "ovf:NetworkSection_Type"))
     146        else if (    !strcmp(pcszElemName, "NetworkSection")
     147                  || (    !strcmp(pcszElemName, "Section")
     148                       && !strcmp(pcszTypeAttr, "ovf:NetworkSection_Type")
    153149                     )
    154150                )
     
    156152            HandleNetworkSection(pElem);
    157153        }
    158         else if (    (!strcmp(pcszElemName, "DeploymentOptionSection")))
     154        else if (    !strcmp(pcszElemName, "DeploymentOptionSection"))
    159155        {
    160156            // TODO
    161157        }
    162         else if (    (!strcmp(pcszElemName, "Info")))
     158        else if (    !strcmp(pcszElemName, "Info"))
    163159        {
    164160            // child of VirtualSystemCollection -- TODO
    165161        }
    166         else if (    (!strcmp(pcszElemName, "ResourceAllocationSection")))
     162        else if (    !strcmp(pcszElemName, "ResourceAllocationSection"))
    167163        {
    168164            // child of VirtualSystemCollection -- TODO
    169165        }
    170         else if (    (!strcmp(pcszElemName, "StartupSection")))
     166        else if (    !strcmp(pcszElemName, "StartupSection"))
    171167        {
    172168            // child of VirtualSystemCollection -- TODO
    173169        }
    174         else if (    (!strcmp(pcszElemName, "VirtualSystem"))
    175                   || (    (!strcmp(pcszElemName, "Content"))
    176                        && (!strcmp(pcszTypeAttr, "ovf:VirtualSystem_Type"))
     170        else if (    !strcmp(pcszElemName, "VirtualSystem")
     171                  || (    !strcmp(pcszElemName, "Content")
     172                       && !strcmp(pcszTypeAttr, "ovf:VirtualSystem_Type")
    177173                     )
    178174                )
     
    180176            HandleVirtualSystemContent(pElem);
    181177        }
    182         else if (    (!strcmp(pcszElemName, "VirtualSystemCollection"))
    183                   || (    (!strcmp(pcszElemName, "Content"))
    184                        && (!strcmp(pcszTypeAttr, "ovf:VirtualSystemCollection_Type"))
     178        else if (    !strcmp(pcszElemName, "VirtualSystemCollection")
     179                  || (    !strcmp(pcszElemName, "Content")
     180                       && !strcmp(pcszTypeAttr, "ovf:VirtualSystemCollection_Type")
    185181                     )
    186182                )
     
    215211        const char *pcszDiskId;
    216212        const char *pcszFormat;
    217         if (!(pelmDisk->getAttributeValue("diskId", pcszDiskId)))
     213        if (!pelmDisk->getAttributeValue("diskId", pcszDiskId))
    218214            pcszBad = "diskId";
    219         else if (!(pelmDisk->getAttributeValue("format", pcszFormat)))
     215        else if (!pelmDisk->getAttributeValue("format", pcszFormat))
    220216            pcszBad = "format";
    221         else if (!(pelmDisk->getAttributeValue("capacity", d.iCapacity)))
     217        else if (!pelmDisk->getAttributeValue("capacity", d.iCapacity))
    222218            pcszBad = "capacity";
    223219        else
     
    226222            d.strFormat = pcszFormat;
    227223
    228             if (!(pelmDisk->getAttributeValue("populatedSize", d.iPopulatedSize)))
     224            if (!pelmDisk->getAttributeValue("populatedSize", d.iPopulatedSize))
    229225                // optional
    230226                d.iPopulatedSize = -1;
     
    239235                const xml::ElementNode *pFileElem;
    240236                if (    pReferencesElem
    241                      && ((pFileElem = pReferencesElem->findChildElementFromId(pcszFileRef)))
     237                     && (pFileElem = pReferencesElem->findChildElementFromId(pcszFileRef)) != NULL
    242238                   )
    243239                {
     
    246242                    const char *pcszBadInFile = NULL;
    247243                    const char *pcszHref;
    248                     if (!(pFileElem->getAttributeValue("href", pcszHref)))
     244                    if (!pFileElem->getAttributeValue("href", pcszHref))
    249245                        pcszBadInFile = "href";
    250                     else if (!(pFileElem->getAttributeValue("size", d.iSize)))
     246                    else if (!pFileElem->getAttributeValue("size", d.iSize))
    251247                        d.iSize = -1;       // optional
    252248
     
    350346        if (!strcmp(pcszElemName, "Section"))       // OVF 0.9 used "Section" element always with a varying "type" attribute
    351347        {
    352             const xml::AttributeNode *pTypeAttr;
    353             if (    (pTypeAttr = pelmThis->findAttribute("type")) != NULL
    354                  || (pTypeAttr = pelmThis->findAttribute("type", "xsi")) != NULL
    355                )
     348            const xml::AttributeNode *pTypeAttr = pelmThis->findAttribute("type");
     349            if (!pTypeAttr)
    356350                pcszTypeAttr = pTypeAttr->getValue();
    357351            else
     
    361355        }
    362356
    363         if (    (!strcmp(pcszElemName, "EulaSection"))
    364              || (!strcmp(pcszTypeAttr, "ovf:EulaSection_Type"))
     357        if (    !strcmp(pcszElemName, "EulaSection")
     358             || !strcmp(pcszTypeAttr, "ovf:EulaSection_Type")
    365359           )
    366360        {
     
    374368                vsys.strLicenseText = pelmLicense->getValue();
    375369        }
    376         if (    (!strcmp(pcszElemName, "ProductSection"))
    377              || (!strcmp(pcszTypeAttr, "ovf:ProductSection_Type"))
     370        if (    !strcmp(pcszElemName, "ProductSection")
     371             || !strcmp(pcszTypeAttr, "ovf:ProductSection_Type")
    378372           )
    379373        {
     
    402396                vsys.strVendorUrl = pelmVendorUrl->getValue();
    403397        }
    404         else if (    (!strcmp(pcszElemName, "VirtualHardwareSection"))
    405                   || (!strcmp(pcszTypeAttr, "ovf:VirtualHardwareSection_Type"))
     398        else if (    !strcmp(pcszElemName, "VirtualHardwareSection")
     399                  || !strcmp(pcszTypeAttr, "ovf:VirtualHardwareSection_Type")
    406400                )
    407401        {
     
    526520
    527521                    case ResourceType_Memory:        // 4
    528                         if (    (i.strAllocationUnits == "MegaBytes")           // found in OVF created by OVF toolkit
    529                              || (i.strAllocationUnits == "MB")                  // found in MS docs
    530                              || (i.strAllocationUnits == "byte * 2^20")         // suggested by OVF spec DSP0243 page 21
     522                        if (    i.strAllocationUnits == "MegaBytes"           // found in OVF created by OVF toolkit
     523                             || i.strAllocationUnits == "MB"                  // found in MS docs
     524                             || i.strAllocationUnits == "byte * 2^20"         // suggested by OVF spec DSP0243 page 21
    531525                           )
    532526                            vsys.ullMemorySize = i.ullVirtualQuantity * _1M;
     
    797791            }
    798792        }
    799         else if (    (!strcmp(pcszElemName, "OperatingSystemSection"))
    800                   || (!strcmp(pcszTypeAttr, "ovf:OperatingSystemSection_Type"))
     793        else if (    !strcmp(pcszElemName, "OperatingSystemSection")
     794                  || !strcmp(pcszTypeAttr, "ovf:OperatingSystemSection_Type")
    801795                )
    802796        {
     
    908902}
    909903
    910 void VirtualHardwareItem::_checkConsistencyAndCompliance() throw (OVFLogicError)
     904void VirtualHardwareItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError)
    911905{
    912906    RTCString name = getItemName();
     
    987981
    988982
    989 void StorageItem::_checkConsistencyAndCompliance() throw (OVFLogicError)
     983void StorageItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError)
    990984{
    991985    VirtualHardwareItem::_checkConsistencyAndCompliance();
     
    10441038}
    10451039
    1046 void EthernetPortItem::_checkConsistencyAndCompliance() throw (OVFLogicError)
     1040void EthernetPortItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError)
    10471041{
    10481042    VirtualHardwareItem::_checkConsistencyAndCompliance();
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