• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ XmlNodeList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XmlNodeList的典型用法代码示例。如果您正苦于以下问题:C++ XmlNodeList类的具体用法?C++ XmlNodeList怎么用?C++ XmlNodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XmlNodeList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fprintf

void plainconf::outputConfigFile(const XmlNode *pNode, FILE *fp, int level)
{
    XmlNodeList list;
    int count = pNode->getAllChildren(list);
    list.sort(s_compare);

    if (count > 0)
    {
        if (level > 0)
        {
            fprintf(fp, "\n");
            outputSpaces(level, fp);
            const char *value = pNode->getValue();

            if (!value)
                value = "";

            fprintf(fp, "%s %s {\n", pNode->getName(), value);
        }

        XmlNodeList::const_iterator iter;

        for (iter = list.begin(); iter != list.end(); ++iter)
            outputConfigFile((*iter), fp, level + 1);

        if (level > 0)
        {
            outputSpaces(level, fp);
            fprintf(fp, "}\n");
        }
    }
    else
        outputSigleNode(fp, pNode, level);
}
开发者ID:Acidburn0zzz,项目名称:openlitespeed,代码行数:34,代码来源:plainconf.cpp


示例2: displayNodeList

void displayNodeList(XmlNodeList &nodelist)
{
	for (auto i = nodelist.begin(); i != nodelist.end(); ++i)
	{
		cout << (*i)->toString() << endl;
	}
}
开发者ID:vulfgang,项目名称:coursework-kitten,代码行数:7,代码来源:main.cpp


示例3: main

int main()
{
	const int NUMBER_OF_FILES = 4; // can change if more/less than 4 files
	vector<string> filenames = getFileNames(NUMBER_OF_FILES);

	ThreadedUserParser userParser("<user>(.|\\n)*?</user>");

	cout << "Starting timer...\n\n\n";
	clock_t begin = clock(); // start timer

	cout << "Now parsing all files...";
	XmlNodeList nodelist = userParser.parseUserFiles(filenames);

	clock_t end = clock();
	cout << "Finished parsing all files." << endl
		<< "\nTotal number of users: " << nodelist.size() << endl
		<< "Total time taken to parse: " << double(end - begin) / CLOCKS_PER_SEC << " seconds\n\n\n";

	cout << "\n\nNow displaying all user data (encrypted):\n\n";
	displayNodeList(nodelist);
	cout << "\n\n\n\n\n";

	cout << "Decrypting all user data...";
	decryptUserData(nodelist);
	cout << "Finished decrypting all user data.\n\n\n";

	cout << "\n\nNow displaying user data (decrypted):\n\n";
	displayNodeList(nodelist);
	
	cout << "\n\n\nNow exiting...\n\n";

	return 0;
}
开发者ID:vulfgang,项目名称:coursework-kitten,代码行数:33,代码来源:main.cpp


示例4: decryptUserData

void decryptUserData(XmlNodeList &nodelist)
{
	UserDecryptor decryptor;

	for (auto i = nodelist.begin(); i != nodelist.end(); ++i)
	{
		// "*i" dereferences the XmlNode* which is then
		// casted to a User*, which finally is dereferenced
		// to the User instance and passed to decryptor.convert()
		decryptor.convert(*dynamic_cast<User*>(*i));
	}
}
开发者ID:vulfgang,项目名称:coursework-kitten,代码行数:12,代码来源:main.cpp


示例5: handleSpecialCaseLoop

void plainconf::handleSpecialCaseLoop(XmlNode *pNode)
{
    XmlNodeList list;
    int count = pNode->getAllChildren(list);

    if (count > 0)
    {
        XmlNodeList::const_iterator iter;

        for (iter = list.begin(); iter != list.end(); ++iter)
            handleSpecialCaseLoop(*iter);

        handleSpecialCase(pNode);
    }
}
开发者ID:Acidburn0zzz,项目名称:openlitespeed,代码行数:15,代码来源:plainconf.cpp


示例6: release

void plainconf::release(XmlNode *pNode)
{
    XmlNodeList list;
    int count = pNode->getAllChildren(list);

    if (count > 0)
    {
        XmlNodeList::const_iterator iter;

        for (iter = list.begin(); iter != list.end(); ++iter)
            release(*iter);
    }

    if (!pNode->getParent())
        delete pNode;
}
开发者ID:Acidburn0zzz,项目名称:openlitespeed,代码行数:16,代码来源:plainconf.cpp


示例7: trim

WMSCapabilities*
WMSCapabilitiesReader::read(std::istream &in)
{
    osg::ref_ptr<WMSCapabilities> capabilities = new WMSCapabilities;

    osg::ref_ptr<XmlDocument> doc = XmlDocument::load( in );
    if (!doc.valid() || doc->getChildren().empty())
    {
        OE_NOTICE << "Failed to load Capabilities " << std::endl;
        return 0;
    }

    //Get the Capabilities version
    osg::ref_ptr<XmlElement> e_root = static_cast<XmlElement*>(doc->getChildren()[0].get());
    capabilities->setVersion( e_root->getAttr(ATTR_VERSION ) );

    osg::ref_ptr<XmlElement> e_capability = e_root->getSubElement( ELEM_CAPABILITY );
    if (!e_capability.valid())
    {
        OE_NOTICE << "Could not find Capability element" << std::endl;
        return 0;
    }

    //Get the supported formats
    osg::ref_ptr<XmlElement> e_request = e_capability->getSubElement( ELEM_REQUEST );
    if (e_request.valid())
    {
        osg::ref_ptr<XmlElement> e_getMap = e_request->getSubElement( ELEM_GETMAP );
        if ( e_getMap.valid() )
        {
            //Read all the formats
            XmlNodeList formats = e_getMap->getSubElements( ELEM_FORMAT );
            for( XmlNodeList::const_iterator i = formats.begin(); i != formats.end(); i++ )
            {            
                string format = trim(static_cast<XmlElement*>( i->get() )->getText());
                capabilities->getFormats().push_back(format);
            }
        }
    }

    //Try to read the layers
    readLayers( e_capability.get(), 0, capabilities->getLayers());

    return capabilities.release();
}
开发者ID:rhabacker,项目名称:osgearth,代码行数:45,代码来源:WMS.cpp


示例8:

XmlNodeList 
XmlElement::getSubElements( const std::string& name ) const
{
    XmlNodeList results;

    std::string name_lower = name;
    std::transform( name_lower.begin(), name_lower.end(), name_lower.begin(), tolower );

    for( XmlNodeList::const_iterator i = getChildren().begin(); i != getChildren().end(); i++ )
    {
        if ( i->get()->isElement() )
        {
            XmlElement* e = (XmlElement*)i->get();
            std::string name = e->getName();
            std::transform( name.begin(), name.end(), name.begin(), tolower );
            if ( name == name_lower )
                results.push_back( e );
        }
    }

    return results;
}
开发者ID:JohnDr,项目名称:osgearth,代码行数:22,代码来源:XmlUtils.cpp


示例9: removeElementNamespace

WFSCapabilities*
WFSCapabilitiesReader::read(std::istream &in)
{
    osg::ref_ptr<WFSCapabilities> capabilities = new WFSCapabilities;

    osg::ref_ptr<XmlDocument> doc = XmlDocument::load( in );
    if (!doc.valid() || doc->getChildren().empty())
    {
        OE_NOTICE << "Failed to load Capabilities " << std::endl;
        return 0;
    }

    //Get the Capabilities version
    osg::ref_ptr<XmlElement> e_root = static_cast<XmlElement*>(doc->getChildren()[0].get());
    capabilities->setVersion( e_root->getAttr(ATTR_VERSION ) );

    removeElementNamespace(e_root);

    osg::ref_ptr<XmlElement> e_service = e_root->getSubElement( ELEM_SERVICE );
    if (!e_service.valid())
    {
        OE_NOTICE << "Could not find Service element" << std::endl;
        return 0;
    }
    

    //Read the parameters from the Service block
    capabilities->setName( e_service->getSubElementText(ELEM_NAME ) );
    capabilities->setAbstract( e_service->getSubElementText( ELEM_ABSTRACT ) );
    capabilities->setTitle( e_service->getSubElementText( ELEM_TITLE ) );    

    //Read all the feature types    
    osg::ref_ptr<XmlElement> e_feature_types = e_root->getSubElement( ELEM_FEATURETYPELIST );
    if (e_feature_types.valid())
    {
        XmlNodeList featureTypes = e_feature_types->getSubElements( ELEM_FEATURETYPE );
        for( XmlNodeList::const_iterator itr = featureTypes.begin(); itr != featureTypes.end(); itr++ )
        {
            XmlElement* e_featureType = static_cast<XmlElement*>( itr->get() );
            WFSFeatureType* featureType = new WFSFeatureType();
            featureType->setName( e_featureType->getSubElementText( ELEM_NAME ) );
            featureType->setTitle( e_featureType->getSubElementText( ELEM_TITLE ) );
            featureType->setAbstract( e_featureType->getSubElementText( ELEM_ABSTRACT ) );

            //NOTE:  TILED and MAXLEVEL aren't part of the WFS spec, these are enhancements to our server for tiled WFS access
            std::string tiledStr = e_featureType->getSubElementText(ELEM_TILED);
            featureType->setTiled( as<bool>(tiledStr, false) );

            std::string maxLevelStr = e_featureType->getSubElementText(ELEM_MAXLEVEL);
            featureType->setMaxLevel( as<int>(maxLevelStr, -1));

            std::string firstLevelStr = e_featureType->getSubElementText(ELEM_FIRSTLEVEL);
            featureType->setFirstLevel( as<int>(firstLevelStr, 0));

            // Read the SRS            
            std::string srsText = e_featureType->getSubElementText(ELEM_SRS);
            if (srsText.compare("") != 0)
            {                
                featureType->setSRS( srsText );                
            }

            osg::ref_ptr<XmlElement> e_bb = e_featureType->getSubElement( ELEM_LATLONGBOUNDINGBOX );
            if (e_bb.valid())
            {
                double minX, minY, maxX, maxY;
                minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0);
                minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0);
                maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0);
                maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0);                
                featureType->setExtent( GeoExtent( osgEarth::SpatialReference::create( srsText ), minX, minY, maxX, maxY) );
            }                       

            capabilities->getFeatureTypes().push_back( featureType );
        }        
    }


    return capabilities.release();
}
开发者ID:ifad-ts,项目名称:osgearth,代码行数:79,代码来源:WFS.cpp


示例10: readLayers

static void
readLayers(XmlElement* e, WMSLayer* parentLayer, WMSLayer::LayerList& layers)
{
    XmlNodeList layerNodes = e->getSubElements( ELEM_LAYER );
    for( XmlNodeList::const_iterator i = layerNodes.begin(); i != layerNodes.end(); i++ )
    {
        XmlElement* e_layer = static_cast<XmlElement*>( i->get() );

        WMSLayer *layer = new WMSLayer;
        layer->setName( e_layer->getSubElementText( ELEM_NAME ) );
        layer->setTitle( e_layer->getSubElementText( ELEM_TITLE ) );
        layer->setAbstract( e_layer->getSubElementText( ELEM_ABSTRACT ) );        

        //Read all the supported styles
        XmlNodeList styles = e_layer->getSubElements( ELEM_STYLE );
        for( XmlNodeList::const_iterator styleitr = styles.begin(); styleitr != styles.end(); styleitr++ )
        {
            XmlElement* e_style = static_cast<XmlElement*>( styleitr->get() );
            string name = e_style->getSubElementText( ELEM_NAME );
            string title = e_style->getSubElementText( ELEM_TITLE );
            layer->getStyles().push_back(WMSStyle(name,title));
        }

        //Read all the supported SRS's
        XmlNodeList spatialReferences = e_layer->getSubElements( ELEM_SRS );
        for (XmlNodeList::const_iterator srsitr = spatialReferences.begin(); srsitr != spatialReferences.end(); ++srsitr)
        {
            string srs = static_cast<XmlElement*>( srsitr->get() )->getText();
            layer->getSpatialReferences().push_back(srs);
        }

        //Read all the supported CRS's
        spatialReferences = e_layer->getSubElements( ELEM_CRS );
        for (XmlNodeList::const_iterator srsitr = spatialReferences.begin(); srsitr != spatialReferences.end(); ++srsitr)
        {
            string crs = static_cast<XmlElement*>( srsitr->get() )->getText();
            layer->getSpatialReferences().push_back(crs);
        }

        osg::ref_ptr<XmlElement> e_bb = e_layer->getSubElement( ELEM_LATLONBOUNDINGBOX );
        if (e_bb.valid())
        {
            double minX, minY, maxX, maxY;
            minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0);
            minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0);
            maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0);
            maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0);
            layer->setLatLonExtents(minX, minY, maxX, maxY);
        }
        else {
            osg::ref_ptr<XmlElement> e_gbb = e_layer->getSubElement( ELEM_GEOGRAPHICBOUNDINGBOX );
            if (e_gbb.valid())
            {
                double minX, minY, maxX, maxY;
                minX = as<double>(e_gbb->getSubElementText( ATTR_WESTLON ), 0);
                minY = as<double>(e_gbb->getSubElementText( ATTR_SOUTHLAT ), 0);
                maxX = as<double>(e_gbb->getSubElementText( ATTR_EASTLON ), 0);
                maxY = as<double>(e_gbb->getSubElementText( ATTR_NORTHLAT ), 0);
                layer->setLatLonExtents(minX, minY, maxX, maxY);
            }
        }

        e_bb = e_layer->getSubElement( ELEM_BOUNDINGBOX );
        if (e_bb.valid())
        {
            double minX, minY, maxX, maxY;
            minX = as<double>(e_bb->getAttr( ATTR_MINX ), 0);
            minY = as<double>(e_bb->getAttr( ATTR_MINY ), 0);
            maxX = as<double>(e_bb->getAttr( ATTR_MAXX ), 0);
            maxY = as<double>(e_bb->getAttr( ATTR_MAXY ), 0);
            layer->setExtents(minX, minY, maxX, maxY);
        }

        //Add the layer to the list and set its parent layer
        layers.push_back(layer);
        layer->setParentLayer( parentLayer );

        //Read any other layers that are in the layer node
        readLayers( e_layer, layer, layer->getLayers());
    }
}
开发者ID:rhabacker,项目名称:osgearth,代码行数:81,代码来源:WMS.cpp



注:本文中的XmlNodeList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XmlNodeRef类代码示例发布时间:2022-05-31
下一篇:
C++ XmlNode类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap