当前位置: 首页>>代码示例>>C++>>正文


C++ XMLElement::FirstChildElement方法代码示例

本文整理汇总了C++中tinyxml2::XMLElement::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::FirstChildElement方法的具体用法?C++ XMLElement::FirstChildElement怎么用?C++ XMLElement::FirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tinyxml2::XMLElement的用法示例。


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

示例1: ReadAttributedObject

/**
 * Reads the attributed object id, comments, and artifacts.
 */
bool Translator::ReadAttributedObject( AttributedObject& aobj, 
		Context& ctxt, const tinyxml2::XMLElement & elem, bool bIdAttributeRequired )
{
	//Grab the ID.
	pcstr szid = elem.Attribute("id");
	if( szid == NULL)
	{
		if( bIdAttributeRequired )
			throw GnssMetadata::TranslationException( "Required id attribute not defined.");
	}
	else
		aobj.Id(szid);

	//Parse the comments.
	const XMLElement* pelem = elem.FirstChildElement("comment");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("comment"))
	{
		const char* szFmt = pelem->Attribute("format");
		Comment::CommentFormat fmt = (strcmp(szFmt, "text") == 0)
			? Comment::text : Comment::html;
		Comment comment( pelem->GetText(), fmt);
		aobj.Comments().push_back( comment);
	}

	//Parse the Artifacts.
	pelem = elem.FirstChildElement("artifact");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("artifact"))
	{
		AnyUri auri( pelem->GetText());
		aobj.Artifacts().push_back( auri);
	}

	return true;
}
开发者ID:mbmathews,项目名称:metadata,代码行数:37,代码来源:Translator.cpp

示例2: decodeXML

void Elevator::decodeXML(tinyxml2::XMLElement & xml)
{
	clearCars();
	Item::decodeXML(xml);
	size.y = xml.IntAttribute("height");
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("unserviced"); e; e = e->NextSiblingElement("unserviced")) {
		unservicedFloors.insert(e->IntAttribute("floor"));
	}
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("car"); e; e = e->NextSiblingElement("car")) {
		Car * car = new Car(this);
		car->decodeXML(*e);
		cars.insert(car);
	}
	updateSprite();
}
开发者ID:Hmaal,项目名称:OpenSkyscraper,代码行数:15,代码来源:Elevator.cpp

示例3: SetFrameEvent

	void Animation2D::Read(const tinyxml2::XMLElement& el_ )
	{
		Animation::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		//float totalTime = 0.0f;

		while (pElemFrame != nullptr)
		{
			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->Read(const_cast<tinyxml2::XMLElement *>(pElemFrame));
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();

			/*unsigned int spriteID;
			pElemFrame->QueryUnsignedAttribute("spriteID", &spriteID);
			float time;
			pElemFrame->QueryFloatAttribute("time", &time);

			std::ostringstream str;
			str << spriteID;

			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->FrameID(str.str().c_str());
			pFrameEvent->Time(time + totalTime);
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();
			totalTime += time;*/
		}
	}
开发者ID:xcasadio,项目名称:casaengine,代码行数:33,代码来源:Animation2D.cpp

示例4: cf

bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
    if (strcmp(element.Name(), "favorite") == 0)
    {
        std::string id = Util::GetXmlFirstChildElementText(&element, "id");
        std::string name = Util::GetXmlFirstChildElementText(&element, "name");

        //channels
        ChannelFavorite::favorite_channel_list_t channels;
        const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
        if (channels_element != NULL)
        {
            const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
            while (channel_element != NULL)
            {
                if (strcmp(channel_element->Name(), "channel") == 0)
                {
                    if (channel_element->GetText() != NULL)
                        channels.push_back(channel_element->GetText());
                }
                channel_element = channel_element->NextSiblingElement();
            }

        }

        ChannelFavorite cf(id, name, channels);

        m_favoritesList.favorites_.push_back(cf);

        return false;
    }

    return true;
}
开发者ID:MrMC,项目名称:pvr.dvblink,代码行数:34,代码来源:favorites.cpp

示例5: getValue

inline bool getValue(const tinyxml2::XMLElement& elt, Microseconds& microseconds) {
    uint64_t count;
    auto pChildElement = elt.FirstChildElement("Microseconds");
    if(pChildElement && getValue(*pChildElement, count)) {
        microseconds = Microseconds { count };
        return true;
    }
    return false;
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:9,代码来源:parsing.hpp

示例6:

void Box2D::Read(const tinyxml2::XMLElement& pEl_)
{
	//TODO


	const tinyxml2::XMLElement* pLocation_ = pEl_.FirstChildElement("Location");
	pLocation_->QueryFloatAttribute("x", &m_Center.x);
	pLocation_->QueryFloatAttribute("y", &m_Center.y);
	m_Center /= 100.0f; // TODO : to remove only for testing purpose
	//m_Center.x = -m_Center.x;
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:11,代码来源:Box2D.cpp

示例7: Read

	void Animation::Read(const tinyxml2::XMLElement& el_)
	{
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		while (pElemFrame != nullptr)
		{
			//get type event
			//EventFactory.Read()
			// 
			pElemFrame = pElemFrame->NextSiblingElement();
		}
	}
开发者ID:xcasadio,项目名称:casaengine,代码行数:14,代码来源:Animation.cpp

示例8: strcmp

bool	CStacksmithXMLPrinter::CompactMode( const tinyxml2::XMLElement& elem )
{
	if( strcmp(elem.Name(),"text") == 0 || strcmp(elem.Name(),"script") == 0 || strcmp(elem.Name(),"td") == 0
		|| strcmp(elem.Name(),"body") == 0 )	// For htmlText property.
		return true;
	const tinyxml2::XMLElement*	firstElem = elem.FirstChildElement();
	const tinyxml2::XMLNode*	firstChild = elem.FirstChild();
	if( firstChild && firstElem && firstChild == elem.LastChild() && firstElem == firstChild	// Exactly one child, and it's an element?
		&& firstElem->FirstChild() == NULL )	// And this element has no children? I.e. is self-closing?
	{
		return true;
	}
	
	return false;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例9: loadDirectionalLight

DirectionalLight loadDirectionalLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pExitantPower = elt.FirstChildElement("ExitantPower");
    if(pExitantPower) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(elt, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(elt, "ExitantPower", exitantPower);

        return DirectionalLight(wi, exitantPower, scene);
    }

    return { normalize(loadVector(elt)), loadColor(elt) };
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:15,代码来源:parsing.cpp

示例10: Read

	void Sprite::Read( const tinyxml2::XMLElement& el_ )
	{
		Clear();
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElem, *pChild;

		m_AssetFileName = el_.FirstChildElement("AssetFileName")->GetText();
		//m_Name = el_->Attribute("name");
		//m_Name = el_->Attribute("id");
		SetName(el_.Attribute("id")); // TODO : ID is not the name

		m_pTexture2D = Texture::loadTexture(m_AssetFileName.c_str());

		pElem = el_.FirstChildElement("PositionInTexture");
		int x, y, w, h;
		pElem->QueryIntAttribute("x", &x);
		pElem->QueryIntAttribute("y", &y);
		pElem->QueryIntAttribute("width", &w);
		pElem->QueryIntAttribute("height", &h);
		m_PositionInTexture.Set(x, y, w, h);

		pElem = el_.FirstChildElement("HotSpot");
		pElem->QueryIntAttribute("x", &m_Origin.x);
		pElem->QueryIntAttribute("y", &m_Origin.y);

		pElem = el_.FirstChildElement("CollisionList");
		pChild = pElem->FirstChildElement("Shape");

		while (pChild != nullptr)
		{
			IShape *pShape = IShape::LoadShape(*pChild);
			m_CollisionShapes.push_back(pShape);
			pChild = pChild->NextSiblingElement();
		}
	}
开发者ID:xcasadio,项目名称:casaengine,代码行数:36,代码来源:Sprite.cpp

示例11: Read

void Polygon::Read(const tinyxml2::XMLElement& pEl_)
{
	const tinyxml2::XMLElement* pPointList_ = pEl_.FirstChildElement("PointList");
	const tinyxml2::XMLElement *pPoint;

	pPoint = pPointList_->FirstChildElement("Point");
	m_PointList.clear();

	while (pPoint != nullptr)
	{
		Vector2F point;
		pPoint->QueryFloatAttribute("x", &point.x);
		pPoint->QueryFloatAttribute("y", &point.y);
		m_PointList.push_back(point);
		pPoint = pPoint->NextSiblingElement();
	}
}
开发者ID:xcasadio,项目名称:casaengine,代码行数:17,代码来源:Polygon.cpp

示例12: loadEnvironmentLight

EnvironmentLight loadEnvironmentLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pBuildFromDirection = elt.FirstChildElement("BuildFromDirection");
    if(pBuildFromDirection) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(*pBuildFromDirection, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(*pBuildFromDirection, "ExitantPower", exitantPower);
        Vec2u resolution = Vec2u(1, 1);
        getChildAttribute(*pBuildFromDirection, "Resolution", resolution);

        return EnvironmentLight(resolution, wi, exitantPower, scene);
    }

    throw std::runtime_error("Unable to load EnvironmentLight");
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:17,代码来源:parsing.cpp

示例13: while

aggregate_view_info
view_info_builder::build(const tinyxml2::XMLElement &element,
                         const mfast::group_field_instruction *inst) {
  const char *name = get_optional_attr(element, "name", nullptr);

  if (name == nullptr)
    BOOST_THROW_EXCEPTION(
        fast_static_error("A view must has a name attribute"));

  this->visit(inst, nullptr);
  aggregate_view_info result;
  result.max_depth_ = 0;
  std::size_t sz = std::strlen(name) + 1;
  result.name_ = reinterpret_cast<const char *>(
      std::memcpy(new (alloc_) char[sz], name, sz));

  // result.name_ = std::strcpy(new (alloc_) char[std::strlen(name) + 1],
  //                            name);

  std::deque<field_view_info> fields;

  const tinyxml2::XMLElement *child = element.FirstChildElement();
  while (child != nullptr) {
    if (std::strcmp(child->Name(), "field") == 0) {
      const tinyxml2::XMLElement *grandchild = child->FirstChildElement();
      while (grandchild != nullptr) {
        build_field_view(*grandchild, result.max_depth_, fields);
        grandchild = grandchild->NextSiblingElement();
      }

      fields.back().prop &= ~field_view_info::CONTINUE_BIT;
    }
    child = child->NextSiblingElement();
  }
  field_view_info terminator = {0, nullptr};
  fields.push_back(terminator);

  auto data = new (alloc_) field_view_info[fields.size()];
  std::copy(fields.begin(), fields.end(), data);
  result.data_ = mfast::array_view<const field_view_info>(data, fields.size());
  result.instruction_ = inst;
  return result;
}
开发者ID:dendisuhubdy,项目名称:matching-engine,代码行数:43,代码来源:view_info_builder.cpp

示例14: ParseTinyXmlElement

		void XML::ParseTinyXmlElement(const tinyxml2::XMLElement& element)
		{
			//Parse this
			const char* text = element.GetText();
			if(text)
				m_data = text;

			//Parse attributes
			for(const tinyxml2::XMLAttribute* attribute = element.FirstAttribute(); attribute; attribute = attribute->Next())
			{
				m_attributes.insert(std::make_pair(string::ToLower(attribute->Name()), std::string(attribute->Value())));
			}

			//Parse children
			for(const tinyxml2::XMLElement* childElement = element.FirstChildElement(); childElement; childElement = childElement->NextSiblingElement())
			{
				XML* childNode = AddChild(childElement->Name());
				childNode->ParseTinyXmlElement(*childElement);
			}
		}
开发者ID:BigEvilCorporation,项目名称:ion-engine,代码行数:20,代码来源:XML.cpp

示例15: ReadFirstElement

size_t Translator::ReadFirstElement( const char* pszelem, 
		const tinyxml2::XMLElement& container, 
		bool bRequired,  size_t iDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return iDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required unsigned integer element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return atol( pchild->GetText());
	}
}
开发者ID:tompano33,项目名称:GNSSReader,代码行数:21,代码来源:Translator.cpp


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