void parseInput() { while (!feof(stdin)) { if (fgets(command_line,MAX_LINE_SIZE + 2,stdin) == NULL) break; if (strlen(command_line) > MAX_LINE_SIZE) { printf("Command too long, can not parse\n"); goto_next_line(stdin); } else { missing_argc = 0; sprintf(command_name,""); argc = sscanf(command_line,"%s %d,%d,%d",command_name,&(intv[0]),&(intv[1]),&(intv[2])); if (check_command(COMMAND_GET_POINTS,2)) getPoints(intv[0]); else if (check_command(COMMAND_NEW_MEMBER,3)) newMember(intv[0],intv[1]); else if (check_command(COMMAND_NEW_INVITED_MEMBER,4)) newInvitedMember(intv[0],intv[1],intv[2]); else if (check_command(COMMAND_FORBID_MEMBERSHIP,3)) forbidMembership(intv[0],intv[1]); else if (check_command(COMMAND_GET_TLC_PERSON,2)) getTlcPerson(intv[0]); else if (check_command(COMMAND_GET_FRIENDLIEST_PEOPLE,2)) getFriendliestPeople(intv[0]); else if (check_command(COMMAND_GET_MEMBERS_ADDRESSES,2)) getMembersAddresses(intv[0]); else if (check_command(COMMAND_PYRAMID_BONUS,2)) pyramidBonus(intv[0],intv[1]); else if (check_command(COMMAND_EXIT,1)) break; else if (missing_argc > 0) printf("Missing %d argument(s) in command %s!\n",missing_argc,command_name); else if (argc > 0) printf("Illegal command!\n"); } } }
void QDiscordStateComponent::guildMemberRemoveReceived(const QJsonObject& object) { QSharedPointer<QDiscordGuild> guildPtr = guild(object["guild_id"].toString("")); QSharedPointer<QDiscordMember> member; if(guildPtr) { QSharedPointer<QDiscordMember> tmpMember = guildPtr->member(object["user"].toObject()["id"].toString("")); if(tmpMember) { member = QSharedPointer<QDiscordMember>( new QDiscordMember(*tmpMember) ); guildPtr->removeMember(tmpMember); } else { member =QSharedPointer<QDiscordMember>( new QDiscordMember(object, QSharedPointer<QDiscordGuild>()) ); } } else { member = QSharedPointer<QDiscordMember>( new QDiscordMember(object, QSharedPointer<QDiscordGuild>()) ); } QDiscordMember newMember(*member); emit guildMemberRemoved(newMember); }
cdgClass::cdgClass(size_t lineNumber): cdgScope("class", lineNumber) { CMN_ASSERT(this->AddField("name", "", true, "name of the generated C++ class")); CMN_ASSERT(this->AddField("attribute", "", false, "string placed between 'class' and the class name (e.g. CISST_EXPORT)")); cdgField * field; field = this->AddField("ctor-all-members", "false", false, "adds a constructor requiring an initial value for each member"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); field = this->AddField("virtual-dtor", "false", false, "make the destructor virtual"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); field = this->AddField("generate-human-readable", "true", false, "generate the code for std::string _type.HumanReadable(void), set this to false to provide own implementation"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("false"); CMN_ASSERT(this->AddField("namespace", "", false, "namespace for the class")); field = this->AddField("mts-proxy", "true", false, "generate the code to create a cisstMultiTask proxy, set this to false to avoid proxy generation or \"declaration-only\" to manually instantiate the proxy in a different source file (.cpp)"); CMN_ASSERT(field); field->AddPossibleValue("true"); field->AddPossibleValue("declaration-only"); field->AddPossibleValue("false"); this->AddKnownScope(*this); cdgBaseClass newBaseClass(0); this->AddSubScope(newBaseClass); cdgTypedef newTypedef(0); this->AddSubScope(newTypedef); cdgMember newMember(0); this->AddSubScope(newMember); cdgEnum newEnum(0); this->AddSubScope(newEnum); cdgInline newInline(0, cdgInline::CDG_INLINE_HEADER); this->AddSubScope(newInline); cdgInline newCode(0, cdgInline::CDG_INLINE_CODE); this->AddSubScope(newCode); }
void OSMData::startElementHandler (const XML_Char *name, const XML_Char **atts) { // Les differents element XML d'un OSM sont : // osm, bounds, node, way, relation, nd, member, tag // On peut donc, presque, se contenter de tester le 1er chr ce qui va mieux // qu'un strcmp // Mesure sur rhone-alpes.osm (2.4G) GCC 4.5.0 MinGW en "-O2 -DNDEBUG -g" : // strcmp = 80.0s, switch = 78.7s + newND fixe = 78.1s switch (name[0]) { case 'o' : // XML "osm" element : ignored { checkSyntax (!strcmp (name, "osm")); } break; case 'b' : // XML "bounds" element { checkSyntax (!strcmp (name, "bounds")); m_filebound.min.lat = fixedlatlon (value (atts, "minlat")); m_filebound.max.lat = fixedlatlon (value (atts, "maxlat")); m_filebound.min.lon = fixedlatlon (value (atts, "minlon")); m_filebound.max.lon = fixedlatlon (value (atts, "maxlon")); } break; case 'n' : // XML "node" or "nd" element { if (name[1] == 'o') { checkSyntax (!strcmp (name, "node")); newNode (atts); } else { checkSyntax (!strcmp (name, "nd")); #if 1 // Pas la peine de chercher, "ref" est toujours atts[0] ? checkSyntax (! strcmp (atts[0], "ref")); newND (idvalue(atts[1])); #else newND (idvalue(value(atts, "ref"))); #endif } } break; case 'w' : // XML "way" element { checkSyntax (!strcmp (name, "way")); newWay (atts); } break; case 'r' : // XML "relation" element { checkSyntax (!strcmp (name, "relation")); newRelation (atts); } break; case 'm' : // XML "member" element { checkSyntax (!strcmp (name, "member")); newMember (idvalue(value(atts, "ref")), eltvalue(value(atts, "type")), value(atts, "role")); } break; case 't' : // XML "tag" element { checkSyntax (!strcmp (name, "tag")); // Pas la peine de chercher, c'est toujours 0="k" et 2="v" ... ? addTag (value(atts, "k"), value(atts, "v")); } break; } }