TInt CRfsScript::ParseNextCommandL( CRfsCommand* aCommand ) { const TDesC* commands[ KRfsNumberOfCommands ] = { &KRfsCommand1, &KRfsCommand2, &KRfsCommand3, &KRfsCommand4, &KRfsCommand5, &KRfsCommand6, &KRfsCommand7, &KRfsCommand8 }; TInt startIndex; TInt endIndex; FOREVER { // check if index is beyond the descriptor already if ( iIndex >= iLength ) { return KRfsEndOfScript; } // go to the beginning of the "command word" startIndex = iIndex; SkipSpace( startIndex ); // go to the end of the "command word" endIndex = startIndex; FindEnd( endIndex ); if ( endIndex - startIndex > 0 && !IsComment( startIndex ) ) { break; } // if the line is commented out, skip it iIndex = NextLine( startIndex ); } // create TPtrC to the "command word" TPtrC command( &iScript[ startIndex ], endIndex - startIndex ); TRfsCommandId commandId( ERfsCommandUnknown ); // determine the command id for ( TInt i = 0; i < KRfsNumberOfCommands ; i++ ) { if ( !command.CompareF( *( commands[ i ] ) ) ) { commandId = (TRfsCommandId)i; break; } } TInt ret( KErrGeneral ); // returns this if there is a syntax error in line if ( commandId != ERfsCommandUnknown ) { TInt numberOfParams( 0 ); TInt start = endIndex; FOREVER { TBool quotes( EFalse ); SkipSpace( start, "es ); TInt end = start; if ( FindEnd( end, quotes ) ) { if ( end - start > 0 && !IsComment( start) ) { numberOfParams++; start = end; continue; } } break; } if ( VerifyNumberOfParameters( commandId, numberOfParams ) ) { // set command information if the command parameter has been given if ( aCommand ) { TPtrC* params = new( ELeave ) TPtrC[ numberOfParams ]; // fetch parameter information for ( TInt i = 0; i < numberOfParams ; i++ ) { TInt paramStart = endIndex; TBool quotes( EFalse ); SkipSpace( paramStart, "es ); TInt paramEnd = paramStart; FindEnd( paramEnd, quotes ); TInt realStart( paramStart ); TInt realEnd( paramEnd ); if ( quotes ) { realStart++; realEnd--; } params[ i ].Set( &iScript[ realStart ], realEnd - realStart ); endIndex = paramEnd; } // aCommand gets ownership of paramStarts and paramLengths aCommand->Set( commandId, numberOfParams, params ); } iIndex = NextLine ( endIndex ); ret = KErrNone; } }
void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew) { mapOldNew.clear(); mapOldNew.resize(realEnd(),0xffffffff); //VERSION THAT PRESERVE ORDER OF ELEMENTS ? // unsigned int down = 0; // for (unsigned int occup = realBegin(); occup != realEnd(); next(occup)) // { // mapOldNew[occup] = down; // copyLine(down,occup); // // copy ref counter // setNbRefs(down,getNbRefs(occup)); // down++; // } // fill the holes with data & create the map Old->New unsigned int up = realRBegin(); unsigned int down = 0; while (down < up) { if (!used(down)) { mapOldNew[up] = down; // copy data copyLine(down,up); // copy ref counter setNbRefs(down,getNbRefs(up)); // set next element to catch for hole filling realRNext(up); } down++; } // end of table = nb elements m_maxSize = m_size; // no more blocks empty m_tableBlocksEmpty.clear(); // only the last block has free indices m_tableBlocksWithFree.clear(); // compute nb block full unsigned int nbb = m_size / _BLOCKSIZE_; // update holeblock for (unsigned int i=0; i<nbb; ++i) m_holesBlocks[i]->compressFull(_BLOCKSIZE_); //update last holeblock unsigned int nbe = m_size % _BLOCKSIZE_; if (nbe != 0) { m_holesBlocks[nbb]->compressFull(nbe); m_tableBlocksWithFree.push_back(nbb); nbb++; } // free memory and resize for (int i = m_holesBlocks.size() - 1; i > int(nbb); --i) delete m_holesBlocks[i]; m_holesBlocks.resize(nbb); // release unused data memory for(unsigned int j = 0; j < m_tableAttribs.size(); ++j) { if (m_tableAttribs[j] != NULL) m_tableAttribs[j]->setNbBlocks(m_holesBlocks.size()); } }