void XMLProtocolParser::handlePlayerIn(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); GameData::Side side; std::string reason; while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("team") == 0) { if (strAttr.compare("Cyan") == 0) { side = GameData::Side::CYAN; } else if (strAttr.compare("Magenta") == 0) { side = GameData::Side::MAGENTA; } } else if (strName.compare("reason") == 0) { reason = strAttr; } attr = attr->Next(); } this->gameData->log("Player in " + reason, false, side); }
void XMLProtocolParser::handlePlayer(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); std::string name = ""; std::string inField = ""; bool found = false; while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("name") == 0) { found = fillSetup(valAttr); name = valAttr; } else if (strName.compare("inField") == 0) { inField = valAttr; } attr = attr->Next(); } if (!found) fillTable(name, inField); }
void XMLProtocolParser::handleGoals(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); GameData::Side side = GameData::Side::ALL; while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("team") == 0) { if (strAttr.compare("Cyan") == 0) { side = GameData::Side::CYAN; } else if (strAttr.compare("Magenta") == 0) { side = GameData::Side::MAGENTA; } } attr = attr->Next(); } if (side != GameData::Side::ALL) { this->gameData->setGoals(side, this->gameData->getGoals(side) + 1); } }
void XMLProtocolParser::handleTeamData(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("team") == 0) { if (strAttr.compare("Cyan") == 0) { this->cyan = true; this->magenta = false; } else if (strAttr.compare("Magenta") == 0) { this->cyan = false; this->magenta = true; } } attr = attr->Next(); } }
// ---------------------------------------------------------------------------- bool CGtfReadRecord::x_AssignAttributesFromGff( const string& strGtfType, const string& strRawAttributes ) // ---------------------------------------------------------------------------- { vector< string > attributes; x_SplitGffAttributes(strRawAttributes, attributes); for ( size_t u=0; u < attributes.size(); ++u ) { string strKey; string strValue; string strAttr(attributes[u]); if (!NStr::SplitInTwo(strAttr, "=", strKey, strValue)) { if (!NStr::SplitInTwo(strAttr, " ", strKey, strValue)) { if (strGtfType == "gene") { m_Attributes["gene_id"] = xNormalizedAttributeValue(strAttr); continue; } if (strGtfType == "transcript") { if (!NStr::SplitInTwo(strAttr, ".", strKey, strValue)) { return false; } m_Attributes["gene_id"] = xNormalizedAttributeValue(strKey); m_Attributes["transcript_id"] = xNormalizedAttributeValue(strAttr); continue; } } } strKey = xNormalizedAttributeKey( strKey ); strValue = xNormalizedAttributeValue( strValue ); if ( strKey.empty() && strValue.empty() ) { // Probably due to trailing "; ". Sequence Ontology generates such // things. continue; } if ( NStr::StartsWith( strValue, "\"" ) ) { strValue = strValue.substr( 1, string::npos ); } if ( NStr::EndsWith( strValue, "\"" ) ) { strValue = strValue.substr( 0, strValue.length() - 1 ); } m_Attributes[ strKey ] = strValue; } return true; }
void XMLProtocolParser::handleCardAwarded(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); std::string team = ""; std::string player = ""; std::string color = ""; std::string number = ""; while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("team") == 0) { team = strAttr; } else if (strName.compare("player") == 0) { player = strAttr; } else if (strName.compare("color") == 0) { color = strAttr; } else if (strName.compare("number") == 0) { number = strAttr; } else if (strName.compare("time") == 0) { this->gameData->refBox->lbl_time->setText(QString(valAttr)); } else if (strName.compare("stage") == 0) { this->gameData->refBox->lbl_stage->setText(QString(valAttr)); } attr = attr->Next(); } fillYellow(team, player, color, number); }
void XMLProtocolParser::handleGoalAwarded(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("team") == 0) { if (strAttr.compare("Cyan") == 0) { this->gameData->setGoals(GameData::Side::CYAN, this->gameData->getGoals(GameData::Side::CYAN) + 1); this->gameData->log("Goal", false, GameData::Side::CYAN); } else if (strAttr.compare("Magenta") == 0) { this->gameData->setGoals(GameData::Side::MAGENTA, this->gameData->getGoals(GameData::Side::MAGENTA) + 1); this->gameData->log("Goal", false, GameData::Side::MAGENTA); } } else if (strName.compare("player") == 0) { // TODO NEUER TAB } else if (strName.compare("own") == 0) { // TODO NEUER TAB } else if (strName.compare("stage") == 0) { this->gameData->refBox->lbl_stage->setText(QString(valAttr)); } else if (strName.compare("time") == 0) { this->gameData->refBox->lbl_time->setText(QString(valAttr)); } attr = attr->Next(); } }
void XMLProtocolParser::handleGameInfo(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("time") == 0) { this->gameData->refBox->lbl_time->setText(QString(valAttr)); } else if (strName.compare("stage") == 0) { this->gameData->refBox->lbl_stage->setText(QString(valAttr)); } attr = attr->Next(); } }
void XMLProtocolParser::handleSetup(tinyxml2::XMLElement *curChild) { const tinyxml2::XMLAttribute *attr = curChild->FirstAttribute(); while (attr != nullptr) { const char *valAttr = attr->Value(); const char *valName = attr->Name(); std::string strAttr(valAttr); std::string strName(valName); if (strName.compare("name") == 0) { fillSetup(valAttr); } else if (strName.compare("leader") == 0) { fillSetup(valAttr); } attr = attr->Next(); } }