本文整理汇总了C++中QChar::isNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ QChar::isNumber方法的具体用法?C++ QChar::isNumber怎么用?C++ QChar::isNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QChar
的用法示例。
在下文中一共展示了QChar::isNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: func_proper
// Function: PROPER
Value func_proper(valVector args, ValueCalc *calc, FuncExtra *)
{
QString str = calc->conv()->asString(args[0]).asString().toLower();
QChar f;
bool first = true;
for (int i = 0; i < str.length(); ++i) {
if (first) {
f = str[i];
if (f.isNumber())
continue;
f = f.toUpper();
str[i] = f;
first = false;
continue;
}
if (str[i].isSpace() || str[i].isPunct())
first = true;
}
return Value(str);
}
示例2: dxfLayerName
QString QgsDxfExport::dxfLayerName( const QString& name )
{
//dxf layers can be max 31 characters long
QString layerName = name.left( 31 );
//allowed characters are 0-9, A-Z, $, -, _
for ( int i = 0; i < layerName.size(); ++i )
{
QChar c = layerName.at( i );
if ( c > 122 )
{
layerName[i] = '_';
continue;
}
if ( c.isNumber() )
{
continue;
}
if ( c == '$' || c == '-' || c == '_' )
{
continue;
}
if ( !c.isLetter() )
{
layerName[i] = '_';
}
}
return layerName;
}
示例3: runtime_error
LevelFile::LevelFile(QString file)
{
// open file
level = new QFile(file);
if(!level->open(QIODevice::ReadOnly)) {
throw runtime_error("Couldn't open file");
}
// create stream
QTextStream in(level);
in.setIntegerBase(10);
// read through file, put into map
QChar l;
int row = 0;
map.append(Row());
while(!in.atEnd()) {
in >> l; // read each letter
if(l == QChar::Space) // ignore space
continue;
else if(l == QChar::LineFeed) { // new row
map.append(Row());
row++;
}
else if(l.isNumber()) { // add number to map
map[row].append(l.digitValue());
}
}
level->close();
}
示例4: getNumer
void Coefficient::getNumer(QString& fractionRep, int& numerInt, bool& hasDenom)
{
QString numerString;
int numeratorSize = 0;
for(int i = 0; i<fractionRep.size(); i++)
{
QChar ch = fractionRep.at(i);
if(ch.isNumber() || (ch=='-' || ch=='+') )
numerString += ch;
else if (ch=='/' || ch=='\\')
{
hasDenom = true;
numerInt = numerString.toInt();
fractionRep.remove(0,numeratorSize);
return;
}
else
numerInt = 0;
numeratorSize++;
}
numerInt = numerString.toInt();
}
示例5: updateCompletionMap
void EditorCompletion::updateCompletionMap( Q3TextDocument *doc )
{
bool strict = true;
if ( doc != lastDoc )
strict = false;
lastDoc = doc;
Q3TextParagraph *s = doc->firstParagraph();
if ( !s->extraData() )
s->setExtraData( new ParagData );
while ( s ) {
if ( s->length() == ( (ParagData*)s->extraData() )->lastLengthForCompletion ) {
s = s->next();
continue;
}
QChar c;
QString buffer;
for ( int i = 0; i < s->length(); ++i ) {
c = s->at( i )->c;
if ( c.isLetter() || c.isNumber() || c == '_' || c == '#' ) {
buffer += c;
} else {
addCompletionEntry( buffer, doc, strict );
buffer = QString::null;
}
}
if ( !buffer.isEmpty() )
addCompletionEntry( buffer, doc, strict );
( (ParagData*)s->extraData() )->lastLengthForCompletion = s->length();
s = s->next();
}
}
示例6: isNumber
bool isNumber(const QChar &ch)
{
if (ch.isNumber()) {
return true;
}
if (QString(QLatin1String( ".,-+" )).contains( ch )) {
return true;
}
return false;
}
示例7: translatedToVanity
QChar QPhoneNumberString::translatedToVanity(const QChar c) {
if ( c.isNull() ) return QChar();
if ( c.isNumber() ) return c;
if ( c.isSpace() ) return QChar('1');
QChar vanityChar = m_VanityChars[ c.toLower() ];
if ( vanityChar.isNull() )
kDebug() << " did not found char "
<< c << hex << c.unicode()
<< "\" to translate.";
return( vanityChar );
}
示例8: shouldStartCompletion
bool CodeCompletionModelControllerInterface::shouldStartCompletion(View* view, const QString &insertedText, bool userInsertion, const Cursor &position)
{
Q_UNUSED(view);
Q_UNUSED(position);
if(insertedText.isEmpty())
return false;
QChar lastChar = insertedText.at(insertedText.count() - 1);
if ((userInsertion && (lastChar.isLetter() || lastChar.isNumber() || lastChar == '_')) ||
lastChar == '.' || insertedText.endsWith(QLatin1String("->"))) {
return true;
}
return false;
}
示例9: getDenom
void Coefficient::getDenom(QString& fractionRep, int& denomInt)
{
QString denomString;
for(int i = 0; i<fractionRep.size(); i++)
{
QChar ch = fractionRep.at(i);
if(ch.isNumber())
denomString += ch;
else
denomInt = 1;
}
denomInt = denomString.toInt();
}
示例10: nextSequence
QString FLUtil::nextSequence(int nivel, const QString &secuencia, const QString &ultimo)
{
QString cadena;
QString valor;
QString string;
QString string2;
QChar temp;
long num;
int pos2 = 0;
int nivpas = 0;
int posult = 0;
int niveles = secuencia.contains("%A") + secuencia.contains("%N");
int pos = 1;
pos2 = secuencia.find("%", 0);
while (pos2 != -1) {
if (nivpas == 0) {
cadena = secuencia.mid(0, pos2);
posult = pos2;
} else {
string2 = secuencia.mid(pos + 2, pos2 - pos - 2);
posult = ultimo.find(string2, posult) + string2.length();
cadena = cadena + secuencia.mid(pos + 2, pos2 - pos - 2);
}
pos = pos2;
valor = "";
if (nivpas < niveles - nivel) {
for (uint i = posult; i < ultimo.length(); ++i) {
if (secuencia.mid(pos + 1, 1) == "A") {
temp = ultimo.at(i);
if (temp.isLetter() == false) {
cadena = cadena + valor;
break;
}
valor = valor + temp;
}
if (secuencia.mid(pos + 1, 1) == "N") {
temp = ultimo.at(i);
if (temp.isNumber() == false) {
cadena = cadena + valor;
break;
}
valor = valor + temp;
}
}
posult = posult + valor.length();
} else if (nivpas == niveles - nivel) {
for (uint i = posult; i < ultimo.length(); ++i) {
if (secuencia.mid(pos + 1, 1) == "A") {
temp = ultimo.at(i);
if (i == (ultimo.length() - 1)) {
valor = valor + temp;
num = serialLettertoNumber(valor).toLong() + 1;
cadena = cadena + serialNumbertoLetter(num);
break;
}
if (temp.isLetter() == false) {
num = serialLettertoNumber(valor).toLong() + 1;
cadena = cadena + serialNumbertoLetter(num);
break;
}
valor = valor + temp;
}
if (secuencia.mid(pos + 1, 1) == "N") {
temp = ultimo.at(i);
if (i == (ultimo.length() - 1)) {
valor = valor + temp;
cadena = cadena + string.setNum(valor.toInt() + 1);
break;
}
if (temp.isNumber() == false) {
cadena = cadena + string.setNum(valor.toInt() + 1);
break;
}
valor = valor + temp;
}
}
posult = posult + valor.length();
} else {
if (secuencia.mid(pos + 1, 1) == "N")
cadena = cadena + "1";
if (secuencia.mid(pos + 1, 1) == "A")
cadena = cadena + "A";
}
pos2 = secuencia.find("%", pos + 1);
nivpas++;
}
return cadena;
}
示例11: process
//.........这里部分代码省略.........
}
else if ( c=='\'' )
{
do
{
i = text.indexOf("\'", ++i);
if ( i == -1 )
{
setFormat(n, len-n, fmts[quote]);
return normal;
}
} while ( text.at(i-1)=='\\' );
setFormat(n, i-n+1, fmts[quote]);
}
else if ( c=='\"' )
{
do
{
i = text.indexOf("\"", ++i);
if ( i == -1 )
{
setFormat(n, len-n, fmts[quote]);
if ( str[len-1]=='\\' )
return quote;
else
return normal;
}
} while ( text.at(i-1)=='\\' );
setFormat(n, i-n+1, fmts[quote]);
}
else if ( c.isLetter() || (c == '_') )
{
do
{
c = str[++i];
} while ( c.isLetterOrNumber() || (c == '_') );
s = QString(str+n, i-n);
for (int j=0; j<keywords; j++)
{
if ( s != kwds[j] )
continue;
setFormat(n, s.count(), fmts[keyword]);
break;
}
i--;
}
else if ( c.isNumber() )
{
char base = 10;
if ( str[i] == '0' )
{
base = 8;
if ( str[i+1] == 'x' )
{
base = 16;
i++;
}
}
do
{
c = str[++i];
} while ( DevQt::isNumber(c.toLatin1(), base) || ( (base==10) &&
((c=='.') || (c=='e') || (c=='E') || (c=='f') || (c=='F')) )
);
s = QString(str+n, i-n);
i--;
if (base == 10 && (
(s.count('e', Qt::CaseInsensitive)>1) ||
(s.count('f', Qt::CaseInsensitive)>1) ) )
continue;
setFormat(n, s.count(), fmts[number]);
} else if ( c == '{' ) {
bd->parentheses << Parenthesis(Parenthesis::Open, c, i);
//TODO : add collapsing stuffs
} else if ( c == '(' || c == '[' ) {
bd->parentheses << Parenthesis(Parenthesis::Open, c, i);
} else if ( c == '}' ) {
bd->parentheses << Parenthesis(Parenthesis::Closed, c, i);
//TODO : add collapsing stuffs
} else if ( c == ')' || c == ']' ) {
bd->parentheses << Parenthesis(Parenthesis::Closed, c, i);
}
}
return normal;
}
示例12: isValidIdentifierChar
bool isValidIdentifierChar(const QChar &ch)
{
return isValidFirstIdentifierChar(ch) || ch.isNumber();
}
示例13: foreach
foreach (QChar c, str) {
if (!c.isNumber()) {
return false;
}
}
示例14: if
QList<Token> Scanner::operator()(const QString &text, int startState)
{
_state = startState;
QList<Token> tokens;
// ### handle multi line comment state.
int index = 0;
if (_state == MultiLineComment) {
const int start = index;
while (index < text.length()) {
const QChar ch = text.at(index);
QChar la;
if (index + 1 < text.length())
la = text.at(index + 1);
if (ch == QLatin1Char('*') && la == QLatin1Char('/')) {
_state = Normal;
index += 2;
break;
} else {
++index;
}
}
if (_scanComments)
tokens.append(Token(start, index - start, Token::Comment));
}
while (index < text.length()) {
const QChar ch = text.at(index);
QChar la; // lookahead char
if (index + 1 < text.length())
la = text.at(index + 1);
switch (ch.unicode()) {
case '/':
if (la == QLatin1Char('/')) {
if (_scanComments)
tokens.append(Token(index, text.length() - index, Token::Comment));
index = text.length();
} else if (la == QLatin1Char('*')) {
const int start = index;
index += 2;
_state = MultiLineComment;
while (index < text.length()) {
const QChar ch = text.at(index);
QChar la;
if (index + 1 < text.length())
la = text.at(index + 1);
if (ch == QLatin1Char('*') && la == QLatin1Char('/')) {
_state = Normal;
index += 2;
break;
} else {
++index;
}
}
if (_scanComments)
tokens.append(Token(start, index - start, Token::Comment));
} else {
tokens.append(Token(index++, 1, Token::Delimiter));
}
break;
case '\'':
case '"': {
const QChar quote = ch;
const int start = index;
++index;
while (index < text.length()) {
const QChar ch = text.at(index);
if (ch == quote)
break;
else if (index + 1 < text.length() && ch == QLatin1Char('\\'))
index += 2;
else
++index;
}
if (index < text.length()) {
++index;
// good one
} else {
// unfinished
}
tokens.append(Token(start, index - start, Token::String));
} break;
case '.':
if (la.isDigit()) {
const int start = index;
do {
++index;
} while (index < text.length() && isNumberChar(text.at(index)));
//.........这里部分代码省略.........
示例15: doCompletion
bool EditorCompletion::doCompletion()
{
searchString = "";
if ( !curEditor )
return false;
Q3TextCursor *cursor = curEditor->textCursor();
Q3TextDocument *doc = curEditor->document();
if ( cursor->index() > 0 && cursor->paragraph()->at( cursor->index() - 1 )->c == '.' &&
( cursor->index() == 1 || cursor->paragraph()->at( cursor->index() - 2 )->c != '.' ) )
return doObjectCompletion();
int idx = cursor->index();
if ( idx == 0 )
return false;
QChar c = cursor->paragraph()->at( idx - 1 )->c;
if ( !c.isLetter() && !c.isNumber() && c != '_' && c != '#' )
return false;
QString s;
idx--;
completionOffset = 1;
for (;;) {
s.prepend( QString( cursor->paragraph()->at( idx )->c ) );
idx--;
if ( idx < 0 )
break;
if ( !cursor->paragraph()->at( idx )->c.isLetter() &&
!cursor->paragraph()->at( idx )->c.isNumber() &&
cursor->paragraph()->at( idx )->c != '_' &&
cursor->paragraph()->at( idx )->c != '#' )
break;
completionOffset++;
}
searchString = s;
QList<CompletionEntry> lst( completionList( s, doc ) );
if ( lst.count() > 1 ) {
Q3TextStringChar *chr = cursor->paragraph()->at( cursor->index() );
int h = cursor->paragraph()->lineHeightOfChar( cursor->index() );
int x = cursor->paragraph()->rect().x() + chr->x;
int y, dummy;
cursor->paragraph()->lineHeightOfChar( cursor->index(), &dummy, &y );
y += cursor->paragraph()->rect().y();
completionListBox->clear();
for ( QList<CompletionEntry>::ConstIterator it = lst.begin(); it != lst.end(); ++it )
(void)new CompletionItem( completionListBox, (*it).text, (*it).type, (*it).postfix,
(*it).prefix, (*it).postfix2 );
cList = lst;
completionPopup->resize( completionListBox->sizeHint() +
QSize( completionListBox->verticalScrollBar()->width() + 4,
completionListBox->horizontalScrollBar()->height() + 4 ) );
completionListBox->setCurrentItem( 0 );
if ( curEditor->mapToGlobal( QPoint( 0, y ) ).y() + h + completionPopup->height() < QApplication::desktop()->height() )
completionPopup->move( curEditor->mapToGlobal( curEditor->
contentsToViewport( QPoint( x, y + h ) ) ) );
else
completionPopup->move( curEditor->mapToGlobal( curEditor->
contentsToViewport( QPoint( x, y - completionPopup->height() ) ) ) );
completionPopup->show();
} else if ( lst.count() == 1 ) {
curEditor->insert( lst.first().text.mid( completionOffset, 0xFFFFFF ),
(uint) ( Q3TextEdit::RedoIndentation |
Q3TextEdit::CheckNewLines |
Q3TextEdit::RemoveSelected ) );
} else {
return false;
}
return true;
}