本文整理汇总了C++中qstringlist::iterator::toInt方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::toInt方法的具体用法?C++ iterator::toInt怎么用?C++ iterator::toInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::iterator
的用法示例。
在下文中一共展示了iterator::toInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: modelPoint
modelPoint *parsePoint()
{
modelPoint *ret = new modelPoint();
QString strLine = getLine();
checkEqual(strLine, TOKOBRACE);
strLine = getLine();
QString connectedlines = getValue(strLine, TOKCONECTEDLINES);
strLine = getLine();
QString connectedextrems = getValue(strLine, TOKCONECTEDEXTREMS);
strLine = getLine();
//QString position=getValue(strLine,TOKPOSITION);
strLine = getLine();
checkEqual(strLine, TOKCBRACE);
ret->extrems =
connectedextrems.split(TOKCOLON, QString::SkipEmptyParts);
QStringList t = connectedlines.split(TOKCOLON, QString::SkipEmptyParts);
QStringList::iterator i;
QList < int >ls;
for (i = t.begin(); i != t.end(); ++i)
ls.append(i->toInt());
ret->lines = ls;
return ret;
}
示例2: modelLine
modelLine *parseLine()
{
modelLine *ret = new modelLine();
QString strLine = getLine();
checkEqual(strLine, TOKOBRACE);
strLine = getLine();
QString source = getValue(strLine, TOKSOURCE);
strLine = getLine();
QString sink = getValue(strLine, TOKSINK);
strLine = getLine();
//QString pointx=getValue(strLine,TOKPOINTX);
strLine = getLine();
//QString pointy=getValue(strLine,TOKPOINTY);
strLine = getLine();
checkEqual(strLine, TOKCBRACE);
QStringList src = source.split(TOKCOLON, QString::SkipEmptyParts);
ret->sourceType = src.takeFirst().trimmed();
QStringList::iterator i;
QList < int >sources;
for (i = src.begin(); i != src.end(); ++i)
sources.append(i->toInt());
ret->sources = sources;
src = sink.split(TOKCOLON, QString::SkipEmptyParts);
ret->sinkType = src.takeFirst().trimmed();
QList < int >sinks;
for (i = src.begin(); i != src.end(); ++i)
sinks.append(i->toInt());
ret->sinks = sinks;
return ret;
}
示例3: isAlldataTypeValid
bool synaxErrorJudger::isAlldataTypeValid(QStringList &data, vector<pair<int, size_t>> &dataTypeInfo)
{
QStringList::iterator it;
for (it = data.begin(); it != data.end(); ++it) {
*it = it->trimmed();
if (*it == "") {
return false;
}
bool ok;
if (it->indexOf('\'') != -1) { //引号'应该是字符或字符串
it->remove(0, 1).remove(QRegExp("'$"));
size_t len = it->size();
if (len < 1 || len > 255) {
return false;
}
else if (len == 1) {
dataTypeInfo.push_back(pair<int, size_t>(_CHAR, sizeof(char)));
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_STRING, len * sizeof(char)));
}
}
else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
it->toFloat(&ok);
if (!ok) {
return false;
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_FLOAT, sizeof(float)));
}
}
else { //剩下的应该是int类型
it->toInt(&ok);
if (!ok) {
return false;
}
else {
dataTypeInfo.push_back(pair<int, size_t>(_INT, sizeof(int)));
}
}
}
return true;
}
示例4: generateCondition
void synaxErrorJudger::generateCondition()
{
int begin = sqlExp.indexOf("where") + 5;
int end = sqlExp.indexOf(QRegExp(";$")) - 1;
QStringList conditions = sqlExp.mid(begin, end - begin + 1).split("and");
QStringList::iterator it;
pair<int, size_t> dataType;
int logicType;
string rightSide, leftSide;
for (it = conditions.begin(); it != conditions.end(); ++it) {
*it = it->trimmed();
if (*it == "") {
throw QString("Synax Error: Conditions' format is incorrect.");
}
int begin = 0;
int end = it->indexOf(QRegExp("[=><]"))-1;
rightSide = it->mid(begin, end - begin + 1).trimmed().toStdString();
begin = end + 1;
end = it->indexOf(QRegExp("[=><]"), begin + 1);
if (end - begin > 1 || end == -1) { //如果下一个"=",">","<"号出现在较远处
end = begin; //说明这个逻辑关系是"=",">","<"而非">=", "<=", "<>"
}
logicType = condition::getLogicTypeFromStr(it->mid(begin, end - begin + 1).toStdString());
if (logicType == _ERROR) {
throw QString("Synax Error: The logic arithemtic is invalid.");
}
bool ok;
*it = it->mid(end + 1).trimmed();
if (it->indexOf(QRegExp("^'")) != -1) { //引号'应该是字符或字符串
it->remove(0, 1).remove(QRegExp("'$"));
size_t len = it->size();
pair<int, size_t> dType;
Api::cManager.getAttributeDataType(*tblName, rightSide, dType);
if (len < 1 || len > 255 || len > dType.second) {
throw QString("Synax Error: The length of string is overflow.");
}
else if (len == 1) {
dataType = pair<int, size_t>(_CHAR, sizeof(char));
}
else {
dataType = pair<int, size_t>(_STRING, dType.second * sizeof(char));
}
}
else if (it->indexOf('.') != -1) { //有小数点且不是字符串,应该是float
it->toFloat(&ok);
if (!ok) {
;
}
else {
dataType = pair<int, size_t>(_FLOAT, sizeof(float));
}
}
else { //剩下的应该是int类型
it->toInt(&ok);
if (!ok) {
;
}
else {
dataType = pair<int, size_t>(_INT, sizeof(int));
}
}
leftSide = it->toStdString();
if (cond == 0) {
cond = new vector<condition>;
}
cond->push_back(condition(rightSide, logicType, dataType, leftSide));
}
}
示例5: fi
void
CLArgsPrivate::parse()
{
{
QStringList::iterator it = hasToken( QString::fromUtf8("version"), QString::fromUtf8("v") );
if ( it != args.end() ) {
QString msg = QObject::tr("%1 version %2 at commit %3 on branch %4 built on %4").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).arg( QString::fromUtf8(NATRON_VERSION_STRING) ).arg( QString::fromUtf8(GIT_COMMIT) ).arg( QString::fromUtf8(GIT_BRANCH) ).arg( QString::fromUtf8(__DATE__) );
std::cout << msg.toStdString() << std::endl;
error = 1;
return;
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8("help"), QString::fromUtf8("h") );
if ( it != args.end() ) {
CLArgs::printUsage( args[0].toStdString() );
error = 1;
return;
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8("background"), QString::fromUtf8("b") );
if ( it != args.end() ) {
isBackground = true;
args.erase(it);
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8("interpreter"), QString::fromUtf8("t") );
if ( it != args.end() ) {
isInterpreterMode = true;
isBackground = true;
std::cout << QObject::tr("Note: -t argument given, loading in command-line interpreter mode, only Python commands / scripts are accepted").toStdString()
<< std::endl;
args.erase(it);
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8("render-stats"), QString::fromUtf8("s") );
if ( it != args.end() ) {
enableRenderStats = true;
args.erase(it);
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_PROCESS_PID), QString() );
if ( it != args.end() ) {
++it;
if ( it != args.end() ) {
breakpadProcessPID = it->toLongLong();
args.erase(it);
} else {
std::cout << QObject::tr("You must specify the breakpad process executable file path").toStdString() << std::endl;
error = 1;
return;
}
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_PROCESS_EXEC), QString() );
if ( it != args.end() ) {
++it;
if ( it != args.end() ) {
breakpadProcessFilePath = *it;
args.erase(it);
} else {
std::cout << QObject::tr("You must specify the breakpad process executable file path").toStdString() << std::endl;
error = 1;
return;
}
}
}
{
QStringList::iterator it = hasToken( QString::fromUtf8(NATRON_BREAKPAD_CLIENT_FD_ARG), QString() );
if ( it != args.end() ) {
++it;
if ( it != args.end() ) {
breakpadPipeClientID = it->toInt();
args.erase(it);
} else {
std::cout << QObject::tr("You must specify the breakpad pipe client FD").toStdString() << std::endl;
error = 1;
return;
}
}
}
{
//.........这里部分代码省略.........
示例6: if
//.........这里部分代码省略.........
QgsDebugMsg( "Found y field: " + ( *it ) );
mYFieldIndex = fieldPos;
}
QgsDebugMsg( "Adding field: " + ( *it ) );
// assume that the field could be integer or double
couldBeInt.insert( fieldPos, true );
couldBeDouble.insert( fieldPos, true );
fieldPos++;
}
}
QgsDebugMsg( "Field count for the delimited text file is " + QString::number( attributeFields.size() ) );
hasFields = true;
}
else if ( mXFieldIndex != -1 && mYFieldIndex != -1 )
{
mNumberFeatures++;
// split the line on the delimiter
QStringList parts;
if ( mDelimiterType == "regexp" )
parts = line.split( mDelimiterRegexp );
else
parts = line.split( mDelimiter );
// Skip malformed lines silently. Report line number with nextFeature()
if ( attributeFields.size() != parts.size() )
{
continue;
}
// Get the x and y values, first checking to make sure they
// aren't null.
QString sX = parts[mXFieldIndex];
QString sY = parts[mYFieldIndex];
bool xOk = true;
bool yOk = true;
double x = sX.toDouble( &xOk );
double y = sY.toDouble( &yOk );
if ( xOk && yOk )
{
if ( !firstPoint )
{
mExtent.combineExtentWith( x, y );
}
else
{ // Extent for the first point is just the first point
mExtent.set( x, y, x, y );
firstPoint = false;
}
}
int i = 0;
for ( QStringList::iterator it = parts.begin(); it != parts.end(); ++it, ++i )
{
// try to convert attribute values to integer and double
if ( couldBeInt[i] )
{
it->toInt( &couldBeInt[i] );
}
if ( couldBeDouble[i] )
{
it->toDouble( &couldBeDouble[i] );
}
}
}
}
// now it's time to decide the types for the fields
for ( QgsFieldMap::iterator it = attributeFields.begin(); it != attributeFields.end(); ++it )
{
if ( couldBeInt[it.key()] )
{
it->setType( QVariant::Int );
it->setTypeName( "integer" );
}
else if ( couldBeDouble[it.key()] )
{
it->setType( QVariant::Double );
it->setTypeName( "double" );
}
}
if ( mXFieldIndex != -1 && mYFieldIndex != -1 )
{
QgsDebugMsg( "Data store is valid" );
QgsDebugMsg( "Number of features " + QString::number( mNumberFeatures ) );
QgsDebugMsg( "Extents " + mExtent.toString() );
mValid = true;
}
else
{
QgsDebugMsg( "Data store is invalid. Specified x,y fields do not match those in the database" );
}
QgsDebugMsg( "Done checking validity" );
}