本文整理汇总了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;
}
示例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();
}
示例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;*/
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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) };
}
示例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();
}
}
示例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();
}
}
示例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");
}
示例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;
}
示例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);
}
}
示例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());
}
}