QString param = descriptors[descriptor];QStringList array = param.split(";"); SqlQuery squery;query.exec(QString(array[0]));int j = 2;QString var = array[1]; switch (array[1]){ case "special" : while (j < array.size()) { QStringList subarr = array[j].split("="); text += subarr[0] + " " + squery[subarr[1]] + ", "; j++; } break; case "day" : {text = squery[array[2]]; QStringList subarr = text.split(":"); text = subarr[0];} break; case "monthNum" : {text = squery[array[2]]; QStringList subarr = text.split(":"); text = subarr[1];} break; case "yearLast2" : {text = squery[array[2]]; QStringList subarr = text.split(":"); text = subarr[2]; text = text.remove(0, 2);} break; case "art" : text = QString :: number(IT + 1); // IT - порядковый номер записи тт Накладной break; default: while (j < array.size()) { text += array[1] + squery[array[j]]; j++; }}
C++ (Qt)enum FieldType { specila, day, monthNum, yearLst, ..... }; FieldType fld = array[ 1 ];switch( fld ){ case special: .... case day: ....}
int x = 0;switch (x)case 0: x++;break;
C++ (Qt)int x = 0;switch (x) case 0: x++;break;
C++ (Qt)class MServerConnectionPrivate{public: MServerConnectionPrivate(MServerConnection *value); MServer *server; quint32 clientId; bool sendGreeting(); bool processPacket(MPacket &packet);private: bool processIdChange(MPacket &packet); bool processServerMessage(MPacket &packet); bool processServerStatus(MPacket &packet); bool processServerIdent(MPacket &packet); bool processServerList(MPacket &packet); bool processSearchResult(MPacket &packet); bool processCallbackRequested(MPacket &packet); bool processCallbackFail(MPacket &packet); bool processReject(MPacket &packet); bool processFoundSources(MPacket &packet); bool processFoundSourcesObfuscated(MPacket &packet); typedef bool (MServerConnectionPrivate::*ProcessMethodPtr)(MPacket &packet); typedef QHash<quint8, ProcessMethodPtr> ProcessMethodsTable; ProcessMethodsTable table; MServerConnection *q;};#ifdef METHOD_TABLE_FILL#error conflict in macro declaration#endif #define METHOD_TABLE_FILL(_Opcode_) \ table[Opcode::_Opcode_] = &MServerConnectionPrivate::process##_Opcode_MServerConnectionPrivate::MServerConnectionPrivate(MServerConnection *value) : q(value), clientId(0){ METHOD_TABLE_FILL(IdChange); METHOD_TABLE_FILL(ServerStatus); METHOD_TABLE_FILL(ServerMessage); METHOD_TABLE_FILL(ServerIdent); METHOD_TABLE_FILL(ServerList); METHOD_TABLE_FILL(SearchResult); METHOD_TABLE_FILL(CallbackRequested); METHOD_TABLE_FILL(CallbackFail); METHOD_TABLE_FILL(Reject); METHOD_TABLE_FILL(FoundSources); METHOD_TABLE_FILL(FoundSourcesObfuscated);}#undef METHOD_TABLE_FILL
C++ (Qt)bool MServerConnectionPrivate::processPacket(MPacket &packet){ ProcessMethodPtr method = table[packet.opcode()]; if (!method) { qFatal("Method not found for opcode = %d", packet.opcode());//TODO:remove after implementing all return false; } qDebug("Found method to process packet, opcode = %d", packet.opcode()); return (this->*method)(packet);}
switch(iType){ case abonent: //my code break; case phone: //my code break; case default: //my code //break}
int k = 0;int iType;switch(iType){ case k: break;}
C++ (Qt)...enum MyEnum { One = 1, Two, Three };...int iType = 3;MyEnum t = MyEnum(iType); switch (t) {case One: {...} break;case Two: {...} break;case Three: {...} break;default: {...} break;};