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


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

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


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

示例1: ExtractIOReg

// Extract the column and row attributes from an ioreg element.
int EpiphanyXML::ExtractIOReg(XMLElement* element, unsigned* row, unsigned* col)
{
	// ioregs is a child of chip and should have a col and row attribute
	int nkids;
	int i;
	XMLElement* child;
	char buf[128];

	nkids = element->GetChildrenNum();
	for (i=0; i<nkids; i++)
	{
		if ((child = element->GetChildren()[i]))
		{
			child->GetElementName(buf);
			if ((strcmp(buf, "ioregs") == 0) &&
			    (ExtractAttr(child, row, "row") == 0) &&
			    (ExtractAttr(child, col, "col") == 0))
			{
				// found the ioregs element and liked it.
				return 0;
			}
		}
	}
	*row = NO_IOREG;
	*col = NO_IOREG;
	return -1;
}
开发者ID:alexrp,项目名称:epiphany-libs,代码行数:28,代码来源:epiphany_xml.cpp

示例2: Parse

int EpiphanyXML::Parse()
{
	int nkids = 0;
	int i;
	XMLElement* root;
	XMLElement* child;
	//XMLElement* gchild;
	char buf[256];

	root = m_xml->GetRootElement();
	root->GetElementName(buf);
	if (strcmp(buf, "platform") ||
	    ExtractAttr(root, &m_platform->version, "version") ||
	    ExtractAttr(root, &m_platform->name, "name") ||
	    ExtractAttr(root, &m_platform->lib, "lib") ||
	    ExtractAttr(root, &m_platform->libinitargs, "libinitargs"))
	{
		return -1;
	}

	if (m_platform->version != 1)
	{
		return -2;
	}

	// process platform children
	nkids = root->GetChildrenNum();
	for (i=0; i < nkids; i++)
	{
		child = root->GetChildren()[i];
		child->GetElementName(buf);
		if (strcmp(buf, "chips") == 0)
		{
			ExtractChips(child);
		}
		else if (strcmp(buf, "external_memory") == 0)
		{
			ExtractExternalMemory(child);
		}
	}

	return 0;
}
开发者ID:alexrp,项目名称:epiphany-libs,代码行数:43,代码来源:epiphany_xml.cpp

示例3: GetXmlIcon

int GetXmlIcon(XMLElement* xe)
{
	int nChildNum = xe->GetChildrenNum();
	for (int i=0; i<nChildNum; ++i)
	{
		XMLElement* ch = xe->GetChildren()[i];
		char n[128];
		ch->GetElementName(n);
		if (strcmp(n, "icon") ==0)
		{
			char szBuiltin[128];
			ch->FindVariableZ("BUILTIN")->GetValue(szBuiltin, 1);
			if (strcmp(szBuiltin, "flag")==0)
			{
				return TEXT_ICON_TODO;
			}
			else if (strcmp(szBuiltin, "button_ok")==0)
			{
				return TEXT_ICON_DONE;
			}
			else if (strcmp(szBuiltin, "button_cancel")==0)
			{
				return TEXT_ICON_CROSS;
			}
			else if (strcmp(szBuiltin, "bookmark")==0)
			{
				return TEXT_ICON_STAR;
			}
			else if (strcmp(szBuiltin, "help")==0)
			{
				return TEXT_ICON_QUESTION;
			}
			else if (strcmp(szBuiltin, "messagebox_warning")==0)
			{
				return TEXT_ICON_WARNING;
			}
			else if (strcmp(szBuiltin, "idea")==0)
			{
				return TEXT_ICON_IDEA;
			}
			else
			{
				return TEXT_ICON_PLAINTEXT;
			}
		}
		
	}
	return TEXT_ICON_PLAINTEXT;
}
开发者ID:boogunote,项目名称:bn1,代码行数:49,代码来源:Common.cpp

示例4: ExtractExternalMemory

// Extract data from an <external_memory> element.
void EpiphanyXML::ExtractExternalMemory(XMLElement* element)
{
	int i;
	int nkids;
	XMLElement* child;
	char buf[128];

	// Figure out how many chips there are.
	if ((nkids = element->GetChildrenNum()))
	{
		// If we've already found an external memory tag, we should just add more
		// memory banks to m_platform->ext_mem. To do this, we allocate a new
		// one, copy the old one into it, free the old one, and replace the old with
		// the new.
		if (m_platform->num_banks)
		{
			mem_def_t *new_mem = new mem_def_t[nkids + m_platform->num_banks];
			memcpy(new_mem, m_platform->ext_mem, sizeof(mem_def_t) * m_platform->num_banks);
			delete[] m_platform->ext_mem;
			m_platform->ext_mem = new_mem;
		}
		else
		{
			// If the XML is well-formed, all of the child elements of <external_memory>
			// should be <bank>. Allocating enough mem_def_t's for all the children
			// will only waste memory if the XML is not well-formed.
			m_platform->ext_mem = new mem_def_t[nkids];
		}
		// Now populate the array with each bank we find
		for (i = 0; i < nkids; i++)
		{
			child = element->GetChildren()[i];
			child->GetElementName(buf);
			if (!strcmp(buf, "bank"))
			{
				ExtractBank(child, &m_platform->ext_mem[m_platform->num_banks]);
				m_platform->num_banks += 1;
			}
		}
	}
}
开发者ID:alexrp,项目名称:epiphany-libs,代码行数:42,代码来源:epiphany_xml.cpp

示例5: ExtractChips

// Extract data from a <chips> element.
void EpiphanyXML::ExtractChips(XMLElement* element)
{
	int i;
	int nkids;
	XMLElement* child;
	char buf[128];

	// Figure out how many chips there are.
	if ((nkids = element->GetChildrenNum()))
	{
		// If we've already found a chip tag, we should just add more
		// chips to m_platform->chips. To do this, we allocate a new
		// one, copy the old one into it, free the old one, and replace the old with
		// the new.
		if (m_platform->num_chips)
		{
			chip_def_t* new_platform = new chip_def_t[nkids + m_platform->num_chips];
			memcpy(new_platform, m_platform->chips, sizeof(chip_def_t) * m_platform->num_chips);
			delete[] m_platform->chips;
			m_platform->chips = new_platform;
		}
		else
		{
			// If the XML is well-formed, all of the child elements of <chips>
			// should be <chip>. Allocating enough chip_def_t's for all the children
			// will only waste memory if the XML is not well-formed.
			m_platform->chips = new chip_def_t[nkids];
		}

		// Now populate the array with each valid chip we find
		for (i = 0; i < nkids; i++)
		{
			child = element->GetChildren()[i];
			child->GetElementName(buf);
			if (!strcmp(buf, "chip") && ExtractChip(child, &m_platform->chips[m_platform->num_chips]) == 0)
			{
				m_platform->num_chips += 1;
			}
		}
	}
}
开发者ID:alexrp,项目名称:epiphany-libs,代码行数:42,代码来源:epiphany_xml.cpp

示例6: main

int main()
 {
 OleInitialize(0);
 char* f1 = "http://www.turboirc.com/xml/sample1.xml";
 char* f2 = ".\\sample2.xml";

 XML* x = 0;

 // Load from file or url
 FILE* fp = fopen(f1,"rb");
 if (fp)
	 {
	 // Load from file
	 fclose(fp);
	 x = new XML(f1);
	 }
 else
	 {
	 // Load from url
	 x = new XML(f1,XML_LOAD_MODE_URL);
	 }

 // Parse status check
 int iPS = x->ParseStatus(); // 0 OK , 1 Header warning (not fatal) , 2 Error in parse (fatal)
 bool iTT = x->IntegrityTest(); // TRUE OK
 if (iPS == 2 || iTT == false)
	 {
	 fprintf(stderr,"Error: XML file %s is corrupt (or not a XML file).\r\n\r\n",f1);
	 delete x;
	 return 0;
	 }

 // Sample export to stdout
 x->Export(stdout,XML_SAVE_MODE_ZERO);


 // Sample XML functions
 fprintf(stdout,"\r\n\r\n---------- XML test ----------\r\n");
 XML_VERSION_INFO xI = {0};
 x->Version(&xI);
 fprintf(stdout,"XML version: %u.%u (%s)\r\n",xI.VersionHigh,xI.VersionLow,xI.RDate);
 int m1 = x->MemoryUsage();
 x->CompressMemory();
 int m2 = x->MemoryUsage();
 fprintf(stdout,"Memory used before/after compression: %u / %u bytes.\r\n",m1,m2);
 fprintf(stdout,"XML header: %s\r\n",x->GetHeader()->operator const char *());

 // Sample XMLElement functions
 fprintf(stdout,"\r\n\r\n---------- XMLElement test ----------\r\n");
 XMLElement* r = x->GetRootElement();
 int nC = r->GetChildrenNum();
 fprintf(stdout,"Root element has %u children.\r\n",nC);
 for(int i = 0 ; i < nC ; i++)
	 {
	 XMLElement* ch = r->GetChildren()[i];
	 int nV = ch->GetVariableNum();
	 int nMaxElName = ch->GetElementName(0);
	 char* n = new char[nMaxElName + 1];
	 ch->GetElementName(n);

	 fprintf(stdout,"\t Child %u: Variables: %u , Name: %s\r\n",i,nV,n);
	 delete[] n;
	 }
 // Add a children to the end
 r->AddElement(new XMLElement(r,(char*)"<testel x=\"1\" />"));

 // Find this element by name
 XMLElement* el = r->FindElementZ("testel");
 if (!el)
	 fprintf(stderr,"Error, element not found!\r\n");
 else
	 {
	 // Add some variables
	 el->AddVariable(new XMLVariable("somename","somevalue"));
	 // Note that the new XMLVariable we added is now owned by el

	 // Export only this element
	 el->Export(stdout,1,XML_SAVE_MODE_ZERO); // this prints <testel somename="somevalue"/>
	 }

 // Find an element that may not exist, get its variable X that may not exist, get 
 // a default value of 0
 int v = r->FindElementZ("elx",true)->FindVariableZ("varx",true)->GetValueInt();
 // Set it to 5, set some more
 r->FindElementZ("elx",true)->FindVariableZ("varx",true)->SetValueInt(5);
 r->FindElementZ("elx",true)->FindVariableZ("varx2",true)->SetValueInt(10);
 // Printout it
 // This would print: <elx varx="5" varx2="10"/>
 r->FindElementZ("elx",true)->Export(stdout,1,XML_SAVE_MODE_ZERO);

 // Remove the var we just added
 int ix = r->FindElement("elx");
 if (ix != -1)
	 r->RemoveVariable(ix);

 // Other XMLElement functions
 r->Copy(); // Copy entire thing to windows clipboard

 XMLElement* nP = XML::Paste();
 if (nP)
//.........这里部分代码省略.........
开发者ID:visusnet,项目名称:Blobby-Warriors,代码行数:101,代码来源:xmltest.cpp


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