/*! \internal Set a record for OnFieldChange and OnRowChange. */ bool QSqlTableModelPrivate::setRecord(int row, const QSqlRecord &record) { Q_Q(QSqlTableModel); bool isOk = true; QSqlTableModel::EditStrategy oldStrategy = strategy; // FieldChange strategy makes no sense when setting an entire row if (strategy == QSqlTableModel::OnFieldChange) strategy = QSqlTableModel::OnRowChange; for (int i = 0; i < record.count(); ++i) { int idx = nameToIndex(record.fieldName(i)); if (idx == -1) continue; QModelIndex cIndex = q->createIndex(row, idx); QVariant value = record.value(i); QVariant oldValue = q->data(cIndex); if (oldValue.isNull() || oldValue != value) isOk &= q->setData(cIndex, value, Qt::EditRole); } if (isOk && oldStrategy == QSqlTableModel::OnFieldChange) q->submitAll(); strategy = oldStrategy; return isOk; }
int AnalyseGPL(nodeType *p1) { char nodeName[15]; strcpy(nodeName, p1->name); int boolAnalyse = 1; if (strcmp(nodeName, "conc") == 0) { if (AnalyseGPL(p1->left) == 1) { return AnalyseGPL(p1->right); } else { return 0; } } else if (strcmp(nodeName, "union") == 0) { if (AnalyseGPL(p1->left) == 1) { return 1; } else { return AnalyseGPL(p1->right); } } else if (strcmp(nodeName, "star") == 0) { while (AnalyseGPL(p1->left) == 1) { } return 1; } else if (strcmp(nodeName, "un") == 0) { return AnalyseGPL(p1->left); } else { // atome if(val_scanGPL()==NULL){ return 1; } if (p1->aType == TERMINAL) { if (p1->code == codeGPL()) { if (p1->action != 0) { actionGPL(p1->action); } char copie[50] = "\'"; strcat(copie,val_scanGPL()); strcat(copie,"\'"); if ((strcmp(p1->name, copie) == 0 || strcmp(p1->name, "\'ident\'") == 0 || strcmp(p1->name, "\'Ent\'") == 0)/* || strcmp(val_scanGPL(), "\';\'")==0*/) { scan_GPL(); return 1; } else { return 0; } } } else if (p1->aType == NONTERMINAL && AnalyseGPL(A[nameToIndex(p1->name)]) == 1) { if (p1->action != 0) { actionGPL(p1->action); } return 1; } else { return 0; } } return 0; // normalement on ne passe pas la }
int AnalyseG0(nodeType *p1) { char nodeName[15]; strcpy(nodeName, p1->name); int boolAnalyse = 1; if (strcmp(nodeName, "conc") == 0) { if (AnalyseG0(p1->left) == 1) { return AnalyseG0(p1->right); } else { return 0; } } else if (strcmp(nodeName, "union") == 0) { if (AnalyseG0(p1->left) == 1) { return 1; } else { return AnalyseG0(p1->right); } } else if (strcmp(nodeName, "star") == 0) { while (AnalyseG0(p1->left) == 1) { } return 1; } else if (strcmp(nodeName, "un") == 0) { return AnalyseG0(p1->left); } else { // atome if (p1->aType == TERMINAL) { if (p1->code == code()) { if (p1->action != 0) { action(p1->action); } if (code() == OPERATION) { if (strcmp(p1->name, val_scan()) == 0) { scan(); return 1; } else { return 0; } } else { scan(); return 1; } } else { return 0; } } else if (p1->aType == NONTERMINAL && AnalyseG0(A[nameToIndex(p1->name)]) == 1) { if (p1->action != 0) { action(p1->action); } return 1; } else { return 0; } } return 0; // normalement on ne passe pas la }
////////////////////////////////////////////////////////////////////////////// // Delete the stop watch with the name \a name ////////////////////////////////////////////////////////////////////////////// void destroy(const unsigned int &name) { // get index into global memory swatches_size_type pos = nameToIndex(name); // delete stop watch delete StopWatchC::swatches[pos]; // invalidate storage StopWatchC::swatches[pos] = NULL; }
/** * Get index of given @a option * @param option the option to retrieve the index for * @param sec Section the new index should point to * @return a QModelIndex to @a option */ QModelIndex OptionsTreeModel::index(const QString &option, Section sec) const { if (option == "") { return QModelIndex(); } if (flat_) { QStringList options = tree_->getChildOptionNames("",false,false); options.sort(); int row = options.indexOf(option); return createIndex(row, sec, nameToIndex(options.at(row))); } else { QString parentname(getParentName(option)); QStringList children = tree_->getChildOptionNames(parentname,true,true); children.sort(); int row = children.indexOf(option); return createIndex(row, sec, nameToIndex(option)); } }
int main() { const char out[4][32] = {"subordinate", "supervisor", "colleague", "unrelated"}; while (scanf("%d", &n) == 1) { for (int i = 0; i < n; i++) { scanf("%d", &A[i].id); readName(&A[i]); scanf("%d", &A[i].boss_id); } build_graph(); scanf("%d", &m); employee x, y; for (int i = 0; i < m; i++) { readName(&x); readName(&y); int ix = nameToIndex(&x), iy = nameToIndex(&y); if (ix == -1 || iy == -1) { puts(out[3]); } else { puts(out[relation(ix, iy)]); } } } return 0; }
int targetReadCallback(char* buf, int len) { cachecrack_t resp; cachecrack(&resp, buf, len); if(resp.cols !=3 || resp.retcode != 0) { printf("power target query returned bad data\n%s\n",buf); cachecrack_free(&resp); return 1; } for(int i=0;i<resp.rows; i++) { char* name = resp.rowdata[i][0]; double s0 = strtod(resp.rowdata[i][1],NULL); double s1 = strtod(resp.rowdata[i][2],NULL); int idx = nameToIndex(name, hostnames, HOST_NAME_MAX); if(idx<0) { printf("bad host name %s in list\n",name); } else { allocations[idx*2] = s0; allocations[idx*2+1] = s1; } } cachecrack_free(&resp); }
QModelIndex OptionsTreeModel::index(int row, int column, const QModelIndex & parent) const { if (column < 0 || column >= SectionBound || row < 0) { return QModelIndex(); } int id = 0; QStringList options; if (flat_) { options = tree_->getChildOptionNames("",false,false); } else { QString parent_option; if (parent.isValid()) { parent_option = indexToOptionName(parent); } options = tree_->getChildOptionNames(parent_option,true,true); } if (row >= options.size()) { return QModelIndex(); } options.sort(); id = nameToIndex(options.at(row)); return createIndex(row,column,id); }
////////////////////////////////////////////////////////////////////////////// // Get a handle to the stop watch with the name \a name ////////////////////////////////////////////////////////////////////////////// StopWatchC & get(const unsigned int &name) { return *(StopWatchC::swatches[nameToIndex(name)]); }
int parseDr( mips * pMips, const char * paramStr ) { char * argCopy = NULL, * pch = NULL, * str = NULL; int toDisplay[100]; int i, nb, parseNb, invalid; char parseName[100] = {'\0'}; nb = 0; invalid = 0; // copy argument string for modifications argCopy = (char *) malloc( 1 + strlen( paramStr ) ); argCopy = strcpy( argCopy, paramStr ); pch = strtok( argCopy, " " ); if( NULL == pch ) { // no arguments given : display all registers for( i = 0; i < 36; i++ ) toDisplay[i] = i; nb = 36; } else { do { if( '$' == pch[0] ) { // copy pch without the '$' str = (char *) malloc( strlen( pch ) ); strcpy( str, pch+1 ); } else { // pch doesn't contain '$', copy it entirely str = (char *) malloc( 1 + strlen( pch ) ); strcpy( str, pch ); } // process 'str' if( isDigit( str[0] ) ) { // $index form sscanf( str, "%d", &parseNb ); if( parseNb >= 0 && parseNb <= 31 ) { toDisplay[nb] = parseNb; nb++; } else invalid++; } else { // $name form sscanf( str, "%s", parseName ); if( nameToIndex( parseName ) >= 0 ) { toDisplay[nb] = nameToIndex( parseName ); nb++; } else { invalid++; } } pch = strtok( NULL, " " ); } while( NULL != pch ); } if( invalid ) { WARNING_MSG( "invalid registers" ); printf( "Warning : %d invalid registers names were ignored.\n", invalid ); } return( executeDr( pMips, toDisplay, nb ) ); }