本文整理汇总了C++中QValueStack::pop方法的典型用法代码示例。如果您正苦于以下问题:C++ QValueStack::pop方法的具体用法?C++ QValueStack::pop怎么用?C++ QValueStack::pop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QValueStack
的用法示例。
在下文中一共展示了QValueStack::pop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isLast
bool QExp::isLast(QValueStack<char> opr){
int ins=0;
bool b=true;
while(b && !opr.empty()){
if(opr.top()==tLpr){
if(ins == 0)
b= true;
else
ins--;
} else if(opr.top()==tLpr)
ins++;
else if(opr.top()==tComa)
b= false;
else if(opr.top()==tEof)
b= false;
opr.pop();
}
return b;
}
示例2: populateProject
void AntProjectPart::populateProject()
{
QApplication::setOverrideCursor(Qt::waitCursor);
QValueStack<QString> s;
int prefixlen = m_projectDirectory.length()+1;
s.push(m_projectDirectory);
QDir dir;
do
{
dir.setPath(s.pop());
kdDebug() << "Examining: " << dir.path() << endl;
const QFileInfoList *dirEntries = dir.entryInfoList();
QPtrListIterator<QFileInfo> it(*dirEntries);
for (; it.current(); ++it)
{
QString fileName = it.current()->fileName();
if (fileName == "." || fileName == "..")
continue;
QString path = it.current()->absFilePath();
if (it.current()->isDir())
{
kdDebug() << "Pushing: " << path << endl;
s.push(path);
}
else
{
kdDebug() << "Adding: " << path << endl;
m_sourceFiles.append(path.mid(prefixlen));
}
}
}
while (!s.isEmpty());
QApplication::restoreOverrideCursor();
}
示例3: parse
/**
\internal
*/
bool GetOpt::parse( bool untilFirstSwitchOnly )
{
// qDebug( "parse(%s)", args.join( QString( "," ) ).ascii() );
// push all arguments as we got them on a stack
// more pushes might following when parsing condensed arguments
// like --key=value.
QValueStack<QString> stack;
{
QStringList::const_iterator it = args.fromLast();
const QStringList::const_iterator end = args.end();
while ( it != end ) {
stack.push( *it );
--it;
}
}
const OptionConstIterator obegin = options.begin();
const OptionConstIterator oend = options.end();
enum { StartState, ExpectingState, OptionalState } state = StartState;
Option currOpt;
enum TokenType { LongOpt, ShortOpt, Arg, End } t, currType = End;
bool extraLoop = true; // we'll do an extra round. fake an End argument
while ( !stack.isEmpty() || extraLoop ) {
QString a;
QString origA;
// identify argument type
if ( !stack.isEmpty() ) {
a = stack.pop();
currArg++;
origA = a;
// qDebug( "popped %s", a.ascii() );
if ( a.startsWith( QString::fromLatin1( "--" ) ) ) {
// recognized long option
a = a.mid( 2 );
if ( a.isEmpty() ) {
qWarning( "'--' feature not supported, yet" );
exit( 2 );
}
t = LongOpt;
// split key=value style arguments
int equal = a.find( '=' );
if ( equal >= 0 ) {
stack.push( a.mid( equal + 1 ) );
currArg--;
a = a.left( equal );
}
} else if ( a.length() == 1 ) {
t = Arg;
} else if ( a[0] == '-' ) {
#if 0 // compat mode for -long style options
if ( a.length() == 2 ) {
t = ShortOpt;
a = a[1];
} else {
a = a.mid( 1 );
t = LongOpt;
// split key=value style arguments
int equal = a.find( '=' );
if ( equal >= 0 ) {
stack.push( a.mid( equal + 1 ) );
currArg--;
a = a.left( equal );
}
}
#else
// short option
t = ShortOpt;
// followed by an argument ? push it for later processing.
if ( a.length() > 2 ) {
stack.push( a.mid( 2 ) );
currArg--;
}
a = a[1];
#endif
} else {
t = Arg;
}
} else {
// faked closing argument
t = End;
}
// look up among known list of options
Option opt;
if ( t != End ) {
OptionConstIterator oit = obegin;
while ( oit != oend ) {
const Option &o = *oit;
if ( ( t == LongOpt && a == o.lname ) || // ### check state
( t == ShortOpt && a[0].unicode() == o.sname ) ) {
opt = o;
break;
}
++oit;
}
if ( t == LongOpt && opt.type == OUnknown ) {
if ( currOpt.type != OVarLen ) {
qWarning( "Unknown option --%s", a.ascii() );
//.........这里部分代码省略.........
示例4: printRange
//.........这里部分代码省略.........
// Find the position range.
long startPos, endPos;
endPos = qsb->SendScintilla(QsciScintillaBase::SCI_GETLENGTH);
startPos = (from > 0 ? qsb -> SendScintilla(QsciScintillaBase::SCI_POSITIONFROMLINE,from) : 0);
if (to >= 0)
{
long toPos = qsb -> SendScintilla(QsciScintillaBase::SCI_POSITIONFROMLINE,to + 1);
if (endPos > toPos)
endPos = toPos;
}
if (startPos >= endPos)
return false;
QPainter painter(this);
bool reverse = (pageOrder() == LastPageFirst);
bool needNewPage = false;
qsb -> SendScintilla(QsciScintillaBase::SCI_SETPRINTMAGNIFICATION,mag);
qsb -> SendScintilla(QsciScintillaBase::SCI_SETPRINTWRAPMODE,wrap);
for (int i = 1; i <= numCopies(); ++i)
{
// If we are printing in reverse page order then remember the start
// position of each page.
QValueStack<long> pageStarts;
int currPage = 1;
long pos = startPos;
while (pos < endPos)
{
// See if we have finished the requested page range.
if (pgTo > 0 && pgTo < currPage)
break;
// See if we are going to render this page, or just see how much
// would fit onto it.
bool render = false;
if (pgFrom == 0 || pgFrom <= currPage)
{
if (reverse)
pageStarts.push(pos);
else
{
render = true;
if (needNewPage)
{
if (!newPage())
return false;
}
else
needNewPage = true;
}
}
QRect area = def_area;
formatPage(painter,render,area,currPage);
pos = qsb -> SendScintilla(QsciScintillaBase::SCI_FORMATRANGE,render,&painter,area,pos,endPos);
++currPage;
}
// All done if we are printing in normal page order.
if (!reverse)
continue;
// Now go through each page on the stack and really print it.
while (!pageStarts.isEmpty())
{
--currPage;
long ePos = pos;
pos = pageStarts.pop();
if (needNewPage)
{
if (!newPage())
return false;
}
else
needNewPage = true;
QRect area = def_area;
formatPage(painter,true,area,currPage);
qsb->SendScintilla(QsciScintillaBase::SCI_FORMATRANGE,true,&painter,area,pos,ePos);
}
}
return true;
}
示例5: getToken
//.........这里部分代码省略.........
The code contains, indeed, two opening braces for
one closing brace; yet there's no reason to panic.
The solution is to remember yyBraceDepth as it was
when #if, #ifdef or #ifndef was met, and to set
yyBraceDepth to that value when meeting #elif or
#else.
*/
do {
yyCh = getChar();
} while ( isspace(yyCh) && yyCh != '\n' );
switch ( yyCh ) {
case 'i':
yyCh = getChar();
if ( yyCh == 'f' ) {
// if, ifdef, ifndef
yySavedBraceDepth.push( yyBraceDepth );
yySavedParenDepth.push( yyParenDepth );
}
break;
case 'e':
yyCh = getChar();
if ( yyCh == 'l' ) {
// elif, else
if ( !yySavedBraceDepth.isEmpty() ) {
yyBraceDepth = yySavedBraceDepth.top();
yyParenDepth = yySavedParenDepth.top();
}
} else if ( yyCh == 'n' ) {
// endif
if ( !yySavedBraceDepth.isEmpty() ) {
yySavedBraceDepth.pop();
yySavedParenDepth.pop();
}
}
}
while ( isalnum(yyCh) || yyCh == '_' )
yyCh = getChar();
break;
case '/':
yyCh = getChar();
if ( yyCh == '/' ) {
do {
yyCh = getChar();
} while ( yyCh != EOF && yyCh != '\n' );
} else if ( yyCh == '*' ) {
bool metAster = FALSE;
bool metAsterSlash = FALSE;
while ( !metAsterSlash ) {
yyCh = getChar();
if ( yyCh == EOF ) {
fprintf( stderr,
"%s: Unterminated C++ comment starting at"
" line %d\n",
(const char *) yyFileName, yyLineNo );
yyComment[yyCommentLen] = '\0';
return Tok_Comment;
}
if ( yyCommentLen < sizeof(yyComment) - 1 )
yyComment[yyCommentLen++] = (char) yyCh;
if ( yyCh == '*' )
metAster = TRUE;
示例6: paintData
//.........这里部分代码省略.........
}
// If there was no value at all, bail out, to avoid endless loops
// later on (e.g. in findPieAt()).
if( !atLeastOneValue )
return;
// Find the backmost pie which is at +90° and needs to be drawn
// first
int backmostpie = findPieAt( 90 * 16 );
// Find the frontmost pie (at -90°/+270°) that should be drawn last
int frontmostpie = findPieAt( 270 * 16 );
// and put the backmost pie on the TODO stack to initialize it,
// but only if it is not the frontmostpie
QValueStack < int > todostack;
if ( backmostpie != frontmostpie )
todostack.push( backmostpie );
else {
// Otherwise, try to find something else
int leftOfCurrent = findLeftPie( backmostpie );
if ( leftOfCurrent != frontmostpie ) {
todostack.push( leftOfCurrent );
} else {
int rightOfCurrent = findRightPie( backmostpie );
if ( rightOfCurrent != frontmostpie ) {
todostack.push( rightOfCurrent );
}
}
// If we get here, there was nothing else, and we will bail
// out of the while loop below.
}
// The list with pies that have already been drawn
QValueList < int > donelist;
// Draw pies until the todostack is empty or only the frontmost
// pie is there
while ( !todostack.isEmpty() &&
!( ( todostack.count() == 1 ) &&
( ( todostack.top() == frontmostpie ) ) ) ) {
// The while loop cannot be cancelled if frontmostpie is on
// top of the stack, but this is also backmostpie (can happen
// when one of the pies covers more than 1/2 of the circle. In
// this case, we need to find something else to put on the
// stack to get things going.
// take one pie from the stack
int currentpie = todostack.pop();
// if this pie was already drawn, ignore it
if ( donelist.find( currentpie ) != donelist.end() )
continue;
// If this pie is the frontmost pie, put it back, but at the
// second position (otherwise, there would be an endless
// loop). If this pie is the frontmost pie, there must be at
// least one other pie, otherwise the loop would already have
// been terminated by the loop condition.
if ( currentpie == frontmostpie ) {
Q_ASSERT( !todostack.isEmpty() );
// QValueStack::exchange() would be nice here...
int secondpie = todostack.pop();
if ( currentpie == secondpie )
// no need to have the second pie twice on the stack,
// forget about one instance and take the third
// instead
if ( todostack.isEmpty() )
break; // done anyway
else
secondpie = todostack.pop();
todostack.push( currentpie );
todostack.push( secondpie );
continue;
}
// When we get here, we can just draw the pie and proceed.
drawOnePie( painter, data, dataset, currentpie, chart,
sizeFor3DEffect,
regions );
// Mark the pie just drawn as done.
donelist.append( currentpie );
// Now take the pie to the left and to the right, check
// whether these have not been painted already, and put them
// on the stack.
int leftOfCurrent = findLeftPie( currentpie );
if ( donelist.find( leftOfCurrent ) == donelist.end() )
todostack.push( leftOfCurrent );
int rightOfCurrent = findRightPie( currentpie );
if ( donelist.find( rightOfCurrent ) == donelist.end() )
todostack.push( rightOfCurrent );
}
// now only the frontmost pie is left to draw
drawOnePie( painter, data, dataset, frontmostpie, chart,
sizeFor3DEffect,
regions );
}