VirtualBox

Changeset 19519 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 8, 2009 12:38:07 PM (16 years ago)
Author:
vboxsync
Message:

Main: decouple xml classes from COM dependencies

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

Legend:

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

    r19310 r19519  
    600600        DiskImage d;
    601601        const char *pcszBad = NULL;
    602         if (!(pelmDisk->getAttributeValue("diskId", d.strDiskId)))
     602        const char *pcszDiskId;
     603        const char *pcszFormat;
     604        if (!(pelmDisk->getAttributeValue("diskId", pcszDiskId)))
    603605            pcszBad = "diskId";
    604         else if (!(pelmDisk->getAttributeValue("format", d.strFormat)))
     606        else if (!(pelmDisk->getAttributeValue("format", pcszFormat)))
    605607            pcszBad = "format";
    606608        else if (!(pelmDisk->getAttributeValue("capacity", d.iCapacity)))
     
    608610        else
    609611        {
     612            d.strDiskId = pcszDiskId;
     613            d.strFormat = pcszFormat;
     614
    610615            if (!(pelmDisk->getAttributeValue("populatedSize", d.iPopulatedSize)))
    611616                // optional
    612617                d.iPopulatedSize = -1;
    613618
    614             Utf8Str strFileRef;
    615             if (pelmDisk->getAttributeValue("fileRef", strFileRef)) // optional
     619            const char *pcszFileRef;
     620            if (pelmDisk->getAttributeValue("fileRef", pcszFileRef)) // optional
    616621            {
    617622                // look up corresponding /References/File nodes (list built above)
    618623                const xml::ElementNode *pFileElem;
    619624                if (    pReferencesElem
    620                      && ((pFileElem = pReferencesElem->findChildElementFromId(strFileRef.c_str())))
     625                     && ((pFileElem = pReferencesElem->findChildElementFromId(pcszFileRef)))
    621626                   )
    622627                {
    623628                    // copy remaining values from file node then
    624629                    const char *pcszBadInFile = NULL;
    625                     if (!(pFileElem->getAttributeValue("href", d.strHref)))
     630                    const char *pcszHref;
     631                    if (!(pFileElem->getAttributeValue("href", pcszHref)))
    626632                        pcszBadInFile = "href";
    627633                    else if (!(pFileElem->getAttributeValue("size", d.iSize)))
    628634                        d.iSize = -1;       // optional
     635
     636                    d.strHref = pcszHref;
     637
    629638                    // if (!(pFileElem->getAttributeValue("size", d.iChunkSize))) TODO
    630639                    d.iChunkSize = -1;       // optional
    631                     pFileElem->getAttributeValue("compression", d.strCompression);
     640                    const char *pcszCompression;
     641                    if (pFileElem->getAttributeValue("compression", pcszCompression))
     642                        d.strCompression = pcszCompression;
    632643
    633644                    if (pcszBadInFile)
     
    642653                                    tr("Error reading \"%s\": cannot find References/File element for ID '%s' referenced by 'Disk' element, line %d"),
    643654                                    pcszPath,
    644                                     strFileRef.c_str(),
     655                                    pcszFileRef,
    645656                                    pelmDisk->getLineNumber());
    646657            }
     
    23222333                        rc = dstHdVBox->COMGETTER(Id)(hdId.asOutParam());
    23232334                        if (FAILED(rc)) throw rc;
    2324                          
     2335
    23252336                        /* For now we assume we have one controller of every type only */
    23262337                        HardDiskController hdc = (*vsysThis.mapControllers.find(vd.idController)).second;
  • trunk/src/VBox/Main/xml/xml.cpp

    r18515 r19519  
    721721 * @return TRUE if attribute was found and str was thus updated.
    722722 */
    723 bool ElementNode::getAttributeValue(const char *pcszMatch, com::Utf8Str &str) const
     723bool ElementNode::getAttributeValue(const char *pcszMatch, const char *&ppcsz) const
    724724{
    725725    const Node* pAttr;
    726726    if ((pAttr = findAttribute(pcszMatch)))
    727727    {
    728         str = pAttr->getValue();
     728        ppcsz = pAttr->getValue();
    729729        return true;
    730730    }
     
    745745bool ElementNode::getAttributeValue(const char *pcszMatch, int64_t &i) const
    746746{
    747     com::Utf8Str str;
    748     if (    (getAttributeValue(pcszMatch, str))
    749          && (VINF_SUCCESS == RTStrToInt64Ex(str.c_str(), NULL, 10, &i))
     747    const char *pcsz;
     748    if (    (getAttributeValue(pcszMatch, pcsz))
     749         && (VINF_SUCCESS == RTStrToInt64Ex(pcsz, NULL, 10, &i))
    750750       )
    751751        return true;
     
    766766bool ElementNode::getAttributeValue(const char *pcszMatch, uint64_t &i) const
    767767{
    768     com::Utf8Str str;
    769     if (    (getAttributeValue(pcszMatch, str))
    770          && (VINF_SUCCESS == RTStrToUInt64Ex(str.c_str(), NULL, 10, &i))
     768    const char *pcsz;
     769    if (    (getAttributeValue(pcszMatch, pcsz))
     770         && (VINF_SUCCESS == RTStrToUInt64Ex(pcsz, NULL, 10, &i))
    771771       )
    772772        return true;
Note: See TracChangeset for help on using the changeset viewer.

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