KDevelop API Documentation

buildtools/qmake/filebuffer.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Jakob Simon-Gaarde * 00003 * jsgaarde@tdcspace.dk * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #include <kdebug.h> 00013 #include <qtextstream.h> 00014 #include "filebuffer.h" 00015 #include <qmessagebox.h> 00016 00020 FileBuffer::~FileBuffer() 00021 //======================= 00022 { 00023 for ( FileBufferList::Iterator it = m_subBuffers.begin(); it != m_subBuffers.end(); ++it ) 00024 delete *it; 00025 for ( ValuesIgnoreList::Iterator it = m_valuesIgnore.begin(); it != m_valuesIgnore.end(); ++it ) 00026 delete *it; 00027 m_subBuffers.clear(); 00028 } 00029 00037 Caret FileBuffer::findInBuffer(const QString &subString,const Caret& startPos, bool nvlToMax, bool searchForVariable) 00038 //=========================================================================================== 00039 { 00040 // ATTENTION: This method is central for the class. Almost all other methods rely on it 00041 // so be careful! 00042 unsigned int i=startPos.m_row; 00043 if (!m_buffer.count()) 00044 if (nvlToMax) 00045 return Caret(m_buffer.count(),0); 00046 else 00047 return Caret(-1,-1); QString line = m_buffer[i++]; 00048 line = line.mid(startPos.m_idx,line.length()-startPos.m_idx); 00049 for (; i<=m_buffer.count(); ++i) 00050 { 00051 int idxSeek = line.find(subString); 00052 // qWarning("FILEBUFFER: substring %s in line %s idxSeek = %d", subString.ascii(), line.latin1(), idxSeek); 00053 if ((line.find(subString)!=-1) 00054 //adymo: do not match substrings if the next character is not a letter or number 00055 //this is supposed to fix handling of similar words like TARGET and TARGETDEPS 00056 && ( ! (searchForVariable && line[idxSeek+subString.length()].isLetterOrNumber()) ) ) 00057 { 00058 00059 // qWarning("FILEBUFFER: next char is %c, index %d", line[idxSeek+subString.length()].latin1(), idxSeek+subString.length()); 00060 if (startPos.m_row == (int) i-1) 00061 // first line in search so start idx should be added to result idx 00062 idxSeek = idxSeek + startPos.m_idx; 00063 return Caret(i-1,idxSeek); 00064 } 00065 if (i<m_buffer.count()) 00066 line = m_buffer[i]; 00067 } 00068 if (nvlToMax) 00069 return Caret(m_buffer.count(),0); 00070 else 00071 return Caret(-1,-1); 00072 } 00073 00078 void FileBuffer::removeComments() 00079 //=============================== 00080 { 00081 for (uint i=0; i<m_buffer.count(); ++i) 00082 { 00083 QString tmp = m_buffer[i].simplifyWhiteSpace(); 00084 if (tmp[0]=='#') 00085 { 00086 pop(i); 00087 --i; 00088 } 00089 } 00090 00091 } 00092 00093 00098 QString FileBuffer::pop(int row) 00099 //============================== 00100 { 00101 if ((unsigned int)row>=m_buffer.count()) 00102 return NULL; 00103 QStringList::Iterator it=m_buffer.begin(); 00104 for (int i=0; i<row; ++it,++i); 00105 QString ReturnStr = *it; 00106 m_buffer.remove(it); 00107 return ReturnStr; 00108 } 00109 00113 void FileBuffer::splitScopeString(QString scopeString,QString &scopeName, QString &scopeRest) 00114 //=========================================================================================== 00115 { 00116 scopeString = scopeString.simplifyWhiteSpace(); 00117 scopeName=""; 00118 scopeRest=""; 00119 if (!scopeString.isEmpty()) 00120 { 00121 int kolonPos = scopeString.find(':'); 00122 if (kolonPos==-1) 00123 scopeName = scopeString; 00124 else 00125 { 00126 scopeName = scopeString.left(kolonPos).simplifyWhiteSpace(); 00127 scopeRest = scopeString.right(scopeString.length()-kolonPos-1); 00128 } 00129 } 00130 } 00131 00136 FileBuffer* FileBuffer::getSubBuffer(QString scopeString) 00137 //======================================================= 00138 { 00139 QString nextScopeName,scopeStringRest; 00140 splitScopeString(scopeString,nextScopeName,scopeStringRest); 00141 if (nextScopeName.isEmpty()) 00142 return this; 00143 int idx = findChildBuffer(nextScopeName); 00144 if (idx==-1) 00145 return NULL; 00146 return m_subBuffers[idx]->getSubBuffer(scopeStringRest); 00147 } 00148 00152 void FileBuffer::setValues(const QString &variable,QStringList values,FileBuffer::ValueSetMode append, int valuesPerRow) 00153 //====================================================================================================================== 00154 { 00155 unsigned int i; 00156 QString line; 00157 ValuesIgnore* valIgnore = getValuesIgnore(variable); 00158 if (append == VSM_APPEND) 00159 { 00160 line = variable + " += "; 00161 values += valIgnore->values; 00162 } 00163 else if (append == VSM_RESET) 00164 { 00165 line = variable + " = "; 00166 values += valIgnore->values; 00167 } 00168 else if (append == VSM_EXCLUDE) 00169 { 00170 line = variable + " -= "; 00171 values += valIgnore->values_exclude; 00172 } 00173 QString spacing; 00174 spacing.fill(' ',line.length()); 00175 00176 for (i=0; i<values.count(); ++i) 00177 { 00178 line = line + values[i] + " "; 00179 if (!((i+1) % valuesPerRow)) 00180 { 00181 if (i != values.count()-1) 00182 line = line + "\\"; 00183 m_buffer.append(line); 00184 line = spacing; 00185 } 00186 } 00187 00188 if (i % valuesPerRow) 00189 m_buffer.append(line); 00190 } 00191 00196 /* 00197 bool FileBuffer::getValues(const QString &variable,QStringList &plusList, QStringList &minusList) 00198 //=============================================================================================== 00199 { 00200 Caret curPos(0,0); 00201 QString valueString=""; 00202 bool finished = false; 00203 while (!finished) 00204 { 00205 Caret variablePos(findInBuffer(variable,curPos)); 00206 if (variablePos==Caret(-1,-1)) 00207 { 00208 finished=true; 00209 continue; 00210 } 00211 Caret eqSign = findInBuffer("=",variablePos); 00212 QString line=m_buffer[eqSign.m_row]; 00213 if (line[eqSign.m_idx-1]=='-') 00214 { 00215 } 00216 if (line[eqSign.m_idx-1]!='+') 00217 valueString = ""; 00218 else 00219 valueString = valueString + " "; 00220 int lineNum=eqSign.m_row; 00221 line = line.mid(eqSign.m_idx+1,line.length()-eqSign.m_idx); 00222 while (line!="") 00223 { 00224 if (line[line.length()-1]=='\\') 00225 { 00226 valueString = valueString + line.left(line.length()-1) + " "; 00227 lineNum++; 00228 line = m_buffer[lineNum]; 00229 continue; 00230 } 00231 valueString = valueString + line; 00232 line = ""; 00233 } 00234 curPos = Caret(lineNum+1,0); 00235 } 00236 return valueString.simplifyWhiteSpace(); 00237 } 00238 */ 00239 00244 bool FileBuffer::getValues(const QString &variable, QStringList &plusList, QStringList &minusList) 00245 //======================================================================================================= 00246 { 00247 Caret curPos(0,0); 00248 QStringList plusValues; 00249 QStringList minusValues; 00250 QStringList curValues; 00251 QStringList curValuesIgnore; 00252 bool finished = false; 00253 while (!finished) 00254 { 00255 Caret variablePos(findInBuffer(variable,curPos,false,true)); 00256 if (variablePos==Caret(-1,-1)) 00257 { 00258 finished=true; 00259 continue; 00260 } 00261 Caret eqSign = findInBuffer("=",variablePos); 00262 if (eqSign.m_row != variablePos.m_row) 00263 { 00264 curPos = Caret(variablePos)+Caret(1,0); 00265 continue; 00266 } 00267 QString line=m_buffer[eqSign.m_row]; 00268 QChar effectOperator = line[eqSign.m_idx-1]; 00269 int lineNum=eqSign.m_row; 00270 curValues.clear(); 00271 curValuesIgnore.clear(); 00272 line = line.mid(eqSign.m_idx+1,line.length()-eqSign.m_idx); 00273 filterOutIgnoreValues(line,curValuesIgnore); 00274 while (!line.isEmpty()) 00275 { 00276 if (line[line.length()-1]=='\\') 00277 { 00278 line = line.left(line.length()-1).simplifyWhiteSpace(); 00279 curValues += QStringList::split(" ",line); 00280 lineNum++; 00281 line = m_buffer[lineNum]; 00282 filterOutIgnoreValues(line,curValuesIgnore); 00283 continue; 00284 } 00285 curValues += QStringList::split(" ",line); 00286 line = ""; 00287 } 00288 if (QString("+-*~").find(effectOperator)==-1) 00289 { 00290 // operator = resets the variable values 00291 00292 getValuesIgnore(variable)->values.clear(); 00293 getValuesIgnore(variable)->values_exclude.clear(); 00294 plusValues.clear(); 00295 minusValues.clear(); 00296 } 00297 if (effectOperator=='-') 00298 { 00299 // remove from plus list if in curvalues 00300 for (uint i=0; i<curValues.count(); ++i) 00301 plusValues.remove(curValues[i]); 00302 // remove from plus list if in curvaluesignore 00303 for (uint i=0; i<curValuesIgnore.count(); ++i) 00304 getValuesIgnore(variable)->values.remove(curValuesIgnore[i]); 00305 // add curvalues to minuslist 00306 getValuesIgnore(variable)->values_exclude += curValuesIgnore; 00307 minusValues += curValues; 00308 } 00309 else 00310 { 00311 // remove from minus list if in curvalues 00312 for (uint i=0; i<curValues.count(); ++i) 00313 minusValues.remove(curValues[i]); 00314 // remove from minus list if in curvaluesignore 00315 for (uint i=0; i<curValuesIgnore.count(); ++i) 00316 getValuesIgnore(variable)->values_exclude.remove(curValuesIgnore[i]); 00317 // add curvalues to pluslist 00318 getValuesIgnore(variable)->values += curValuesIgnore; 00319 plusValues += curValues; 00320 } 00321 curPos = Caret(lineNum+1,0); 00322 } 00323 plusList = plusValues; 00324 minusList = minusValues; 00325 return true; 00326 } 00327 00331 void FileBuffer::getVariableValueSetModes(const QString &variable,QPtrList<FileBuffer::ValueSetMode> &modes) 00332 //======================================================================================================= 00333 { 00334 Caret curPos(0,0); 00335 bool finished = false; 00336 00337 for (int i=0; !finished; ++i) 00338 { 00339 Caret variablePos(findInBuffer(variable,curPos,false,true)); 00340 if (variablePos==Caret(-1,-1)) 00341 { 00342 finished=true; 00343 continue; 00344 } 00345 00346 Caret eqSign = findInBuffer("=",variablePos); 00347 if (eqSign.m_row != variablePos.m_row) 00348 { 00349 curPos = Caret(variablePos)+Caret(1,0); 00350 continue; 00351 } 00352 00353 QString line=m_buffer[eqSign.m_row]; 00354 QChar effectOperator = line[eqSign.m_idx-1]; 00355 int lineNum=eqSign.m_row; 00356 line = line.mid(eqSign.m_idx+1,line.length()-eqSign.m_idx); 00357 while (!line.isEmpty()) 00358 { 00359 if (line[line.length()-1]=='\\') 00360 { 00361 line = line.left(line.length()-1).simplifyWhiteSpace(); 00362 lineNum++; 00363 line = m_buffer[lineNum]; 00364 continue; 00365 } 00366 line = ""; 00367 } 00368 00369 if (QString("+-*~").find(effectOperator)==-1) 00370 { 00371 modes.append(new ValueSetMode(VSM_RESET)); 00372 } 00373 if (effectOperator=='-') 00374 { 00375 modes.append(new ValueSetMode(VSM_EXCLUDE)); 00376 } 00377 else 00378 { 00379 modes.append(new ValueSetMode(VSM_APPEND)); 00380 } 00381 curPos = Caret(lineNum+1,0); 00382 } 00383 } 00384 00388 void FileBuffer::removeValues(const QString &variable) 00389 //=============================================================================== 00390 { 00391 Caret curPos = Caret(0,0); 00392 bool finished = false; 00393 while (!finished) 00394 { 00395 Caret variablePos = findInBuffer(variable,curPos,false,true); 00396 if (variablePos==Caret(-1,-1)) 00397 { 00398 finished = true; 00399 continue; 00400 } 00401 QString line = pop(variablePos.m_row); 00402 while (line[line.length()-1]=='\\') 00403 { 00404 line = pop(variablePos.m_row); 00405 if (line.isNull()) 00406 break; 00407 } 00408 } 00409 } 00410 00414 void FileBuffer::bufferFile(const QString &fileName) 00415 //================================================== 00416 { 00417 m_buffer.clear(); 00418 QFile dataFile(fileName); 00419 if (dataFile.open(IO_ReadOnly)) 00420 { 00421 QTextStream inStream( &dataFile ); 00422 QString inLine; 00423 while ( !inStream.eof() ) 00424 { 00425 inLine = inStream.readLine(); 00426 inLine = inLine.simplifyWhiteSpace(); 00427 m_buffer.append(inLine); 00428 } 00429 } 00430 dataFile.close(); 00431 removeComments(); 00432 } 00433 00437 void FileBuffer::saveBuffer(const QString &filename,const QString &qmakeHeader) 00438 //================================================== 00439 { 00440 QFile dataFile(filename); 00441 QStringList writeBuffer; 00442 writeBuffer.append(qmakeHeader); 00443 writeBuffer += getBufferTextInDepth(); 00444 if (dataFile.open(IO_WriteOnly)) 00445 { 00446 for (unsigned int i=0; i<writeBuffer.count(); ++i) 00447 if (!writeBuffer[i].simplifyWhiteSpace().isEmpty()) 00448 dataFile.writeBlock((writeBuffer[i]+"\n").ascii(),(writeBuffer[i]+"\n").length()); 00449 } 00450 } 00451 00458 void FileBuffer::makeScope(const QString &scopeString) 00459 //==================================================== 00460 { 00461 FileBuffer *subBuffer; 00462 QString nextScopeName,scopeStringRest; 00463 splitScopeString(scopeString,nextScopeName,scopeStringRest); 00464 if (nextScopeName.isEmpty()) 00465 return; 00466 // next scope in nested scopeString 00467 int idx = findChildBuffer(nextScopeName); 00468 00469 if (idx==-1) 00470 { 00471 // scope did not exist (create it) 00472 subBuffer = new FileBuffer(); 00473 subBuffer->setScopeName(nextScopeName); 00474 m_subBuffers.append(subBuffer); 00475 } 00476 else 00477 subBuffer = m_subBuffers[idx]; 00478 subBuffer->makeScope(scopeStringRest); 00479 } 00480 00481 QStringList FileBuffer::getBufferTextInDepth() 00482 //======================================== 00483 { 00484 QStringList resBuffer = m_buffer; 00485 for (unsigned int i=0; i<m_subBuffers.count(); ++i) 00486 { 00487 resBuffer.append(m_subBuffers[i]->getScopeName() + "{"); 00488 QStringList subBuffer = m_subBuffers[i]->getBufferTextInDepth(); 00489 for (unsigned int j=0; j<subBuffer.count(); j++) 00490 subBuffer[j] = " " + subBuffer[j]; 00491 resBuffer += subBuffer; 00492 resBuffer.append("}"); 00493 } 00494 return resBuffer; 00495 } 00496 00497 void FileBuffer::dumpBuffer() 00498 //=========================== 00499 { 00500 for ( unsigned int i=0; i<m_buffer.count(); ++i ) 00501 printf("%s\n", m_buffer[i].latin1()); 00502 } 00503 00504 Caret FileBuffer::findScopeEnd(Caret pos) 00505 //======================================= 00506 { 00507 int scopeDepth=1; 00508 while (scopeDepth) 00509 { 00510 Caret nextScopeStart = findInBuffer("{",pos,true); 00511 Caret nextScopeEnd = findInBuffer("}",pos,true); 00512 if (nextScopeStart < nextScopeEnd) 00513 { 00514 ++scopeDepth; 00515 pos = nextScopeStart + Caret(0,1); 00516 } 00517 else 00518 { 00519 --scopeDepth; 00520 pos = nextScopeEnd + Caret(0,1); 00521 } 00522 if (nextScopeStart==nextScopeEnd) 00523 return Caret(-1,-1); 00524 } 00525 return pos - Caret(0,1); 00526 } 00527 00528 bool FileBuffer::findNextScope(const Caret &startSearch, Caret& scopeStart, Caret& scopeEnd) 00529 //==================================================================================== 00530 { 00531 scopeStart = findInBuffer("{",startSearch); 00532 if (scopeStart==Caret(-1,-1)) 00533 return false; 00534 scopeEnd = findScopeEnd(scopeStart+Caret(0,1)); 00535 if (scopeEnd==Caret(-1,-1)) 00536 return false; 00537 return true; 00538 } 00539 00540 QStringList FileBuffer::copyBlock(const Caret &blockStart, const Caret &blockEnd) 00541 //=============================================================================== 00542 { 00543 QStringList result; 00544 QString tmp = m_buffer[blockStart.m_row]; 00545 result.append(tmp.right(tmp.length()-blockStart.m_idx)); 00546 for (int i=blockStart.m_row+1; i<blockEnd.m_row; ++i) 00547 result.append(m_buffer[i]); 00548 tmp = m_buffer[blockEnd.m_row]; 00549 result.append(tmp.left(blockEnd.m_idx+1)); 00550 return result; 00551 } 00552 00553 QStringList FileBuffer::popBlock(const Caret &blockStart, const Caret &blockEnd) 00554 //=============================================================================== 00555 { 00556 QStringList result = copyBlock(blockStart,blockEnd); 00557 int poprow; 00558 if (blockStart.m_idx==0) 00559 { 00560 pop(blockStart.m_row); 00561 poprow=blockStart.m_row; 00562 } 00563 else 00564 { 00565 m_buffer[blockStart.m_row] = m_buffer[blockStart.m_row].left(blockStart.m_idx); 00566 poprow = blockStart.m_row+1; 00567 } 00568 for (int i=0; i<blockEnd.m_row-blockStart.m_row-1; ++i) 00569 pop(poprow); 00570 QString tmp = m_buffer[poprow]; 00571 if (blockEnd.m_idx >= (int) tmp.length()-1) 00572 pop(poprow); 00573 else 00574 m_buffer[poprow] = tmp.right(tmp.length()-blockEnd.m_idx-1); 00575 return result; 00576 } 00577 00583 bool FileBuffer::handleScopes() 00584 //============================= 00585 { 00586 bool parseError = false; 00587 unsigned int i; 00588 Caret pos(0,0); 00589 // Bracket scopes 00590 while (true) 00591 { 00592 Caret startScope,endScope; 00593 if (!findNextScope(pos,startScope,endScope)) 00594 break; 00595 pos = Caret(startScope.m_row,0); 00596 // is it a qmake valid scope ident | ident1:ident2:...:identn 00597 if (startScope.m_idx==0) 00598 { 00599 break; 00600 parseError = true; 00601 } 00602 00603 QStringList subBuffer; 00604 QString tmp = m_buffer[startScope.m_row]; 00605 QStringList scopeNames = QStringList::split(":",tmp.left(startScope.m_idx)); 00606 // clean-up scopenames 00607 for (i=0;i<scopeNames.count();++i) 00608 scopeNames[i]=scopeNames[i].simplifyWhiteSpace(); 00609 if (scopeNames.count()>1) 00610 { 00611 // nested scopename 00612 QString subBufferPrefix = scopeNames[1]; 00613 for (i=2;i<scopeNames.count();++i) 00614 subBufferPrefix = subBufferPrefix + ":" + scopeNames[i]; 00615 subBuffer = popBlock(startScope,endScope); 00616 subBuffer[0] = subBufferPrefix + subBuffer[0]; 00617 } 00618 else 00619 { 00620 subBuffer = popBlock(startScope,endScope); 00621 // remove start and end brakets 00622 tmp = subBuffer[0]; 00623 subBuffer[0] = tmp.right(tmp.length()-1); 00624 tmp = subBuffer[subBuffer.count()-1]; 00625 subBuffer[subBuffer.count()-1] = tmp.left(tmp.length()-1); 00626 } 00627 00628 // clear scopenesting 00629 pop(startScope.m_row); 00630 int subBufferIdx = findChildBuffer(scopeNames[0]); 00631 FileBuffer *subBufferObject; 00632 if (subBufferIdx==-1) 00633 { 00634 subBufferObject = new FileBuffer(); 00635 m_subBuffers.append(subBufferObject); 00636 } 00637 else 00638 subBufferObject = m_subBuffers[subBufferIdx]; 00639 subBufferObject->setScopeName(scopeNames[0]); 00640 subBufferObject->appendBufferText(subBuffer); 00641 subBufferObject->handleScopes(); 00642 } 00643 //Non bracket scopes 00644 pos = Caret(0,0); 00645 while (true) 00646 { 00647 Caret kolonPos = findInBuffer(":",pos); 00648 if (kolonPos == Caret(-1,-1)) 00649 break; 00650 QString scopeLine = pop(kolonPos.m_row); 00651 int equalPos = scopeLine.find('=',kolonPos.m_idx); 00652 if (equalPos == -1) 00653 { 00654 // Parse error 00655 parseError = true; 00656 break; 00657 } 00658 int idxScopeStringEnd = scopeLine.findRev(':',equalPos); 00659 QString scopeString = scopeLine.left(idxScopeStringEnd); 00660 scopeLine = scopeLine.right(scopeLine.length()-idxScopeStringEnd-1); 00661 scopeLine = scopeLine.simplifyWhiteSpace(); 00662 makeScope(scopeString); 00663 FileBuffer *subBufferObject = getSubBuffer(scopeString); 00664 subBufferObject->appendBufferText(scopeLine); 00665 while (scopeLine[scopeLine.length()-1] == '\\') 00666 { 00667 scopeLine = pop(kolonPos.m_row); 00668 scopeLine = scopeLine.simplifyWhiteSpace(); 00669 subBufferObject->appendBufferText(scopeLine); 00670 } 00671 pos = Caret(kolonPos.m_row,0); 00672 } 00673 return parseError; 00674 } 00675 00676 int FileBuffer::findChildBuffer(const QString &scopeName) 00677 //============================================================== 00678 { 00679 for (unsigned int i=0; i<m_subBuffers.count(); ++i) 00680 if (m_subBuffers[i]->getScopeName()==scopeName) 00681 return i; 00682 return -1; 00683 } 00684 00685 QStringList FileBuffer::getAllScopeStrings(int depth) 00686 //================================================== 00687 { 00688 QStringList result; 00689 unsigned int i; 00690 for (i=0; i<m_subBuffers.count(); ++i) 00691 result += m_subBuffers[i]->getAllScopeStrings(depth+1); 00692 if (depth) 00693 { 00694 for (i=0; i<result.count(); ++i) 00695 result[i] = getScopeName() + ":" + result[i]; 00696 result.append(getScopeName()); 00697 } 00698 return result; 00699 } 00700 00701 QStringList FileBuffer::getAllScopeNames(int depth) 00702 //================================================ 00703 { 00704 QStringList result; 00705 unsigned int i; 00706 for (i=0; i<m_subBuffers.count(); ++i) 00707 result += m_subBuffers[i]->getAllScopeNames(depth+1); 00708 if (!depth) 00709 { 00710 for (i=0; i<result.count(); ++i) 00711 { 00712 QString scopeName = result[0]; 00713 result.remove(scopeName); 00714 result.append(scopeName); 00715 } 00716 } 00717 else 00718 { 00719 QString tmpScopeName = getScopeName(); 00720 // remove negation 00721 if (tmpScopeName[0]=='!') 00722 tmpScopeName = tmpScopeName.right(tmpScopeName.length()-1); 00723 result.append(tmpScopeName); 00724 } 00725 return result; 00726 00727 } 00728 00729 QStringList FileBuffer::getChildScopeNames() 00730 //======================================== 00731 { 00732 QStringList result; 00733 for (unsigned int i=0; i<m_subBuffers.count(); ++i) 00734 result += m_subBuffers[i]->getScopeName(); 00735 return result; 00736 } 00737 00738 bool FileBuffer::getAllExcludeValues(const QString &variable,QStringList &minusValues, int depth) 00739 //============================================================================================== 00740 { 00741 unsigned int i; 00742 QStringList plusDummy,minusTmp; 00743 for (i=0; i<m_subBuffers.count(); ++i) 00744 m_subBuffers[i]->getAllExcludeValues(variable,minusValues,depth+1); 00745 if (depth) 00746 { 00747 for (i=0; i<minusValues.count(); ++i) 00748 minusValues[i] = getScopeName() + ":" + minusValues[i]; 00749 } 00750 getValues(variable,plusDummy,minusTmp); 00751 for (i=0; i<minusTmp.count(); ++i) 00752 minusTmp[i] = getScopeName() + "-" + minusTmp[i]; 00753 minusValues += minusTmp; 00754 return true; 00755 } 00756 00757 00758 void FileBuffer::filterOutIgnoreValues(QString& line,QStringList& valuesignore) 00759 //===================================================================================================== 00760 { 00761 QStringList qmakeFunctions = 00762 QStringList::split(',',"join(,member(,find(,contains(,count(,error(,exists(," 00763 "include(,isEmpty(,system(,message(,infile("); 00764 00765 int len=0; 00766 int closestMatch = -1; 00767 for (uint i=0; i<qmakeFunctions.count(); ++i) 00768 { 00769 int match = line.find(qmakeFunctions[i],0); 00770 if (match==-1) 00771 continue; 00772 if(closestMatch==-1 || 00773 closestMatch>match) 00774 { 00775 closestMatch = match; 00776 len=qmakeFunctions[i].length(); 00777 } 00778 } 00779 int startpos = closestMatch; 00780 00781 while (startpos>-1) 00782 { 00783 int bracketCount=1; 00784 while (bracketCount>0 && startpos+len<(int)line.length()) 00785 { 00786 if (line[startpos+len]=='(') 00787 ++bracketCount; 00788 if (line[startpos+len]==')') 00789 --bracketCount; 00790 ++len; 00791 } 00792 00793 valuesignore.append(line.mid(startpos,len)); 00794 line = line.left(startpos)+line.right(line.length()-startpos-len); 00795 00796 closestMatch=-1; 00797 for (uint i=0; i<qmakeFunctions.count(); ++i) 00798 { 00799 int match = line.find(qmakeFunctions[i],startpos); 00800 if (match==-1) 00801 continue; 00802 if(closestMatch==-1 || 00803 closestMatch>match) 00804 { 00805 closestMatch = match; 00806 len=qmakeFunctions[i].length(); 00807 } 00808 } 00809 startpos = closestMatch; 00810 } 00811 00812 } 00813 00814 ValuesIgnore* FileBuffer::getValuesIgnore(const QString &variable) 00815 //================================================================ 00816 { 00817 ValuesIgnoreList::iterator it; 00818 for ( it = m_valuesIgnore.begin(); it != m_valuesIgnore.end(); ++it ) 00819 if ((*it)->variable == variable) 00820 return (*it); 00821 ValuesIgnore* newVar = new ValuesIgnore; 00822 newVar->variable = variable; 00823 m_valuesIgnore.append(newVar); 00824 return newVar; 00825 } 00826 00827 void FileBuffer::removeScope( const QString & scopeString, const QString &removeString, QStringList buffer ) 00828 { 00829 FileBuffer *subBuffer; 00830 QString nextScopeName,scopeStringRest; 00831 splitScopeString(scopeString,nextScopeName,scopeStringRest); 00832 if (nextScopeName.isEmpty()) 00833 return; 00834 // next scope in nested scopeString 00835 int idx = findChildBuffer(nextScopeName); 00836 00837 if (idx == -1) 00838 return; 00839 else 00840 { 00841 buffer.append(nextScopeName); 00842 subBuffer = m_subBuffers[idx]; 00843 if (buffer.join(":") == removeString) 00844 { 00845 m_subBuffers.remove(subBuffer); 00846 delete subBuffer; 00847 } 00848 else 00849 subBuffer->removeScope(scopeStringRest, removeString, buffer); 00850 } 00851 }
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:37 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003