From: <ac...@us...> - 2007-11-05 02:53:28
|
Revision: 191 http://planeshift.svn.sourceforge.net/planeshift/?rev=191&view=rev Author: acraig Date: 2007-11-04 18:53:32 -0800 (Sun, 04 Nov 2007) Log Message: ----------- Switched to standard XML parser. Modified Paths: -------------- trunk/docs/history.txt trunk/src/client/cmdadmin.cpp Modified: trunk/docs/history.txt =================================================================== --- trunk/docs/history.txt 2007-11-05 00:47:13 UTC (rev 190) +++ trunk/docs/history.txt 2007-11-05 02:53:32 UTC (rev 191) @@ -1,3 +1,6 @@ +*** 2007-11-04 by Andrew Craig +- Fixed command parser on client to use standard XML parser system. + *** 2007-11-04 by Kenny Graunke - Clean up scary code (with warnings) in factions.cpp. Modified: trunk/src/client/cmdadmin.cpp =================================================================== --- trunk/src/client/cmdadmin.cpp 2007-11-05 00:47:13 UTC (rev 190) +++ trunk/src/client/cmdadmin.cpp 2007-11-05 02:53:32 UTC (rev 191) @@ -16,6 +16,8 @@ */ #include <psconfig.h> +#include <iutil/document.h> + #include "globals.h" #include "cmdadmin.h" #include "net/cmdhandler.h" @@ -88,30 +90,35 @@ psSystemMessage sysMsg( 0, MSG_INFO, "You now have the following admin commands available:" ); msgqueue->Publish( sysMsg.msg ); - psXMLString main ( msg.cmd ); + + iDocumentSystem* xml = psengine->GetXMLParser (); + csRef<iDocument> doc = xml->CreateDocument(); + const char* error = doc->Parse(msg.cmd); - int start = (int)main.FindTag("command"); - csString commands; - - while ( start != -1 ) + if ( error ) { - csString cmdString; - psXMLTag tag( main, start ); - tag.GetTagParm( "name", cmdString ); + Error3("Failure to parse XML string %s Error %s\n", msg.cmd, error); + } + else + { + csRef<iDocumentNodeIterator> cmdIter = doc->GetRoot()->GetNodes("command"); + + csString commands = ""; + while ( cmdIter->HasNext() ) + { + csRef<iDocumentNode> commandNode = cmdIter->Next(); + csString cmdString = commandNode->GetAttributeValue("name"); + commands.Append( cmdString ); + commands.Append( " " ); + cmdsource->Subscribe( cmdString, this ); + } + + psSystemMessage commandMsg( 0, MSG_INFO, commands.GetData() ); + msgqueue->Publish( commandMsg.msg ); - commands.Append( cmdString ); - commands.Append( " " ); - - cmdsource->Subscribe( cmdString, this ); - - start = main.FindTag( "command", start + 1 ); - } - - psSystemMessage commandMsg( 0, MSG_INFO, commands.GetData() ); - msgqueue->Publish( commandMsg.msg ); - - // Update the auto-complete list - pawsChatWindow* chat = static_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow")); - chat->RefreshCommandList(); + // Update the auto-complete list + pawsChatWindow* chat = static_cast<pawsChatWindow*>(PawsManager::GetSingleton().FindWidget("ChatWindow")); + chat->RefreshCommandList(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |