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


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

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


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

示例1: main

int main()  
{      
	XmlDocument doc("config.xml");
	// 获取connect节点 
	XmlNode connect = doc.firstNode("connect");  

	// 获取全局属性配置
	XmlNode node = connect.firstNode("property");
	printf("global property:\n");
	for (; !node.isNull(); node = node.nextSibling("property"))
	{
		printf("name: %s value: %s\n", node["name"], node["value"]);
	}

	XmlNode pool = connect.firstNode("pool");
	printf("pools:\n");
	for (; !pool.isNull(); pool = pool.nextSibling("pool"))
	{
		printf("pool:\n");
		printf("name: %s\n", pool["name"]);
		node = pool.firstNode("property");
		for (; !node.isNull(); node = node.nextSibling("property"))
		{
			printf("name: %s value: %s\n", node["name"], node["value"]);
		}
	}

	doc.save("config.xml2");

	return EXIT_SUCCESS;  
}  
开发者ID:xuzhixi,项目名称:ops,代码行数:31,代码来源:t_xml3.cpp

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: catch

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

   try {
      XmlAttribute attr = data.firstAttribute();
      if (!attr.isNull() && attr.name() == "dynamic") {
         m_opts.dynamic = attr.getBool();
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "fixedAngle") {
         m_opts.fixedAngle = attr.getBool();
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "density") {
         m_opts.density = attr.getFloat();
         attr = attr.nextAttribute();
      }

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

示例8: 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

示例9: assignData

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

      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 Throwable; ");
      throw;
   }
}
开发者ID:RobJinman,项目名称:minefield,代码行数:22,代码来源:Throwable.cpp

示例10: assignData

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

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

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

示例11: 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

示例12: assignData

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

      XmlNode node = data.nthChild(1);
      if (!node.isNull() && node.name() == "font") {

         XmlAttribute attr = node.firstAttribute();
         if (!attr.isNull() && attr.name() == "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();
      }

      if (!node.isNull() && node.name() == "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,代码行数:39,代码来源:TextEntity.cpp

示例13: catch

bool Test::testCase1() const {
    bool pass = true;
    bool b = false;

    if (m_verbose) cout << "\tCASE 1: Parsing good document and checking tree\n";
    try {
        XmlDocument doc;
        doc.parse("./test1.xml");

        /*
        <?xml version="1.0" encoding="utf-8"?>
        <element1 a="1" b="2">
           <element2 c="3" d="true"/>
           <element3>Hello World!</element3>
           <element4 a="123">
              <element5 yes="no">
                 <element6 str="This is a string" num="4.5"/>
                 <element7>99.8</element7>
              </element5>
           </element4>
        </element1>
        */

        XmlNode node = doc.firstNode();
        node = node.nextSibling();

        SUBCASE_CHECK_CRITICAL(!node.isNull());
        SUBCASE_CHECK(node.name().compare("element1") == 0, pass, b);

        XmlAttribute attr = node.firstAttribute();
        SUBCASE_CHECK_CRITICAL(!attr.isNull());
        SUBCASE_CHECK(attr.name().compare("a") == 0, pass, b);
        SUBCASE_CHECK(attr.getInt() == 1, pass, b);

        attr = attr.nextAttribute();
        SUBCASE_CHECK_CRITICAL(!attr.isNull());
        SUBCASE_CHECK(attr.name().compare("b") == 0, pass, b);
        SUBCASE_CHECK(attr.getInt() == 2, pass, b);

        {
            XmlNode node_ = node.firstChild();
            SUBCASE_CHECK_CRITICAL(!node_.isNull());
            SUBCASE_CHECK(node_.name().compare("element2") == 0, pass, b);

            XmlAttribute attr = node_.firstAttribute();
            SUBCASE_CHECK_CRITICAL(!attr.isNull());
            SUBCASE_CHECK(attr.name().compare("c") == 0, pass, b);
            SUBCASE_CHECK(attr.getInt() == 3, pass, b);

            attr = attr.nextAttribute();
            SUBCASE_CHECK_CRITICAL(!attr.isNull());
            SUBCASE_CHECK(attr.name().compare("d") == 0, pass, b);
            SUBCASE_CHECK(attr.getString().compare("true") == 0, pass, b);

            node_ = node_.nextSibling();
            SUBCASE_CHECK_CRITICAL(!node_.isNull());
            SUBCASE_CHECK(node_.name().compare("element3") == 0, pass, b);
            SUBCASE_CHECK(node_.getString().compare("Hello World!") == 0, pass, b);

            node_ = node_.nextSibling();
            SUBCASE_CHECK_CRITICAL(!node_.isNull());
            SUBCASE_CHECK(node_.name().compare("element4") == 0, pass, b);

            attr = node_.firstAttribute();
            SUBCASE_CHECK_CRITICAL(!attr.isNull());
            SUBCASE_CHECK(attr.name().compare("a") == 0, pass, b);
            SUBCASE_CHECK(attr.getInt() == 123, pass, b);

            {
                XmlNode node__ = node_.firstChild();
                SUBCASE_CHECK_CRITICAL(!node__.isNull());
                SUBCASE_CHECK(node__.name().compare("element5") == 0, pass, b);

                XmlAttribute attr = node__.firstAttribute();
                SUBCASE_CHECK_CRITICAL(!attr.isNull());
                SUBCASE_CHECK(attr.name().compare("yes") == 0, pass, b);
                SUBCASE_CHECK(attr.getString().compare("no") == 0, pass, b);

                {
                    XmlNode node___ = node__.firstChild();
                    SUBCASE_CHECK_CRITICAL(!node___.isNull());
                    SUBCASE_CHECK(node___.name().compare("element6") == 0, pass, b);

                    XmlAttribute attr = node___.firstAttribute();
                    SUBCASE_CHECK_CRITICAL(!attr.isNull());
                    SUBCASE_CHECK(attr.name().compare("str") == 0, pass, b);
                    SUBCASE_CHECK(attr.getString().compare("This is a string") == 0, pass, b);

                    attr = attr.nextAttribute();
                    SUBCASE_CHECK_CRITICAL(!attr.isNull());
                    SUBCASE_CHECK(attr.name().compare("num") == 0, pass, b);
                    SUBCASE_CHECK(attr.getFloat() == 4.5, pass, b);
                }
            }
        }
    }
    catch (XmlException& e) {
        pass = false;
        if (m_verbose) {
            cout << e.what() << "\n";
//.........这里部分代码省略.........
开发者ID:yuang1516,项目名称:dodge,代码行数:101,代码来源:Test.cpp

示例14: XmlException

//===========================================
// Entity::Entity
//===========================================
Entity::Entity(const XmlNode data)
   : Asset(internString("Entity")),
     m_silent(false),
     m_parent(NULL) {

   AssetManager assetManager;
   ShapeFactory shapeFactory;

   try {
      setSilent(true);

      XML_NODE_CHECK(data, Entity);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, type);
      m_type = internString(attr.getString());

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, name);
      m_name = internString(attr.getString());

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, x);
      m_transl.x = attr.getFloat();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, y);
      m_transl.y = attr.getFloat();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, z);
      m_z = attr.getFloat();

      // So that no Z values are 'exactly' equal
      m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, rot);
      float32_t rot = attr.getFloat();

      XmlNode node = data.firstChild();
      if (!node.isNull() && node.name() == "shape") {
         m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
         node = node.nextSibling();
      }

      m_rot = 0;
      setRotation(rot);

      XML_NODE_CHECK(node, scale);
      m_scale = Vec2f(1.f, 1.f);
      setScale(Vec2f(node.firstChild()));

      node = node.nextSibling();
      XML_NODE_CHECK(node, fillColour);
      m_fillColour = Colour(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, lineColour);
      m_lineColour = Colour(node.firstChild());

      node = node.nextSibling();
      XML_NODE_CHECK(node, lineWidth);
      m_lineWidth = node.getInt();

      node = node.nextSibling();
      XML_NODE_CHECK(node, children);
      XmlNode node_ = node.firstChild();
      while (!node_.isNull() && node_.name() == "child") {
         XmlAttribute attr = node_.firstAttribute();

         if (!attr.isNull() && attr.name() == "ptr") {
            long id = attr.getLong();

            pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));

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

            addChild(child);
         }

         node_ = node_.nextSibling();
      }

      setSilent(false);

      ++m_count;
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Entity; ");
      throw;
   }

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

示例15: assignData

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

   AssetManager assetManager;
   ShapeFactory shapeFactory;

   try {
      bool silent = isSilent();
      setSilent(true);

      XmlAttribute attr = data.firstAttribute();
      if (!attr.isNull() && attr.name() == "type") {
         m_type = internString(attr.getString());
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "name") {
         m_name = internString(attr.getString());
         attr = attr.nextAttribute();
      }

      Vec2f transl = m_transl;

      if (!attr.isNull() && attr.name() == "x") {
         transl.x = attr.getFloat();
         attr = attr.nextAttribute();
      }

      if (!attr.isNull() && attr.name() == "y") {
         transl.y = attr.getFloat();
         attr = attr.nextAttribute();
      }

      setTranslation(transl);

      if (!attr.isNull() && attr.name() == "z") {
         m_z = attr.getFloat();

         // So that no Z values are 'exactly' equal
         m_z += 0.1f * static_cast<float32_t>(rand()) / static_cast<float32_t>(RAND_MAX);

         attr = attr.nextAttribute();
      }

      XmlNode node = data.firstChild();
      if (!node.isNull() && node.name() == "shape") {
         m_shape = unique_ptr<Shape>(shapeFactory.create(node.firstChild()));
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "scale") {
         setScale(Vec2f(node.firstChild()));
         node = node.nextSibling();
      }

      if (!attr.isNull() && attr.name() == "rot") {
         setRotation(attr.getFloat());
      }

      if (!node.isNull() && node.name() == "fillColour") {
         m_fillColour = Colour(node.firstChild());
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "lineColour") {
         m_lineColour = Colour(node.firstChild());
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "lineWidth") {
         m_lineWidth = node.getInt();
         node = node.nextSibling();
      }

      if (!node.isNull() && node.name() == "children") {
         XmlNode node_ = node.firstChild();

         while (!node_.isNull() && node_.name() == "child") {
            XmlAttribute attr = node_.firstAttribute();

            if (!attr.isNull() && attr.name() == "ptr") {
               long id = attr.getLong();

               pEntity_t child = boost::dynamic_pointer_cast<Entity>(assetManager.getAssetPointer(id));

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

               addChild(child);
            }

            node_ = node_.nextSibling();
         }
      }

      setSilent(silent);
   }
//.........这里部分代码省略.........
开发者ID:yuang1516,项目名称:dodge,代码行数:101,代码来源:Entity.cpp


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