modelCoupled *parseCoordinator() { modelCoupled *ret = new modelCoupled(); QString strLine = getLine(); checkEqual(strLine, TOKOBRACE); do { strLine = getLine(); if (strLine.trimmed() == TOKSIMULATOR) { modelChild *c = new modelChild(); c->childType = ATOMIC; c->atomic = parseSimulator(); ret->childs.append(c); } else if (strLine.trimmed() == TOKCOORDINATOR) { modelChild *c = new modelChild(); c->childType = COUPLED; c->coupled = parseCoordinator(); ret->childs.append(c); } else if (strLine.trimmed() == TOKEIC) { QList < modelConnection * >l = parseConnections(); ret->lsEIC = l; } else if (strLine.trimmed() == TOKEOC) { QList < modelConnection * >l = parseConnections(); ret->lsEOC = l; } else if (strLine.trimmed() == TOKIC) { QList < modelConnection * >l = parseConnections(); ret->lsIC = l; } else if (strLine != TOKCBRACE) { printf("Expecting {%s, %s, %s, %s, %s}: found %s\n", TOKSIMULATOR, TOKCOORDINATOR, TOKEIC, TOKEOC, TOKIC, QSTR(strLine)); exit(-1); } } while (strLine != TOKCBRACE); return ret; }
void QuickClassParser::parse( const QString &code ) { formCode = code; QString expr; globalClass.name = gname; globalClass.type = QuickClass::Global; currClass = &globalClass; static int functionLength = strlen( "function" ); static int constructorLength = strlen( "constructor" ); for ( pos = 0; pos < (int)formCode.length(); ++pos ) { if ( legalChars.find( formCode[ pos ] ) == -1 ) expr = ""; else expr += formCode[ pos ]; if ( expr == QString::fromLatin1("var") || expr == QString::fromLatin1("const") || expr == QString::fromLatin1("static") ) { int i = pos + 1; while ( formCode[ i ] == ' ' || formCode[ i ] == '\t' ) ++i; if ( formCode.mid( i, 8 ) != QString::fromLatin1("function") ) { ++pos; parseVariableDecl( expr ); } expr = ""; continue; } else if ( expr == QString::fromLatin1("private") || expr == QString::fromLatin1("protected") || expr == QString::fromLatin1("public") ) { lastAccess = expr; expr = QString::fromLatin1(""); continue; } else if ( expr == QString::fromLatin1("function") || expr == QString::fromLatin1("constructor") ) { ++pos; parseFunction( expr == QString::fromLatin1("function") ? functionLength : constructorLength ); expr = ""; continue; } else if ( expr == QString::fromLatin1("connect") ) { ++pos; parseConnections(); expr = ""; continue; } else if ( expr == QString::fromLatin1("//") ) { pos--; parseCppComment(); expr = ""; continue; } else if ( expr == QString::fromLatin1("/*") ) { pos--; parseCComment(); expr = ""; continue; } else if ( expr == QString::fromLatin1("class") ) { if ( currClass != &globalClass ) clsses.append( *currClass ); currClass = new QuickClass; currClass->type = QuickClass::Class; ++pos; parseClassStart(); expr = ""; } else if ( formCode[ pos ] == '}' ) { if ( currClass != &globalClass ) clsses.append( *currClass ); currClass = &globalClass; } } if ( currClass != &globalClass ) clsses.append( *currClass ); clsses.append( globalClass ); }
static uint64_t parseVersion1( tr_torrent * tor, const uint8_t * buf, const uint8_t * end, uint64_t fieldsToLoad ) { uint64_t ret = 0; while( end - buf >= 5 ) { uint8_t id; uint32_t len; readBytes( &id, &buf, sizeof( id ) ); readBytes( &len, &buf, sizeof( len ) ); if( buf + len > end ) { tr_torerr( tor, "Resume file seems to be corrupt. Skipping." ); } else if( fieldsToLoad & internalIdToPublicBitfield( id ) ) switch( id ) { case FR_ID_DOWNLOADED: ret |= parseDownloaded( tor, buf, len ); break; case FR_ID_UPLOADED: ret |= parseUploaded( tor, buf, len ); break; case FR_ID_PROGRESS: ret |= parseProgress( tor, buf, len ); break; case FR_ID_PRIORITY: ret |= parsePriorities( tor, buf, len ); break; case FR_ID_SPEED: ret |= parseSpeedLimit( tor, buf, len ); break; case FR_ID_RUN: ret |= parseRun( tor, buf, len ); break; case FR_ID_CORRUPT: ret |= parseCorrupt( tor, buf, len ); break; case FR_ID_PEERS: ret |= parsePeers( tor, buf, len ); break; case FR_ID_MAX_PEERS: ret |= parseConnections( tor, buf, len ); break; case FR_ID_DOWNLOAD_DIR: ret |= parseDownloadDir( tor, buf, len ); break; default: tr_tordbg( tor, "Skipping unknown resume code %d", (int)id ); break; } buf += len; } return ret; }