本文整理汇总了C++中Tokens::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokens::empty方法的具体用法?C++ Tokens::empty怎么用?C++ Tokens::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokens
的用法示例。
在下文中一共展示了Tokens::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokenize
// ============================================================================
StatusCode Tuples::TupleObj::fill( const char* format ... )
{
// check the underlying tuple
if ( invalid() ) { return InvalidTuple ; }
// decode format string into tokens
Tokens tokens ;
tokenize( format , tokens , " ,;" );
if ( tokens.empty() ) { return StatusCode::SUCCESS ; }
/// decode arguments
va_list valist ;
va_start( valist , format ) ;
// loop over all tokens
StatusCode status = StatusCode::SUCCESS ;
for( Tokens::const_iterator token = tokens.begin() ;
tokens.end() != token && status.isSuccess() ; ++token )
{
const double val = va_arg( valist , double );
status = column( *token , val );
if( status.isFailure() )
{ Error ( "fill(): Can not add column '" + *token + "' " ) ; }
}
// mandatory !!!
va_end( valist );
//
return status ;
}
示例2: ProcessCommand
void Session::ProcessCommand(const std::string &input)
{
Tokens tokens;
Tokenizer(input, tokens);
if (!tokens.empty())
ProcessCommand(std::move(tokens));
}
示例3: selectionChanged
// Called on selection (and sheet) changes.
void CellEditor::selectionChanged()
{
if (d->selectionChangedLocked) {
return;
}
Selection* choice = selection();
if (choice->isEmpty())
return;
const QString text = toPlainText();
const int textLength = text.length();
// Find the start text cursor position for the active sub-region within
// the formula's expression and determine the length of the sub-region.
Tokens tokens = d->highlighter->formulaTokens();
uint start = 1;
uint length = 0;
if (!tokens.empty()) {
if (d->currentToken < tokens.count()) {
Token token = tokens[d->currentToken];
Token::Type type = token.type();
if (type == Token::Cell || type == Token::Range) {
start = token.pos() + 1; // don't forget the '='!
length = token.text().length();
// Iterate to the end of the sub-region.
for (int i = d->currentToken + 1; i < tokens.count(); ++i) {
token = tokens[i];
type = token.type();
switch (type) {
case Token::Cell:
case Token::Range:
length += token.text().length();
continue;
case Token::Operator:
if (token.asOperator() == Token::Semicolon) {
++length;
continue;
}
default:
break;
}
break;
}
} else {
start = token.pos() + 1; // don't forget the '='!
length = token.text().length();
}
} else {
// sanitize
d->currentToken = tokens.count();
start = textLength;
}
}
// Replace the formula's active sub-region with the selection's one.
const QString address = choice->activeSubRegionName();
const QString newExpression = QString(text).replace(start, length, address);
// The expression highlighting gets updated automatically by the next call,
// even though signals are blocked (must be connected to QTextDocument).
blockSignals(true);
setText(newExpression, start + address.length());
blockSignals(false);
// Ranges have changed.
// Reset the flag, that indicates range changes after text changes.
d->highlighter->resetRangeChanged();
// Mirror the behaviour of slotCursorPositionChanged(), but here the tokens
// are already up-to-date.
d->globalCursorPos = mapToGlobal(cursorRect().bottomLeft());
// Set the active sub-region.
// Needs up-to-date tokens; QSyntaxHighlighter::rehighlight() gets called
// automatically on text changes, which does the update.
d->updateActiveSubRegion(d->highlighter->formulaTokens());
// Always emit, because this editor may be hidden or does not have focus,
// but the external one needs an update.
emit textChanged(toPlainText());
}