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

C++ XmlAttribute类代码示例

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

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



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

示例1: SetAttribute

void XmlElement::SetAttribute( const char * cname, const char * cvalue )
{
	XmlAttribute* attrib = attributeSet.FindOrCreate( cname );
	if ( attrib ) {
		attrib->SetValue( cvalue );
	}
}
开发者ID:oksangman,项目名称:Ant,代码行数:7,代码来源:tinyxml.cpp


示例2: Asset

//===========================================
// 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


示例3: Asset

//===========================================
// 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


示例4: SetDoubleAttribute

void XmlElement::SetDoubleAttribute( const std::string& name, double val )
{	
	XmlAttribute* attrib = attributeSet.FindOrCreate( name );
	if ( attrib ) {
		attrib->SetDoubleValue( val );
	}
}
开发者ID:oksangman,项目名称:Ant,代码行数:7,代码来源:tinyxml.cpp


示例5: SetNodeAttribute

bool CXmlDocument::SetNodeAttribute(const CXmlNode& node, const CString& attributeName, const CString& value)
{
	if(node.GetNode() == NULL)
		return FALSE;

	XmlAttribute pAttr;
	HRESULT hr = m_pDoc->createAttribute((_bstr_t)attributeName, &pAttr);
	if ( FAILED(hr) )
		return FALSE;

	hr = pAttr->put_text((_bstr_t)value);
	if( FAILED(hr) )
		return FALSE;

	XmlMap pNodeMap;
	hr = node.GetNode()->get_attributes(&pNodeMap);
	if ( FAILED(hr) )
		return FALSE;

	XmlNode pNamedItem;
	hr = pNodeMap->setNamedItem(pAttr, &pNamedItem);
	if ( FAILED(hr) )
		return FALSE;

	return TRUE;
}
开发者ID:firememory,项目名称:BuddyDesk,代码行数:26,代码来源:Util_XMLDOM.cpp


示例6: Asset

//===========================================
// 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


示例7: testEmpty

void XmlAttributeUnitTests::testEmpty()
{
	XmlAttribute attr;
	CPPUNIT_ASSERT(attr.GetValue().empty());
	CPPUNIT_ASSERT(false == attr.GetBoolValue(false));
	CPPUNIT_ASSERT(true == attr.GetBoolValue(true));
}
开发者ID:AllanDragoon,项目名称:dotnetinstaller,代码行数:7,代码来源:XmlAttributeUnitTests.cpp


示例8: assert

void XmlSchema::addSimpleVector(const XmlNode* child, String& structDefinition, size_t typeWidth,
								 String& readingFunction, String& writingFunction) const
{
	assert(child != NULL);
	XmlAttribute* type = child->findAttribute(ATTR_TYPE);
	if (type == NULL)
	{
		return;
	}
	
	String typeString = T("std::vector<");
	typeString += getSimpleTypeString(type);
	typeString += T(">");

	size_t thisWidth = typeString.size();
	assert(thisWidth < typeWidth + 1);
	for (size_t i = 0; i < typeWidth + 1 - thisWidth; ++i)
	{
		typeString += T(" ");
	}
	structDefinition += T("	");
	structDefinition += typeString;
	structDefinition += getPluralName(child->getName());
	structDefinition += T(";\r\n");	

	readingFunction += T("\r\n	childNode = node->findFirstChild(");
	readingFunction += LEFT_QUOTE;
	readingFunction += child->getName();
	readingFunction += T("\", iter);\r\n	while (childNode != NULL)\r\n	{\r\n		");
	readingFunction += getPluralName(child->getName());
	readingFunction += T(".resize(");
	readingFunction += getPluralName(child->getName());
	readingFunction += T(".size() + 1);\r\n		");
	readingFunction += getPluralName(child->getName());
	readingFunction += T(".back() = childNode->get");
	String typeName = type->getString();
	typeName[0] -= 32;
	readingFunction += typeName;
	readingFunction += T("();\r\n		childNode = node->findNextChild(");
	readingFunction += LEFT_QUOTE;
	readingFunction += child->getName();
	readingFunction += T("\", iter);\r\n	}\r\n");

	writingFunction += T("\r\n	for (std::vector<");
	writingFunction += getSimpleTypeString(type);
	writingFunction += T(">::const_iterator iter = ");
	writingFunction += getPluralName(child->getName());
	writingFunction += T(".begin();\r\n		  iter != ");
	writingFunction += getPluralName(child->getName());
	writingFunction += T(".end();\r\n		  ++iter)\r\n	{\r\n		const ");
	writingFunction += getSimpleTypeString(type);
	writingFunction += T("& value = *iter;\r\n");
	writingFunction += T("		childNode = node->addChild(");
	writingFunction += LEFT_QUOTE;
	writingFunction += child->getName();
	writingFunction += T("\");\r\n		childNode->set");
	writingFunction += typeName;
	writingFunction += T("(value);\r\n	}\r\n");
}
开发者ID:wzAdmin,项目名称:Graph,代码行数:59,代码来源:XmlSchema.cpp


示例9: Find

XmlAttribute *XmlElement::XmlAttributeSet::FindOrCreate(const String &sName)
{
	XmlAttribute *pAttribute = Find(sName);
	if (!pAttribute) {
		pAttribute = new XmlAttribute();
		Add(*pAttribute);
		pAttribute->SetName(sName);
	}
	return pAttribute;
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:10,代码来源:XmlElement.cpp


示例10: Find

XmlAttribute* XmlAttributeSet::FindOrCreate( const char* _name )
{
	XmlAttribute* attrib = Find( _name );
	if ( !attrib ) {
		attrib = new XmlAttribute();
		Add( attrib );
		attrib->SetName( _name );
	}
	return attrib;
}
开发者ID:oksangman,项目名称:Ant,代码行数:10,代码来源:tinyxml.cpp


示例11: XML_NODE_CHECK

//===========================================
// Item::Item
//===========================================
Item::Item(const XmlNode data) {
    try {
        XML_NODE_CHECK(data, Item);

        XmlAttribute attr = data.firstAttribute();
        XML_ATTR_CHECK(attr, solid);
        m_solid = attr.getBool();
    }
    catch (XmlException& e) {
        e.prepend("Error parsing XML for instance of class Item; ");
        throw;
    }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:16,代码来源:Item.cpp


示例12: EntityPhysics

//===========================================
// Box2dPhysics::Box2dPhysics
//===========================================
Box2dPhysics::Box2dPhysics(Entity* entity, const XmlNode data)
   : EntityPhysics(entity, data),
     m_init(false),
     m_entity(entity),
     m_body(NULL),
     m_opts(false, false, 1.f, 0.3f) {

   init();

   try {
      XML_NODE_CHECK(data, Box2dPhysics);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, dynamic);
      m_opts.dynamic = attr.getBool();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, fixedAngle);
      m_opts.fixedAngle = attr.getBool();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, density);
      m_opts.density = attr.getFloat();

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


示例13: XML_NODE_CHECK

//===========================================
// Vec2i::Vec2i
//===========================================
Vec2i::Vec2i(const XmlNode data) {
   try {
      XML_NODE_CHECK(data, Vec2i);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, x);
      x = attr.getInt();

      attr = attr.nextAttribute();
      XML_ATTR_CHECK(attr, y);
      y = attr.getInt();
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class Vec2i; ");
      throw;
   }
}
开发者ID:yuang1516,项目名称:dodge,代码行数:20,代码来源:Vec2i.cpp


示例14: getNodeMemberTypeWidth

size_t XmlSchema::getNodeMemberTypeWidth(const XmlNode* node) const
{
	size_t maxWidth = 0;
	size_t width = 0;
	NodeIterator iter;
	for (const XmlNode* child = node->getFirstChild(iter);
		child != NULL;
		child = node->getNextChild(iter))
	{
		XmlAttribute* multiple = child->findAttribute(ATTR_MULTIPLE);

		if (child->isEmpty())
		{
			//simple type
			XmlAttribute* type = child->findAttribute(ATTR_TYPE);
			if (type == NULL)
			{
				continue;
			}
			width = getSimpleTypeString(type).size();
			if (multiple != NULL && multiple->getBool())
			{
				width += Strlen(T("std::vector<>"));
			}
		}
		else
		{
			//struct type
			width = Strlen(child->getName());
			if (multiple != NULL && multiple->getBool())
			{
				width += Strlen(T("std::vector<>"));
			}
		}
		if (width > maxWidth)
		{
			maxWidth = width;
		}
	}
	return maxWidth;
}
开发者ID:wzAdmin,项目名称:Graph,代码行数:41,代码来源:XmlSchema.cpp


示例15: _readNodeCallback

bool LibreOfficeInspector::_readNodeCallback(XmlNode node, void *data)
{
	vector <XmlAttribute>* attributes;
	bool bIsItem;

	if (g_parsing_state == PropUILocale && node.GetName().compare(L"value")==0)
	{		
		wstring* lang_found = (wstring *) data;
		*lang_found = node.GetText();
		g_parsing_state = ItemOther;
		return false;
	}

	bIsItem = node.GetName().compare(L"item") == 0;

	if (bIsItem && g_parsing_state != ItemOther)
	{
		g_parsing_state = ItemOther;
	}	

	attributes = node.GetAttributes();
	for (unsigned int i = 0; i < attributes->size(); i++)
	{
		XmlAttribute attribute;

		attribute = attributes->at(i);

		if (g_parsing_state == ItemOther && bIsItem && attribute.GetName() == L"oor:path" && attribute.GetValue() == L"/org.openoffice.Office.Linguistic/General")
		{
			g_parsing_state = ItemLinguisticGeneral;			
		}

		if (g_parsing_state == ItemLinguisticGeneral && attribute.GetName() == L"oor:name" && attribute.GetValue() == L"UILocale")
		{
			g_parsing_state = PropUILocale;
		}		
	}
	
	return true;
}
开发者ID:NoAntzWk,项目名称:CatalanitzadorPerAWindows,代码行数:40,代码来源:LibreOfficeInspector.cpp


示例16: OnParse

//[-------------------------------------------------------]
//[ Protected virtual XmlTextElement functions            ]
//[-------------------------------------------------------]
void XmlTextImage::OnParse(XmlNode &cXmlNode)
{
	// Is this an XML element?
	if (cXmlNode.GetType() == XmlNode::Element) {
		// Destroy the previous image
		if (m_pImage) {
			delete m_pImage;
			m_pImage = nullptr;
		}

		// Get XML element
		XmlElement &cXmlElement = static_cast<XmlElement&>(cXmlNode);

		// Parse attributes
		XmlAttribute *pAttribute = cXmlElement.GetFirstAttribute();
		while (pAttribute) {
			// Get name and value
			String sName  = pAttribute->GetName();
			String sValue = pAttribute->GetValue();

			// Save attribute
			if (sName.CompareNoCase("Src")) {
				// Image filename
				m_sFilename = sValue;
			} else if (sName.CompareNoCase("Width")) {
				// Image width
				m_vSize.x = sValue.GetInt();
			} if (sName.CompareNoCase("Height")) {
				// Image height
				m_vSize.y = sValue.GetInt();
			}

			// Next attribute
			pAttribute = pAttribute->GetNext();
		}

	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:41,代码来源:XmlTextImage.cpp


示例17: Asset

//===========================================
// 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


示例18: Asset

//===========================================
// MusicTrack::MusicTrack
//===========================================
MusicTrack::MusicTrack(const XmlNode data)
   : Asset(internString("MusicTrack")) {

   string path;

   try {
      XML_NODE_CHECK(data, MusicTrack);

      XmlAttribute attr = data.firstAttribute();
      XML_ATTR_CHECK(attr, path);

      stringstream ss;
      ss << gGetWorkingDir() << "/" << attr.getString();

      path = ss.str();
   }
   catch (XmlException& e) {
      e.prepend("Error parsing XML for instance of class MusicTrack; ");
      throw;
   }

   Audio audio;
   audio.newMusicTrack(this, path);
}
开发者ID:yuang1516,项目名称:dodge,代码行数:27,代码来源:MusicTrack.cpp


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


示例20: addConstructorItem

void XmlSchema::addConstructorItem(const XmlNode* child, String& structDefinition, int& index) const
{
	XmlAttribute* type = child->findAttribute(ATTR_TYPE);
	bool recursive = (child->findAttribute(ATTR_RECURSIVE) != NULL);
	if (type == NULL && !recursive)
	{
		return;
	}
	XmlAttribute* multiple = child->findAttribute(ATTR_MULTIPLE);
	if (multiple != NULL && multiple->getBool())
	{
		//don't need to construct a vector member
		return;
	}
	XmlAttribute* defaultAttribute = child->findAttribute(ATTR_DEFAULT);
	if (type != NULL
		&& Strcmp(type->getString(), T("string")) == 0
		&& defaultAttribute == NULL)
	{
		//for String, need construction only when default value exist
		return;
	}

	if (index == 0)
	{
		structDefinition += T("	");
		structDefinition += child->getParent()->getName();
		structDefinition += T("()\r\n		:	");
	}
	else
	{
		structDefinition += T("		,	");
	}
	if (recursive)
	{
		structDefinition += T("Child");
	}
	else
	{
		structDefinition += child->getName();
	}
	structDefinition += T("(");
	++index;

	if (defaultAttribute != NULL)
	{
		if (Strcmp(type->getString(), T("string")) == 0)
		{
			structDefinition += LEFT_QUOTE;
			structDefinition += defaultAttribute->getString();
			structDefinition += T("\"");
		}
		else
		{
			structDefinition += defaultAttribute->getString();
		}
	}
	else
	{
		if (recursive)
		{
			structDefinition += T("NULL");
		}
		else
		{
			structDefinition += getTypeDefaultValue(type->getString());
		}
	}
	structDefinition += T(")\r\n");
}
开发者ID:wzAdmin,项目名称:Graph,代码行数:70,代码来源:XmlSchema.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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