VirtualBox

Changeset 27918 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Mar 31, 2010 5:10:40 PM (15 years ago)
Author:
vboxsync
Message:

Main/OVF: import vbox:Machine XML within OVF, first batch (XML is parsed and machine config created, but COM Machine can't handle it yet)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r27418 r27918  
    506506}
    507507
    508 bool Node::nameEquals(const char *pcsz) const
     508/**
     509 * Variant of nameEquals that checks the namespace as well.
     510 * @param pcszNamespace
     511 * @param pcsz
     512 * @return
     513 */
     514bool Node::nameEquals(const char *pcszNamespace, const char *pcsz) const
    509515{
    510516    if (m->pcszName == pcsz)
     
    514520    if (pcsz == NULL)
    515521        return false;
    516     return !strcmp(m->pcszName, pcsz);
    517 }
    518 
     522    if (strcmp(m->pcszName, pcsz))
     523        return false;
     524
     525    // name matches: then check namespaces as well
     526    if (!pcszNamespace)
     527        return true;
     528    // caller wants namespace:
     529    if (    !m->plibNode->ns
     530         || !m->plibNode->ns->prefix
     531         || !*m->plibNode->ns->prefix
     532       )
     533        // but node has no namespace:
     534        return false;
     535    return !strcmp((const char*)m->plibNode->ns->prefix, pcszNamespace);
     536}
    519537
    520538/**
     
    663681/**
    664682 * Returns the first child element whose name matches pcszMatch.
    665  * @param pcszMatch
     683 *
     684 * @param pcszNamespace Namespace prefix (e.g. "vbox") or NULL to match any namespace.
     685 * @param pcszMatch Element name to match.
    666686 * @return
    667687 */
    668 const ElementNode* ElementNode::findChildElement(const char *pcszMatch)
     688const ElementNode* ElementNode::findChildElement(const char *pcszNamespace,
     689                                                 const char *pcszMatch)
    669690    const
    670691{
     
    679700        {
    680701            ElementNode *pelm = static_cast<ElementNode*>((*it).get());
    681             if (!strcmp(pcszMatch, pelm->getName())) // the element name matches
     702            if (pelm->nameEquals(pcszNamespace, pcszMatch))
    682703                return pelm;
    683704        }
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