Beispiel #1
0
void XMLConfigurator::load(XMLNodeWrapperPtr& pNode, Configurator::ConfMap& conf)
{
    XMLNodeWrapperPtr pChild = pNode->firstNode();
    if (pChild.isNull())
    {
        Configurator c(conf, Configurator::TO_CONF);
        string sValue = pNode->getValue();
        c.configure((const string&)pNode->getName(), 
                    sValue, (const string&)_T(""));
        conf = c.getMap();
    }
    else if (pChild->nextSibling().isNull() 
             && pChild->type() == XMLDocumentWrapper::NODE_DATA)
    {
        Configurator c(conf, Configurator::TO_CONF);
        string sValue = pChild->getValue();
        c.configure((const string&)pNode->getName(), 
                    sValue, (const string&)_T(""));
        conf = c.getMap();
    }
    else 
    {
        Configurator::ConfMap confMap;
        for (XMLNodeWrapperPtr pSubNode = pNode->firstNode();
             pSubNode.isNotNull(); pSubNode = pSubNode->nextSibling())
        {
            load(pSubNode, confMap);
        }

        if (strCompareNoCase(pNode->getName(), CONFIGURE_TAG_NAME))
        {
            Configurator c(conf, Configurator::TO_CONF);
            c.configure(pNode->getName(), confMap);
            conf = c.getMap();
        }
        else 
        {
            conf = confMap;
        }
    }
}