Home » U++ Library support » U++ Core » [XML] Assertion when GetAttrCount() 
	
		
		
			| [XML] Assertion when GetAttrCount() [message #6906] | 
			Mon, 04 December 2006 08:29   | 
		 
		
			
				
				
				
					
						  
						g00fy
						 Messages: 15 Registered: December 2006  Location: Mechelen, Belgium, Europe
						
					 | 
					Promising Member  | 
					 | 
		 
		 
	 | 
 
	
		#include <CtrlLib/CtrlLib.h>
#include <ide/Common/Common.h>
#include <Core/Core.h>
void write_out( FileOut& out, const XmlNode& xml, int ident )
{
	switch( xml.GetType() )
	{
	case XML_TEXT:
		out << String(' ', ident) << "Text: " << xml.GetText() << "\n";
		break;
	case XML_TAG:
		out << String(' ', ident) << "Tag: " << xml.GetTag() << "\n";
		for ( int i = 0, total = xml.GetAttrCount(); i < total; i++ )
		{
			out << String( ' ', ident ) << "+> " << xml.AttrId(i) << ": " << xml.Attr(i) << "\n";
		}
		ident += 2;
		break;
	case XML_DOC:
		out << String(' ', ident) << "Doc:\n";
		break;
	default:
		out << String(' ', ident) << "**UNDEFINED TAG**\n";
		break;
	}
	
	for ( int i = 0, total = xml.GetCount(); i < total; i++ )
	{
		write_out(out, xml[i], ident + 2);
	}
}
GUI_APP_MAIN
{
	Package p;
	String filename("C:\\Upp\\uppsrc\\ide\\Common\\Common.upp");
	p.Load(filename);
	
	XmlNode xml;
	XmlNode makefile = xml.Add("makefile");
	
	XmlNode lib = makefile.Add("lib");
	lib.SetAttr("id", GetFileName(filename));
	
	FileOut out("c:\\tst.dat");
	write_out(out, xml, 2);
} 
 
This code asserts on the call to "xml.GetAttrCount()". It thinks the vector holding those items have -1 items only... 
 
Greetz
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |  
	| 
		
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 10:16:42 CET 2025 
 Total time taken to generate the page: 0.04721 seconds 
 |