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

C++ XMLReader类代码示例

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

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



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

示例1: foreach

XMLGenerator::XMLGenerator(const QString &baseDir)
{
    QList<QEngine*> qengines = QtEngines::self()->engines();
    foreach(QEngine *engine, qengines) {
        QString engineDir = engine->name();
        QString fileName = engineDir + "/" + "data.xml";

        if (!baseDir.isEmpty()) {
            engineDir = QString("%1/%2").arg(baseDir).arg(engineDir);
            fileName = QString("%1/%2").arg(baseDir).arg(fileName);
        }

        if (!QFile::exists(fileName))
            continue;


        XMLReader handler;
        QXmlSimpleReader reader;
        reader.setContentHandler(&handler);
        reader.setErrorHandler(&handler);

        QFile file(fileName);
        if (!file.open(QFile::ReadOnly | QFile::Text)) {
            qWarning("Cannot open file '%s', because: %s",
                     qPrintable(fileName), qPrintable(file.errorString()));
            continue;
        }

        QXmlInputSource xmlInputSource(&file);
        if (reader.parse(xmlInputSource)) {
            XMLEngine *engine = handler.xmlEngine();
            checkDirs(engine->generationDate, engineDir);
            engines.insert(engine->name, engine);
        }
    }
开发者ID:tsuibin,项目名称:emscripten-qt,代码行数:35,代码来源:xmlgenerator.cpp


示例2: main

int main(int argc, char ** argv) 
{
    //add ResourceFinder to locate iCub config file (?)
    yarp::os::ResourceFinder resourceFinder;
    resourceFinder.configure(argc, argv);
    
    yarp::os::Value file = resourceFinder.find("inputFile");
    if (file.isNull()) {
        std::cerr << "No input file provided." << std::endl;
        exit(-1);
    }
    
    std::cout << "Start parsing " << file.asString() << std::endl;
    
    XMLReader xmlReader;
    Robot robot = xmlReader.getRobot(file.asString());
    
    icub2gazebo::iCubConfigParser parser(robot);
    parser.startParsing();
    
    std::cout << std::endl << std::endl << "Computing updated PIDs" << std::endl << parser.outputPIDs();
    
    return 0;
    
    
}
开发者ID:ErikSobel-TRI,项目名称:icub-model-generator,代码行数:26,代码来源:main.cpp


示例3: LoadBulletComponent

void EntityFactory::LoadBulletComponent(EntityData& aEntityToAddTo, XMLReader& aDocument, tinyxml2::XMLElement* aBulletComponentElement, float aDifficultScale)
{
	aEntityToAddTo.myDamageRadius = 0.f;
	aEntityToAddTo.myEntity->AddComponent<BulletComponent>();
	for (tinyxml2::XMLElement* e = aBulletComponentElement->FirstChildElement(); e != nullptr; e = e->NextSiblingElement())
	{
		if (std::strcmp(CU::ToLower(e->Name()).c_str(), CU::ToLower("lifeTime").c_str()) == 0)
		{
			aDocument.ForceReadAttribute(e, "value", aEntityToAddTo.myMaxTime);
		}
		if (std::strcmp(CU::ToLower(e->Name()).c_str(), CU::ToLower("damage").c_str()) == 0)
		{
			int damage = 0;

			aDocument.ForceReadAttribute(e, "value", damage);

			aEntityToAddTo.myDamage = int(damage * aDifficultScale);
		}
		if (std::strcmp(CU::ToLower(e->Name()).c_str(), CU::ToLower("damageRadius").c_str()) == 0)
		{
			float radius = 0;
			aDocument.ForceReadAttribute(e, "value", radius);
			aEntityToAddTo.myDamageRadius = radius;
		}
	}
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:26,代码来源:EntityFactory.cpp


示例4: XMLReader

void MainWindow::setFileName(QString fileName){
    XMLReader * xMlReader = new XMLReader(fileName);
    bool ok = true;
    eventList = xMlReader->readFile(&ok);
    if (!ok){
        eventName.clear();
        ui->labelUpper->setText("<font color='red'>Error reading file " + fileName + "</font>" );
        ui->labelMiddle->setText("<font color='red'>Check if the file exists and if the program has read acces</font>");
        ui->labelLower->setText("<font color='red'>The file might also be damaged or contain XML errors</font");
        return;
    }
    if (eventList.length() == 0){
        ui->labelUpper->setText("<font color ='red'>Error: empty or incorrectly formatted XML file " + fileName + ".</font>");
        return;
    }

    QSignalMapper * signalMapper = new QSignalMapper(this);
    connect(signalMapper,SIGNAL(mapped(int)),this,SLOT(setEventSlot(int)));
    for (int i = 0; i < eventList.length();i++){
        actions.append(ui->menuEvents->addAction(eventList.at(i)->getName()));
        actions.at(i)->setCheckable(true);
        signalMapper->setMapping(actions.at(i),i);
        connect(actions.at(i),SIGNAL(triggered()),signalMapper,SLOT(map()));
    }
    currentEventIndex = 0;
    setEvent();
    actions.at(currentEventIndex)->setChecked(true);
    connect(timer,SIGNAL(timeout()),this,SLOT(eventTimerSlot()));

}
开发者ID:TheMassController,项目名称:Countdown_Timer,代码行数:30,代码来源:mainwindow.cpp


示例5:

EMPAction::EMPAction(XMLReader& aReader, tinyxml2::XMLElement* aElement)
{
	aReader.ForceReadAttribute(aReader.ForceFindFirstChild(aElement, "position"), "X", myPosition.x);
	aReader.ForceReadAttribute(aReader.ForceFindFirstChild(aElement, "position"), "Y", myPosition.y);
	aReader.ForceReadAttribute(aReader.ForceFindFirstChild(aElement, "position"), "Z", myPosition.z);
	myPosition *= 10.f;
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:7,代码来源:EMPAction.cpp


示例6:

void
Joystick::load(const XMLReader& root_reader)
{
  std::string cfg_name;
  if (root_reader.read("name", cfg_name) && name == cfg_name)
    {
      // Read calibration data
      if (XMLReader reader = root_reader.get_section("calibration"))
        {
          std::vector<CalibrationData> calibration_data;
          const std::vector<XMLReader>& sections = reader.get_sections();
          for(std::vector<XMLReader>::const_iterator i = sections.begin(); i != sections.end(); ++i)
            {
              CalibrationData data;

              //i->read("axis", );
              //i->read("precision", );
              i->read("invert",     data.invert);
              i->read("center-min", data.center_min);
              i->read("center-max", data.center_max);
              i->read("range-min",  data.range_min);
              i->read("range-max",  data.range_max);

              calibration_data.push_back(data);
            }

          set_calibration(calibration_data);
        }

      { // Read axis mapping
        const std::vector<std::string>& cfg_axis_map = root_reader.get_string_list("axis-map");
        std::vector<int> mapping;
        
        for(std::vector<std::string>::const_iterator i = cfg_axis_map.begin(); i != cfg_axis_map.end(); ++i)
          {
            int type = 0;
            int code = 0;
            str2event(*i, type, code);
            mapping.push_back(code);
          }

        set_axis_mapping(mapping);
      }

      { // Read button mapping
        const std::vector<std::string>& cfg_button_map = root_reader.get_string_list("button-map");
        std::vector<int> mapping;
        
        for(std::vector<std::string>::const_iterator i = cfg_button_map.begin(); i != cfg_button_map.end(); ++i)
          {
            int type = 0;
            int code = 0;
            str2event(*i, type, code);
            mapping.push_back(code);
          }

        set_button_mapping(mapping);
      }
    }
}
开发者ID:dino0815,项目名称:jstest-gtk,代码行数:60,代码来源:joystick.cpp


示例7: XMLReader

 XMLReader* XMLReader::getFileReader(const std::string& file)
 {
   XMLReader* result = new XMLReader() ;
   result->m_reader = xmlReaderForFile(file.c_str(), NULL, 0) ;
   result->processNode() ;
   return result ;
 }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:7,代码来源:xml_reader.cpp


示例8: Restore

void Waypoint::Restore(XMLReader &reader)
{
    // read my Element
    reader.readElement("Waypoint");
    Name = reader.getAttribute("name");
    // get the value of the placement
    EndPos = Base::Placement(Base::Vector3d(reader.getAttributeAsFloat("Px"),
                                            reader.getAttributeAsFloat("Py"),
                                            reader.getAttributeAsFloat("Pz")),
                             Base::Rotation(reader.getAttributeAsFloat("Q0"),
                                            reader.getAttributeAsFloat("Q1"),
                                            reader.getAttributeAsFloat("Q2"),
                                            reader.getAttributeAsFloat("Q3")));

    Velocity     = (float) reader.getAttributeAsFloat("vel");
    Accelaration = (float) reader.getAttributeAsFloat("acc");
    Cont         = (reader.getAttributeAsInteger("cont") != 0)?true:false;
    Tool         = reader.getAttributeAsInteger("tool");
    Base         = reader.getAttributeAsInteger("base");

    std::string type = reader.getAttribute("type");
    if(type=="PTP")
        Type = Waypoint::PTP;
    else if(type=="LIN")
        Type = Waypoint::LINE;
    else if(type=="CIRC")
        Type = Waypoint::CIRC;
    else if(type=="WAIT")
        Type = Waypoint::WAIT;
    else 
        Type = Waypoint::UNDEF;


}
开发者ID:PrLayton,项目名称:SeriousFractal,代码行数:34,代码来源:Waypoint.cpp


示例9:

	Customer::Customer(XMLReader& reader)
	{
		XMLReader customerReader = reader.GetNextElement(CUSTOMER_TAG);
		mName = customerReader.GetAsString(NAME_TAG);
		mAddress = customerReader.GetAsString(ADDRESS_TAG);
		mData = customerReader.GetAsString(DATA_TAG);
	}
开发者ID:bendova,项目名称:MyCode,代码行数:7,代码来源:Customer.cpp


示例10: throw

void
QGAppRegister::load(const char * filename) throw (runtime_error)
{
  //-- Perform previous data cleanup

  delete _parseData;
  for_each(_entryVect.begin(), _entryVect.end(), qstlDeleteObject());

  //-- Parse File

  _parseData = new ParseData();

  // Open input source.
  ifstream stream(filename);  
  InputSource source(stream);

  // Parse input source.
  XMLReader * parser = XMLReaderFactory::createXMLReader();
  parser->setContentHandler(this);
  parser->parse(source);

  // Clean-up.
  delete _parseData;
  _parseData = 0;
  delete parser;  
}
开发者ID:rentpath,项目名称:qgar,代码行数:26,代码来源:QGAppRegister.cpp


示例11: LoadTriggers

void LevelFactory::LoadTriggers(XMLReader& aReader, tinyxml2::XMLElement* aLevelElement)
{
	for (tinyxml2::XMLElement* entityElement = aReader.FindFirstChild(aLevelElement, "trigger"); entityElement != nullptr;
		entityElement = aReader.FindNextElement(entityElement, "trigger"))
	{
		myCurrentLevel->AddTrigger(aReader, entityElement);
	}
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:8,代码来源:LevelFactory.cpp


示例12: Load

	void ParticleSystemData::Load(const std::string& aFilePath)
	{
		myEmitterData.Init(4);
		myOrientations.Init(4);
		myTimeStamps.Init(4);

		XMLReader xmlDoc;
		xmlDoc.OpenDocument(aFilePath);

		XMLElement emitterElement = xmlDoc.FindFirstChild();

		emitterElement = emitterElement->FirstChildElement("Emitter");

		while (emitterElement != nullptr)
		{
			XMLElement dataElement = emitterElement->FirstChildElement("Name");

			std::string emitterName = dataElement->GetText();

			dataElement = emitterElement->FirstChildElement("Time");

			float time;
			dataElement->QueryFloatText(&time);

			dataElement = emitterElement->FirstChildElement("Position");

			Vector3<float> position;

			position.x = dataElement->FloatAttribute("x");
			position.y = dataElement->FloatAttribute("y");
			position.z = dataElement->FloatAttribute("z");

			dataElement = emitterElement->FirstChildElement("Rotation");

			Vector3<float> rotation;

			rotation.x = dataElement->FloatAttribute("x");
			rotation.y = dataElement->FloatAttribute("y");
			rotation.z = dataElement->FloatAttribute("z");

			Matrix44<float> orientation;

			orientation *= Matrix44<float>::CreateRotateAroundX(rotation.x);
			orientation *= Matrix44<float>::CreateRotateAroundY(rotation.y);
			orientation *= Matrix44<float>::CreateRotateAroundZ(rotation.z);

			orientation.SetTranslation(position);

			myEmitterData.Add(emitterName);
			myOrientations.Add(orientation);
			myTimeStamps.Add(time);

			emitterElement = emitterElement->NextSiblingElement("Emitter");
		}
	}
开发者ID:ebithril,项目名称:ModelViewer,代码行数:55,代码来源:ParticleSystemData.cpp


示例13: new

XMLReader*
ReaderMgr::createIntEntReader(  const   XMLCh* const        sysId
                                , const XMLReader::RefFrom  refFrom
                                , const XMLReader::Types    type
                                , const XMLCh* const        dataBuf
                                , const XMLSize_t           dataLen
                                , const bool                copyBuf
                                , const bool                calcSrcOfs
                                ,       XMLSize_t           lowWaterMark)
{
    //
    //  This one is easy, we just create an input stream for the data and
    //  provide a few extra goodies.
    //
    //  NOTE: We use a special encoding string that will be recognized
    //  as a 'do nothing' transcoder for the already internalized XMLCh
    //  data that makes up an internal entity.
    //
    BinMemInputStream* newStream = new (fMemoryManager) BinMemInputStream
                                   (
                                     (const XMLByte*)dataBuf
                                     , dataLen * sizeof(XMLCh)
                                     , copyBuf ? BinMemInputStream::BufOpt_Copy
                                               : BinMemInputStream::BufOpt_Reference
                                     , fMemoryManager
                                   );
    if (!newStream)
        return 0;

    XMLReader* retVal = new (fMemoryManager) XMLReader
    (
        sysId
        , 0
        , newStream
        , XMLRecognizer::XERCES_XMLCH
        , refFrom
        , type
        , XMLReader::Source_Internal
        , false
        , calcSrcOfs
        , lowWaterMark
        , fXMLVersion
        , fMemoryManager
    );

    // If it failed for any reason, then return zero.
    if (!retVal) {
        delete newStream;
        return 0;
    }

    // Set the reader number to the next available number
    retVal->setReaderNum(fNextReaderNum++);
    return retVal;
}
开发者ID:kanbang,项目名称:Colt,代码行数:55,代码来源:ReaderMgr.cpp


示例14: istr

std::string SAXParserTest::parseMemory(XMLReader& reader, int options, const std::string& data)
{
	std::istringstream istr(data);
	std::ostringstream ostr;
	XMLWriter writer(ostr, options);
	reader.setContentHandler(&writer);
	reader.setDTDHandler(&writer);
	reader.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<Poco::XML::LexicalHandler*>(&writer));
	reader.parseMemoryNP(data.data(), data.size());
	return ostr.str();
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:11,代码来源:SAXParserTest.cpp


示例15: LoadProps

void LevelFactory::LoadProps(XMLReader& aReader, tinyxml2::XMLElement* aLevelElement)
{
	for (tinyxml2::XMLElement* entityElement = aReader.FindFirstChild(aLevelElement, "prop"); entityElement != nullptr;
		entityElement = aReader.FindNextElement(entityElement, "prop"))
	{
		Entity* newEntity = new Entity(eEntityType::PROP, *myCurrentLevel->myScene, Prism::eOctreeType::STATIC);
		std::string propType;
		aReader.ForceReadAttribute(entityElement, "propType", propType);
		myCurrentLevel->myEntityFactory->CopyEntity(newEntity, propType);

		newEntity->AddComponent<PropComponent>()->Init("", "");
		FillDataPropOrDefendable(aReader, entityElement, newEntity);
	}
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:14,代码来源:LevelFactory.cpp


示例16: LoadDifficults

void LevelFactory::LoadDifficults()
{
	XMLReader reader;
	reader.OpenDocument("Data/Setting/SET_difficulty.xml");
	tinyxml2::XMLElement* rootElement = reader.ForceFindFirstChild("root");
	int index = 0;
	for (tinyxml2::XMLElement* e = reader.ForceFindFirstChild(rootElement); e != nullptr; e = reader.FindNextElement(e))
	{
		DL_ASSERT_EXP(index < static_cast<int>(eDifficult::_COUNT), "You are trying to add more difficults than there should be.");
		if (std::strcmp(e->Name(), "Difficult") == 0)
		{
			Difficult newDifficult;
			std::string diffType;
			reader.ForceReadAttribute(e, "type", diffType);
			reader.ForceReadAttribute(e, "multiplier", newDifficult.myMultiplier);
			reader.ForceReadAttribute(e, "defendHealthMulitplier", newDifficult.myHealthMultiplier);

			if (diffType == "Easy")
			{
				newDifficult.myType = eDifficult::EASY;
			}
			else if (diffType == "Normal")
			{
				newDifficult.myType = eDifficult::NORMAL;
			}
			else if (diffType == "Hard")
			{
				newDifficult.myType = eDifficult::HARD;
			}

			myDifficults.Insert(index++,newDifficult);
		}
	}
	reader.CloseDocument();
}
开发者ID:nian0601,项目名称:Spaceshooter,代码行数:35,代码来源:LevelFactory.cpp


示例17: HkFMsgEncodeMsg

/** This function is not exported by FLHook so we include it here */
HK_ERROR HkFMsgEncodeMsg(const wstring &wscMessage, char *szBuf, uint iSize, uint &iRet)
{
	XMLReader rdr;
	RenderDisplayList rdl;
	wstring wscMsg = L"<?xml version=\"1.0\" encoding=\"UTF-16\"?><RDL><PUSH/>";
	wscMsg += L"<TRA data=\"0xE6C68400\" mask=\"-1\"/><TEXT>" + XMLText(wscMessage) + L"</TEXT>";
	wscMsg += L"<PARA/><POP/></RDL>\x000A\x000A";
	if(!rdr.read_buffer(rdl, (const char*)wscMsg.c_str(), (uint)wscMsg.length() * 2))
		return HKE_WRONG_XML_SYNTAX;

	BinaryRDLWriter	rdlwrite;
	rdlwrite.write_buffer(rdl, szBuf, iSize, iRet);

	return HKE_OK;
}
开发者ID:HeIIoween,项目名称:FLHook,代码行数:16,代码来源:PluginUtilities.cpp


示例18:

TimeLimitBTDecorator::TimeLimitBTDecorator(XMLReader& fileReader) :

	BTDecoratorNode(fileReader)
{
	m_timeLimit = fileReader.getFloatValueForSubElement(timeLimitConfigAttributeName);
	m_executionTimer = m_timeLimit;
}
开发者ID:vlad-dolhopolov,项目名称:Spajesty,代码行数:7,代码来源:TimeLimitBTDecorator.cpp


示例19: r

int Module_SOW_Car::load(const XMLReader& xmldata)
{
/*    //See comment below
    if (ModuleG2D::load(xmldata) != 0) {
        //Some error happened
        return -1;
    }*/
	//xmldata.getXMLGroupHandle("")->dump();
    //Load from xml
    xmldata.for_all("object", [=](const XMLGroup* g) {
		
		XMLReader r(*g);
		SFG::Pointer<SOW_Car> c(new SOW_Car(this));
		int loadableret = c.cast<Loadable>()->Loadable::load(r);
		
		int gobjret = c.cast<GObjectBase>()->GObjectBase::load(XMLReader(*r.getXMLGroupHandle("GObjectBase/")));
		
		int carret = c->load(XMLReader(*r.getXMLGroupHandle("Car")));
		
		SFG::Util::printLog(SFG::Util::Information, __FILE__, __LINE__,
							"Loading car module has return values %d - %d -%d", loadableret, gobjret, carret);
		
		this->addObject(c);
		
		
	});
    return 0;
}
开发者ID:cwriter,项目名称:SFMLGame,代码行数:28,代码来源:SOW_Car.cpp


示例20: Restore

void Trajectory::Restore(XMLReader &reader)
{
    vpcWaypoints.clear();
    // read my element
    reader.readElement("Trajectory");
    // get the value of my Attribute
    int count = reader.getAttributeAsInteger("count");
    vpcWaypoints.resize(count);

    for (int i = 0; i < count; i++) {
        Waypoint *tmp = new Waypoint();
        tmp->Restore(reader);
        vpcWaypoints[i] = tmp;
    }
    generateTrajectory();
}
开发者ID:KimK,项目名称:FreeCAD,代码行数:16,代码来源:Trajectory.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ XMLRegisterCleanup类代码示例发布时间:2022-05-31
下一篇:
C++ XMLPrinter类代码示例发布时间: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