void CommandHandler::parse(int argc, char** argv) { if (argc == 0) { UIManager ui; ui.setController(_gameController); ui.start(); return; } std::string command(*argv); if (command == "add") parseAdd(argc, argv); if (command == "remove" || command == "rm") parseRemove(argc, argv); if (command == "list" || command == "ls") parseList(argc, argv); if (command == "lsp") parseListPlatform(argc, argv); if (command == "lsc") parseListCategory(argc, argv); if (command == "run") parseRun(argc, argv); }
void WsAccount::fromXml( IMAccountList& imAccountList, const std::string& xml ) { bool result = true; TiXmlDocument doc; doc.Parse(xml.c_str()); TiXmlHandle docHandle(&doc); TiXmlNode* syncNode = NULL; syncNode = findSyncNode( docHandle ); QueryResult::EnumMethod eMethod = _queryResult.getEnumMethod(); if (syncNode) { assert( eMethod != QueryResult::EnumMethod_None ); std::string nodeData; nodeData << *syncNode; switch( eMethod ) { case QueryResult::EnumMethod_GetUserNetwork: parseGet( syncNode, imAccountList ); break; case QueryResult::EnumMethod_SaveUserNetwork: parseSet( syncNode, imAccountList ); break; case QueryResult::EnumMethod_RemoveUserNetwork: parseRemove( syncNode, _userNetworkId, _bDeleted ); break; default: assert(false); //New method? } //Results QueryResultXMLSerializer resultSerializer( _queryResult ); //Query node may or may not exist, depending on timestamp. TiXmlNode* queryNode = syncNode->FirstChild( "QUERY" ); if ( queryNode ) { resultSerializer.unserializeQuery( queryNode ); } //Response - We should get this: // 1) if no update required due to timestamp. value == 0 // 2) on all gets. value = 1 TiXmlNode* responseNode = syncNode->FirstChild( "response" ); if ( responseNode ) { resultSerializer.unserializeResponse( responseNode ); } //Status - success or failure of overall action TiXmlNode* statusNode = syncNode->FirstChild( "status" ); if ( statusNode ) { resultSerializer.unserializeStatus( statusNode ); } } else { assert(false); //Did not find node. Did XML change? } }