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


C++ QChar::isDigit方法代码示例

本文整理汇总了C++中QChar::isDigit方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isDigit方法的具体用法?C++ QChar::isDigit怎么用?C++ QChar::isDigit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QChar的用法示例。


在下文中一共展示了QChar::isDigit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QString

QString QWsServer::computeAcceptV0( QString key1, QString key2, QString key3 )
{
	QString numStr1;
	QString numStr2;

	QChar carac;
	for ( int i=0 ; i<key1.size() ; i++ )
	{
		carac = key1[ i ];
		if ( carac.isDigit() )
			numStr1.append( carac );
	}
	for ( int i=0 ; i<key2.size() ; i++ )
	{
	    carac = key2[ i ];
		if ( carac.isDigit() )
			numStr2.append( carac );
	}

	quint32 num1 = numStr1.toUInt();
	quint32 num2 = numStr2.toUInt();

	int numSpaces1 = key1.count( ' ' );
	int numSpaces2 = key2.count( ' ' );

	num1 /= numSpaces1;
	num2 /= numSpaces2;

	QString concat = serializeInt( num1 ) + serializeInt( num2 ) + key3;

    QByteArray md5 = QCryptographicHash::hash( concat.toLatin1(), QCryptographicHash::Md5 );
  
	return QString( md5 );
}
开发者ID:Airisu,项目名称:pokemon-online,代码行数:34,代码来源:QWsServer.cpp

示例2: naturalSort

bool misc::naturalSort(QString left, QString right, bool &result) { // uses lessThan comparison
  // Return value indicates if functions was successful
  // result argument will contain actual comparison result if function was successful
  int posL = 0;
  int posR = 0;
  do {
    for (;;) {
      if (posL == left.size() || posR == right.size())
        return false; // No data

      QChar leftChar = left.at(posL);
      QChar rightChar = right.at(posR);
      bool leftCharIsDigit = leftChar.isDigit();
      bool rightCharIsDigit = rightChar.isDigit();
      if (leftCharIsDigit != rightCharIsDigit)
        return false; // Digit positions mismatch

      if (leftCharIsDigit)
        break; // Both are digit, break this loop and compare numbers

      if (leftChar != rightChar)
         return false; // Strings' subsets before digit do not match

      ++posL;
      ++posR;
    }

    QString temp;
    while (posL < left.size()) {
      if (left.at(posL).isDigit())
        temp += left.at(posL);
      else
        break;
      posL++;
    }
    int numL = temp.toInt();
    temp.clear();

    while (posR < right.size()) {
      if (right.at(posR).isDigit())
        temp += right.at(posR);
      else
        break;
      posR++;
    }
    int numR = temp.toInt();

    if (numL != numR) {
      result = (numL < numR);
      return true;
    }

    // Strings + digits do match and we haven't hit string end
    // Do another round

  } while (true);

  return false;
}
开发者ID:Ogene,项目名称:qBittorrent,代码行数:59,代码来源:misc.cpp

示例3: getWordUnderCursor

/**
 * Returns a the complete word defined by the current cursor position.
 * Attempts to extract a valid C symbol from the location of the cursor, by
 * starting at the current line and column, and looking forward and backward
 * for non-symbol characters.
 * @return	A C symbol under the cursor, if any, or QString::null otherwise
 */
QString EditorPage::getWordUnderCursor(uint* pPosInWord)
{
	KTextEditor::ViewCursorInterface* pCursor;
	KTextEditor::EditInterface* pEditIf;
	QString sLine;
	uint nLine, nCol, nFrom, nTo, nLast, nLength;
	QChar ch;

	// Get a cursor object
	pCursor = dynamic_cast<KTextEditor::ViewCursorInterface*>(m_pView);
	if (pCursor == NULL)
		return QString::null;

	// Get a pointer to the edit interface	
	pEditIf = dynamic_cast<KTextEditor::EditInterface*>(m_pDoc);
	if (!pEditIf)
		return QString::null;
	
	// Get the line on which the cursor is positioned
	pCursor->cursorPositionReal(&nLine, &nCol);
	sLine = pEditIf->textLine(nLine);
	
	// Find the beginning of the current word
	for (nFrom = nCol; nFrom > 0;) {
		ch = sLine.at(nFrom - 1);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nFrom--;
	}
	
	// Find the end of the current word
	nLast = sLine.length();
	for (nTo = nCol; nTo < nLast;) {
		ch = sLine.at(nTo);
		if (!ch.isLetter() && !ch.isDigit() && ch != '_')
			break;
		
		nTo++;
	}
	
	// Mark empty words
	nLength = nTo - nFrom;
	if (nLength == 0)
		return QString::null;
	
	// Return the in-word position, if required
	if (pPosInWord != NULL)
		*pPosInWord = nCol - nFrom;
	
	// Extract the word under the cursor from the entire line
	return sLine.mid(nFrom, nLength);
}
开发者ID:VicHao,项目名称:kkscope,代码行数:60,代码来源:editorpage.cpp

示例4: parseNumber

 QVariant parseNumber()
 {
     QVarLengthArray<QChar> str;
     QChar c = next();
     if(c == '-')
     {
         str.append(c);
         c = nextNoSkip();
     }
     for(; c.isDigit(); c = nextNoSkip())
     {
         str.append(c);
     }
     bool hasDecimal = false;
     if(c == '.')
     {
         str.append(c);
         hasDecimal = true;
         c = nextNoSkip();
         for(; c.isDigit(); c = nextNoSkip())
         {
             str.append(c);
         }
     }
     if(c == 'e' || c == 'E')
     {
         // Exponent.
         str.append(c);
         c = nextNoSkip();
         if(c == '+' || c == '-')
         {
             str.append(c);
             c = nextNoSkip();
         }
         for(; c.isDigit(); c = nextNoSkip())
         {
             str.append(c);
         }
     }
     // Rewind one char (the loop was broken when a non-digit was read).
     pos--;
     skipWhite();
     double value = QString(str.constData(), str.size()).toDouble();
     if(hasDecimal)
     {
         return QVariant(value);
     }
     else
     {
         return QVariant(int(value));
     }
 }
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:52,代码来源:json.cpp

示例5: isValidXmlElementName

//--------------------------------------------------------------------------------------------------
/// Check if a string is a valid Xml element name
//
/// http://www.w3schools.com/xml/xml_elements.asp
///
/// XML elements must follow these naming rules:
///   Names can contain letters, numbers, and other characters
///   Names cannot start with a number or punctuation character
///   Names cannot start with the letters xml (or XML, or Xml, etc)
///   Names cannot contain spaces
//--------------------------------------------------------------------------------------------------
bool PdmObject::isValidXmlElementName(const QString& name)
{
    if (name.size() > 0)
    {
        QChar firstChar = name[0];
        if (firstChar.isDigit() || firstChar == '.')
        {
            return false;
        }
    }

    if (name.size() >= 3)
    {
        if (name.left(3).compare("xml", Qt::CaseInsensitive) == 0)
        {
            return false;
        }
    }

    if (name.contains(' '))
    {
        return false;
    }

    return true;
}
开发者ID:joelmheim,项目名称:ResInsight,代码行数:37,代码来源:cafPdmObject.cpp

示例6: EnhancedPathReferenceParameter

EnhancedPathParameter * EnhancedPathShape::parameter(const QString & text)
{
    Q_ASSERT(! text.isEmpty());

    ParameterStore::const_iterator parameterIt = m_parameters.constFind(text);
    if (parameterIt != m_parameters.constEnd()) {
        return parameterIt.value();
    } else {
        EnhancedPathParameter *parameter = 0;
        QChar c = text[0];
        if (c.toAscii() == '$' || c.toAscii() == '?') {
            parameter = new EnhancedPathReferenceParameter(text, this);
        } else {
            if (c.isDigit()) {
                bool success = false;
                qreal constant = text.toDouble(&success);
                if (success)
                    parameter = new EnhancedPathConstantParameter(constant, this);
            } else {
                Identifier identifier = EnhancedPathNamedParameter::identifierFromString(text);
                if (identifier != IdentifierUnknown)
                    parameter = new EnhancedPathNamedParameter(identifier, this);
            }
        }

        if (parameter)
            m_parameters[text] = parameter;

        return parameter;
    }
}
开发者ID:KDE,项目名称:koffice,代码行数:31,代码来源:EnhancedPathShape.cpp

示例7: validate

QValidator::State mdtUicNumberValidator::validate(QString &input, int &pos) const
{
  QChar c;
  QString number;

  // Check if last char is valid
  if(pos > 0){
    c = input.at(pos-1);
    if((!c.isDigit())&&(c != ' ')&&(c != '-')){
      return QValidator::Invalid;
    }
  }

  // Try to build the number...

  //Remove unusable chars
  if(input.size() > 5){
    number = input.simplified();
    number.remove(" ");
    number.remove("-");
    // Check length:
    //  - We only know about 6 and 11 digits UIC numbers
    //  - If we have 7 or 12 digits, the control key is given
    if((number.size() == 6)||(number.size() == 7)||(number.size() == 11)||(number.size() == 12)){
      return QValidator::Acceptable;
    }
  }

  return QValidator::Intermediate;
}
开发者ID:xens,项目名称:multidiagtools,代码行数:30,代码来源:mdtUicNumberValidator.cpp

示例8: checkDomain

QValidator::State EmailValidator::checkDomain(const QString & str, int & pos)const {
	pos = 0;
	if(str.isEmpty()) {
		return set(tr("Domain part after @ is empty"));
	}
	if(str[0] == '-') {
		return set(tr("Hyphen '-' can't be at the start of domain"));
	}
	pos = str.count() - 1;
	if(str[pos] == '-') {
		return set(tr("Hyphen '-' can't be at the end of domain"));
	}
	QStringList parts = str.split('.', QString::KeepEmptyParts);
	if(parts.count()<2) {
		return set(tr("Single domain without subdomains?"));
	}
	pos = 0;
	for(QString part : parts) {
		if(part.isEmpty()) {
			return set(tr("empty domain part .."));
		}
		for(int i = 0; i < part.length(); ++i, ++pos) {
			QChar ch = part.at(i);
			if(isAsciiAlpha(ch) || ch.isDigit() || ch == '-')
				continue;
			return set(tr("Unsupported character ") + ch);
		}
		pos++;
	}
	return set(QValidator::Acceptable);
}
开发者ID:Emercoin,项目名称:emercoin,代码行数:31,代码来源:EmailValidator.cpp

示例9: parse

 QVariant parse()
 {
     LOG_AS("JSONParser");
     if(atEnd()) return QVariant();
     QChar c = peek();
     if(c == '{')
     {
         return parseObject();
     }
     else if(c == '[')
     {
         return parseArray();
     }
     else if(c == '\"')
     {
         return parseString();
     }
     else if(c == '-' || c.isDigit())
     {
         return parseNumber();
     }
     else
     {
         return parseKeyword();
     }
 }
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:26,代码来源:json.cpp

示例10: matchcharclass

static bool matchcharclass( uint *rxd, QChar c )
{
    uint *d = rxd;
    uint clcode = *d & MCD;
    bool neg = clcode == CCN;
    if ( clcode != CCL && clcode != CCN)
	qWarning("QRegExp: Internal error, please report to [email protected]");
    uint numFields = *d & MVL;
    uint cval = (((uint)(c.row())) << 8) | ((uint)c.cell());
    bool found = FALSE;
    for ( int i = 0; i < (int)numFields; i++ ) {
	d++;
	if ( *d == PWS && c.isSpace() ) {
	    found = TRUE;
	    break;
	}
	if ( *d == PDG && c.isDigit() ) {
	    found = TRUE;
	    break;
	}
	else {
	    uint from = ( *d & MCD ) >> 16;
	    uint to = *d & MVL;
	    if ( (cval >= from) && (cval <= to) ) {
		found = TRUE;
		break;
	    }
	}
    }
    return neg ? !found : found;
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:31,代码来源:qregexp.cpp

示例11: checkLocal

QValidator::State EmailValidator::checkLocal(const QString & str, int & pos)const {
	pos = 0;
	const QString allowed = "_-.!#$%&'*"
		//"+-/=?^_`{|}~" //characters after + are valid but ignored
		;
	if(str.isEmpty()) {
		return set(tr("Empty name before @ character"));
	}
	int i = 0;
	pos = 0;
	if(str[0] == '.') {
		return set(tr("Dot (.) can't be at the start of email"));
	}
	pos = str.count() - 1;
	if(str[pos] == '.') {
		return set(tr("Dot (.) can't be at the end of you email name"));
	}
	for(pos = 0; pos < str.length(); ++pos) {
		QChar ch = str[pos];
		if(isAsciiAlpha(ch) || ch.isDigit() || allowed.contains(ch))
			continue;
		return set(tr("Invalid character ") + ch);
	}
	return set(QValidator::Acceptable);
}
开发者ID:Emercoin,项目名称:emercoin,代码行数:25,代码来源:EmailValidator.cpp

示例12: QTableWidgetItem

int iqrfe::ClsSelectorSparse::validateCell(int iR, int iC, bool bAllowEmpty) {
    int iReturn = -1;

//ZZZ    QString qstr = qtablePoints->text( iR, iC ).stripWhiteSpace();
    QTableWidgetItem *qtwi = qtablePoints->itemAt ( iR, iC);
    if(qtwi!=NULL){
	QString qstr = qtwi->text().trimmed();
	if(!qstr.length()<=0){
	    for(unsigned int jj=0; jj<qstr.length(); jj++) {
		QChar qc = qstr[jj];
		if(!qc.isDigit()){
//ZZZ		qtablePoints->setText(iR, iC, "invalid entry");
		    QTableWidgetItem *newItem= new QTableWidgetItem("invalid entry");
		    qtablePoints->setItem(iR, iC, newItem);
		    return iReturn;
		}
	    }
	    try{
		iReturn = iqrUtils::string2int(qstr.toStdString());
	    }
	    catch(...){
//ZZZ	    qtablePoints->setText(iR, iC, "invalid entry");
		QTableWidgetItem *newItem= new QTableWidgetItem("invalid entry");
		qtablePoints->setItem(iR, iC, newItem);
	    }
	} else {
	    if(!bAllowEmpty){
//ZZZ	    qtablePoints->setText(iR, iC, "invalid entry");
		QTableWidgetItem *newItem= new QTableWidgetItem("invalid entry");
		qtablePoints->setItem(iR, iC, newItem);
	    }
	}
	return iReturn;
    }
}
开发者ID:jeez,项目名称:iqr,代码行数:35,代码来源:ClsSelectorSparse.cpp

示例13: slotAttemptAutoComplete

void QuickAddCapacitorDialog::slotAttemptAutoComplete()
{
    QString text = ui->capacitanceValueLineEdit->text().trimmed();
    //We accept 3 digit value codes with an optional tolerance code
    if(text.length()==3 || text.length()==4){
        QString multiplicandStr = text.left(2);
        QChar multiplierChar = text.at(2);
        bool multiplicandOk;
        int multiplicand = multiplicandStr.toInt(&multiplicandOk);        
        if(multiplicandOk && multiplierChar.isDigit()){
            double capacitance = multiplicand * pow10(-12);
            int multiplierIdx = to_char(multiplierChar) - '0';
            if(multiplierIdx >= 0 && multiplierIdx <= 9){
                capacitance = capacitance * MULTIPLIERS[multiplierIdx];
            }
            QString capacitanceStr = UnitFormatter::format(capacitance, _capacitanceParam.unitSymbol());
            ui->capacitanceValueLineEdit->setText(capacitanceStr);
        }
        if(text.length()==4){
            QChar toleranceChar = text.at(3);
            if(toleranceChar.isLetter()){
                QString tolerance = lookupTolerance(to_char(toleranceChar));
                if(!tolerance.isEmpty()){
                    ui->toleranceLineEdit->setText(tolerance);
                }
            }
        }
    }

}
开发者ID:jassuncao,项目名称:myparts,代码行数:30,代码来源:quickaddcapacitordialog.cpp

示例14: pasteLIFE_add

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void elMundo::pasteLIFE_add (QString line)
{
    int cN = 0;
    for (QString::const_iterator it  = line.constBegin();
            it != line.constEnd(); it++) {
        QChar c = *it;
        if (c.isDigit()) cN = 10*cN + c.digitValue();
        else {
            if (cN == 0) cN = 1;
            switch (c.unicode()) {
            case '.':
                cX += cN;
                cN = 0;
                break;
            case '*':
            case 'O':
                while (cN > 0) {
                    add(cX, cY, elcDefault);
                    cX++;
                    cN--;
                }
            }
        }
    }
    cX = cX0;
    cY++;
}
开发者ID:epiktetov,项目名称:juego-de-la-vida,代码行数:28,代码来源:elmundo.cpp

示例15: generateName

void Filer::generateName(bool aSmgExt)
{
    QString s = patchedFileName;
    if (aSmgExt) {
        s.remove(".smg");
    }
    int endString = s.size() - 1;

    QChar ch = patchedFileName.at(endString);
    if (!(ch.isDigit())) {
        patchedFileName = s + QString::number(generateNum(s, 0, aSmgExt));
    } else {
        QString num;
        int i;
        for (i = endString; i >= 0; --i) {
            if (s.at(i).isDigit()) {
                num.insert(0, s.at(i));
            } else {
                break;
            }
        }
        s = s.left(i + 1);
        patchedFileName = s + QString::number(generateNum(s, num.toInt(), aSmgExt));
}

    if (aSmgExt) {
        patchedFileName += ".smg";
    }
}
开发者ID:EXL,项目名称:zUnlock-ZN5,代码行数:29,代码来源:Filer.cpp


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