当前位置: 首页>>代码示例>>C++>>正文


C++ Tokens::empty方法代码示例

本文整理汇总了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 ;
}
开发者ID:atlas-org,项目名称:gaudi,代码行数:27,代码来源:TupleObj.cpp

示例2: ProcessCommand

	void Session::ProcessCommand(const std::string &input)
	{
		Tokens tokens;
		Tokenizer(input, tokens);
		if (!tokens.empty())
			ProcessCommand(std::move(tokens));
	}
开发者ID:Ilya87,项目名称:android-file-transfer-linux,代码行数:7,代码来源:Session.cpp

示例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());
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:81,代码来源:CellEditor.cpp


注:本文中的Tokens::empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。