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


C++ XmlNode::firstChild方法代码示例

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


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

示例1: XmlException

//===========================================
// PauseMenu::PauseMenu
//===========================================
PauseMenu::PauseMenu(const XmlNode data)
   : Asset(internString("PauseMenu")),
     Entity(data.firstChild().firstChild().firstChild()),
     Menu(data.firstChild()) {

   try {
      AssetManager assetManager;

      XML_NODE_CHECK(data, PauseMenu);

      XmlNode node = data.nthChild(1);
      XML_NODE_CHECK(node, flare);

      XmlAttribute attr = node.firstAttribute();
      XML_ATTR_CHECK(attr, ptr);
      long id = attr.getLong();

      m_flare = boost::dynamic_pointer_cast<CSprite>(assetManager.getAssetPointer(id));

      if (!m_flare)
         throw XmlException("Bad asset id for flare item", __FILE__, __LINE__);

      m_flare->addToWorld();
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class PauseMenu; ");
      throw;
   }
}
开发者ID:RobJinman,项目名称:minefield,代码行数:32,代码来源:PauseMenu.cpp

示例2: XmlException

//===========================================
// CreditsMenu::CreditsMenu
//===========================================
CreditsMenu::CreditsMenu(const XmlNode data)
   : Asset(internString("CreditsMenu")),
     Entity(data.firstChild().firstChild().firstChild()),
     Menu(data.firstChild()) {

   try {
      AssetManager assetManager;

      XML_NODE_CHECK(data, CreditsMenu);

      XmlNode node = data.nthChild(1);
      XML_NODE_CHECK(node, font);

      XmlAttribute attr = node.firstAttribute();
      XML_ATTR_CHECK(attr, ptr);

      long id = attr.getLong();
      m_font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(id));

      if (!m_font)
         throw XmlException("Bad font asset id", __FILE__, __LINE__);

      node = node.nextSibling();
      XML_NODE_CHECK(node, fadeInTime);
      m_fadeInTime = node.getFloat();
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class CreditsMenu; ");
      throw;
   }

   init();
}
开发者ID:RobJinman,项目名称:minefield,代码行数:36,代码来源:CreditsMenu.cpp

示例3: PhysicalSprite

      //===========================================
      // PhysicalSprite::PhysicalSprite
      //===========================================
      explicit PhysicalSprite(const XmlNode data)
         : Asset(internString("PhysicalSprite")),
           Entity(data.firstChild().firstChild()),
           Sprite(data.firstChild()),
           T_PHYSICS(this, data.nthChild(1)) {

         XML_NODE_CHECK(data, PhysicalSprite);
      }
开发者ID:yuang1516,项目名称:dodge,代码行数:11,代码来源:PhysicalSprite.hpp

示例4: Asset

//===========================================
// Soil::Soil
//===========================================
Soil::Soil(const XmlNode data)
    : Asset(internString("Soil")),
      Entity(data.firstChild().firstChild()),
      Item(data.firstChild()),
      Sprite(data.nthChild(1)) {

    try {
        XML_NODE_CHECK(data, Soil);
    }
    catch (XmlException& e) {
        e.prepend("Error parsing XML for instance of class Soil; ");
        throw;
    }

    init();
}
开发者ID:RobJinman,项目名称:minefield,代码行数:19,代码来源:Soil.cpp

示例5: Asset

//===========================================
// Polygon::Polygon
//===========================================
Polygon::Polygon(const XmlNode data)
   : Asset(internString("Polygon")),
     m_outlineModel(Renderer::LINES),
     m_interiorModel(Renderer::TRIANGLES),
     m_renderer(Renderer::getInstance()) {

   try {
      XML_NODE_CHECK(data, Polygon);

      clear();

      XmlNode node = data.firstChild();
      while (!node.isNull() && node.name() == "Vec2f") {
         boost::shared_ptr<Vec2f> vert(new Vec2f(node));
         m_verts.push_back(vert);

         ++m_nVerts;
         node = node.nextSibling();
      }
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Polygon; ");
      throw;
   }

   restructure();
   updateModels();
}
开发者ID:yuang1516,项目名称:dodge,代码行数:31,代码来源:Polygon.cpp

示例6: assignData

//===========================================
// Sprite::assignData
//
// All tags and attributes are optional.
//===========================================
void Sprite::assignData(const XmlNode data) {
   if (data.isNull() || data.name() != "Sprite") return;

   try {
      XmlNode node = data.firstChild();

      if (!node.isNull() && node.name() == "Entity") {
         Entity::assignData(node);
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "EntityAnimations") {
         EntityAnimations::assignData(node);
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "EntityTransformations") {
         EntityTransformations::assignData(node);
      }
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Sprite; ");
      throw;
   }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:30,代码来源:Sprite.cpp

示例7: frame

//===========================================
// Animation::Animation
//===========================================
Animation::Animation(const XmlNode data)
   : Asset(internString("Animation")),
     m_state(STOPPED),
     m_frameReady(false) {

   try {
      XML_NODE_CHECK(data, Animation);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, name);
      m_name = internString(attr.getString());

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, duration);
      m_duration = attr.getFloat();

      uint_t f = 0;
      XmlNode node = data.firstChild();
      while (!node.isNull() && node.name() == "AnimFrame") {
         AnimFrame frame(node);
         frame.number = f;

         m_frames.push_back(frame);

         ++f;
         node = node.nextSibling();
      }
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Animation; ");
      throw;
   }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:36,代码来源:Animation.cpp

示例8: assignData

//===========================================
// EntityParallax::assignData
//===========================================
void EntityParallax::assignData(const XmlNode data) {
    try {
        if (data.isNull() || data.name() != "EntityParallax") return;

        XmlNode node = data.firstChild();
        if (!node.isNull() && node.name() == "range") {
            m_range = Vec2f(node.firstChild());
        }
    }
    catch (XmlException& e) {
        e.prepend("Error parsing XML for instance of class EntityParallax; ");
        throw;
    }

    init();
}
开发者ID:yuang1516,项目名称:dodge,代码行数:19,代码来源:EntityParallax.cpp

示例9: parseGameModes

//===========================================
// GameSettings::parseGameModes
//===========================================
void GameSettings::parseGameModes(XmlNode data) {
   XmlNode node = data.firstChild();

   while (!node.isNull() && node.name() == "GameOptions") {
      difficultyModes.push_back(pGameOptions_t(new GameOptions(node)));
      node = node.nextSibling();
   }
}
开发者ID:RobJinman,项目名称:minefield,代码行数:11,代码来源:GameSettings.cpp

示例10: catch

//===========================================
// EntityParallax::EntityParallax
//===========================================
EntityParallax::EntityParallax(Entity* entity, const XmlNode data)
    : m_entity(entity) {

    try {
        XML_NODE_CHECK(data, EntityParallax);

        XmlNode node = data.firstChild();
        XML_NODE_CHECK(node, range);
        m_range = Vec2f(node.firstChild());
    }
    catch (XmlException& e) {
        e.prepend("Error parsing XML for instance of class EntityParallax; ");
        throw;
    }

    init();
}
开发者ID:yuang1516,项目名称:dodge,代码行数:20,代码来源:EntityParallax.cpp

示例11: setMapSettings

//===========================================
// Application::setMapSettings
//===========================================
void Application::setMapSettings(const XmlNode data) {
   try {
      XML_NODE_CHECK(data, customSettings);

      XmlNode node = data.firstChild();
      XML_NODE_CHECK(node, bgColour);
      m_bgColour = Colour(node.firstChild());

      const Range& mb = m_mapLoader.getMapBoundary();
      Range boundary(mb.getPosition() - Vec2f(0.1, 0.1), mb.getSize() + Vec2f(0.2, 0.2));
      m_worldSpace.init(unique_ptr<Quadtree<pEntity_t> >(new Quadtree<pEntity_t>(1, boundary)));
   }
   catch (XmlException& e) {
      e.prepend("Error loading map settings; ");
      throw;
   }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:20,代码来源:Application.cpp

示例12: assignData

      //===========================================
      // PhysicalSprite::assignData
      //===========================================
      virtual void assignData(const XmlNode data) {
         if (data.isNull() || data.name() != "PhysicalSprite") return;

         XmlNode node = data.firstChild();

         if (!node.isNull() && node.name() == "Sprite") {
            Sprite::assignData(node);
            node = node.nextSibling();
         }

         if (!node.isNull() && node.name() == "EntityPhysics") {
            T_PHYSICS::assignData(data.nthChild(1));
         }
      }
开发者ID:yuang1516,项目名称:dodge,代码行数:17,代码来源:PhysicalSprite.hpp

示例13: assignData

//===========================================
// PauseMenu::assignData
//===========================================
void PauseMenu::assignData(const XmlNode data) {
   try {
      XML_NODE_CHECK(data, PauseMenu)

      XmlNode node = data.firstChild();
      if (!node.isNull() && node.name() == "Menu") {
         Menu::assignData(node);
      }
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class PauseMenu; ");
      throw;
   }
}
开发者ID:RobJinman,项目名称:minefield,代码行数:17,代码来源:PauseMenu.cpp

示例14: XmlException

//===========================================
// TextEntity::TextEntity
//===========================================
TextEntity::TextEntity(const XmlNode data)
   : Asset(internString("TextEntity")),
     Entity(data.firstChild()),
     m_renderer(Renderer::getInstance()),
     m_model(Renderer::TRIANGLES) {

   try {
      XML_NODE_CHECK(data, TextEntity);

      XmlNode node = data.nthChild(1);
      XML_NODE_CHECK(node, font);

      XmlAttribute attr = node.firstAttribute();
      XML_ATTR_CHECK(attr, ptr);
      long fontId = attr.getLong();

      AssetManager assetManager;
      pFont_t font = boost::dynamic_pointer_cast<Dodge::Font>(assetManager.getAssetPointer(fontId));

      if (!font)
         throw XmlException("Bad asset id", __FILE__, __LINE__);

      m_font = font;

      node = node.nextSibling();
      XML_NODE_CHECK(node, textSize);
      m_size = Vec2f(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, text);
      setText(node.getString());
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class TextEntity; ");
      throw;
   }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:40,代码来源:TextEntity.cpp

示例15: assignData

//===========================================
// Soil::assignData
//===========================================
void Soil::assignData(const XmlNode data) {
    try {
        XML_NODE_CHECK(data, Soil)

        XmlNode node = data.firstChild();
        if (!node.isNull() && node.name() == "Item") {
            Item::assignData(node);
            node = node.nextSibling();
        }

        if (!node.isNull() && node.name() == "Sprite") {
            Sprite::assignData(node);
        }
    }
    catch (XmlException& e) {
        e.prepend("Error parsing XML for instance of class Soil; ");
        throw;
    }
}
开发者ID:RobJinman,项目名称:minefield,代码行数:22,代码来源:Soil.cpp


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