本文整理汇总了C++中QMultiHash::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ QMultiHash::clear方法的具体用法?C++ QMultiHash::clear怎么用?C++ QMultiHash::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMultiHash
的用法示例。
在下文中一共展示了QMultiHash::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QByteArray
void tst_QVCard21Writer::testEncodeParameters_data()
{
QTest::addColumn< QMultiHash<QString, QString> >("parameters");
QTest::addColumn<QByteArray>("expected");
QMultiHash<QString,QString> parameters;
QTest::newRow("No parameters") << parameters << QByteArray("");
parameters.insert(QStringLiteral("TYPE"), QString::fromLatin1("HOME"));
QTest::newRow("One TYPE parameter") << parameters << QByteArray(";HOME");
// HOME should appear before VOICE because it is more "important" and some vCard
// parsers may ignore everything after the first TYPE
parameters.insert(QStringLiteral("TYPE"), QString::fromLatin1("VOICE"));
QTest::newRow("Two TYPE parameters") << parameters << QByteArray(";HOME;VOICE");
parameters.clear();
parameters.insert(QStringLiteral("ENCODING"), QString::fromLatin1("8BIT"));
QTest::newRow("One ENCODING parameter") << parameters << QByteArray(";ENCODING=8BIT");
parameters.insert(QString::fromLatin1("X-PARAM"),QString::fromLatin1("VALUE"));
QTest::newRow("Two parameters") << parameters << QByteArray(";X-PARAM=VALUE;ENCODING=8BIT");
parameters.clear();
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("VOICE"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("CELL"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("MODEM"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("CAR"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("VIDEO"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("FAX"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("BBS"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("PAGER"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("HOME"));
parameters.insert(QStringLiteral("TYPE"), QStringLiteral("WORK"));
// Ensure CELL and FAX are at the front because they are "more important" and some vCard
// parsers may ignore everything after the first TYPE
// Ensure WORK and HOME come next.
// Besides these conditions, there are no other ordering constraints. The data here is simply
// what the writer produces (as dictated by its internal data structures).
QTest::newRow("TYPE parameters order") << parameters
<< QByteArray(";CELL;FAX;WORK;HOME;MODEM;CAR;VIDEO;BBS;PAGER;VOICE");
}
示例2: LogPrintf
bool OsmAnd::MapRendererTiledSymbolsResource::uploadToGPU()
{
typedef std::pair< std::shared_ptr<MapSymbol>, std::shared_ptr<const GPUAPI::ResourceInGPU> > SymbolResourceEntry;
bool ok;
bool anyUploadFailed = false;
const auto link_ = link.lock();
const auto collection = static_cast<MapRendererTiledSymbolsResourcesCollection*>(&link_->collection);
// Unique
QMultiHash< std::shared_ptr<GroupResources>, SymbolResourceEntry > uniqueUploaded;
for (const auto& groupResources : constOf(_uniqueGroupsResources))
{
for (const auto& symbol : constOf(groupResources->group->symbols))
{
// Prepare data and upload to GPU
std::shared_ptr<const GPUAPI::ResourceInGPU> resourceInGPU;
ok = resourcesManager->uploadSymbolToGPU(symbol, resourceInGPU);
// If upload have failed, stop
if (!ok)
{
LogPrintf(LogSeverityLevel::Error, "Failed to upload unique symbol in %dx%[email protected]%d tile",
tileId.x, tileId.y, zoom);
anyUploadFailed = true;
break;
}
// Mark this symbol as uploaded
uniqueUploaded.insert(groupResources, qMove(SymbolResourceEntry(symbol, resourceInGPU)));
}
if (anyUploadFailed)
break;
}
// Shared
QMultiHash< std::shared_ptr<GroupResources>, SymbolResourceEntry > sharedUploaded;
QMultiHash< std::shared_ptr<GroupResources>, SymbolResourceEntry > sharedReferenced;
for (const auto& groupResources : constOf(_referencedSharedGroupsResources))
{
if (groupResources->group->symbols.isEmpty())
continue;
// This check means "continue if shared symbols were uploaded by other resource"
// This check needs no special handling, since all GPU resources work is done from same thread.
if (!groupResources->resourcesInGPU.isEmpty())
{
for (const auto& entryResourceInGPU : rangeOf(constOf(groupResources->resourcesInGPU)))
{
const auto& symbol = entryResourceInGPU.key();
auto& resourceInGPU = entryResourceInGPU.value();
sharedReferenced.insert(groupResources, qMove(SymbolResourceEntry(symbol, resourceInGPU)));
}
continue;
}
for (const auto& symbol : constOf(groupResources->group->symbols))
{
// Prepare data and upload to GPU
std::shared_ptr<const GPUAPI::ResourceInGPU> resourceInGPU;
ok = resourcesManager->uploadSymbolToGPU(symbol, resourceInGPU);
// If upload have failed, stop
if (!ok)
{
LogPrintf(LogSeverityLevel::Error, "Failed to upload unique symbol in %dx%[email protected]%d tile",
tileId.x, tileId.y, zoom);
anyUploadFailed = true;
break;
}
// Mark this symbol as uploaded
sharedUploaded.insert(groupResources, qMove(SymbolResourceEntry(symbol, resourceInGPU)));
}
if (anyUploadFailed)
break;
}
// If at least one symbol failed to upload, consider entire tile as failed to upload,
// and unload its partial GPU resources
if (anyUploadFailed)
{
uniqueUploaded.clear();
sharedUploaded.clear();
return false;
}
// All resources have been uploaded to GPU successfully by this point,
// so it's safe to walk across symbols and remove bitmaps:
// Unique
for (const auto& entry : rangeOf(constOf(uniqueUploaded)))
{
const auto& groupResources = entry.key();
const auto& symbol = entry.value().first;
//.........这里部分代码省略.........
示例3: loadEngine
void TcDatabase::loadEngine(const QString& filename)
{
m_sqls.clear();
if ( m_handle.isOpen() )
{
if ( dbType() == SQLSERVER )
{
// 取出存储过程名
QSqlQuery procedures_query = QSqlQuery(m_handle);
QSqlQuery query = QSqlQuery(m_handle);
if ( procedures_query.exec("exec sp_procedures_rowset2") )
{
while(procedures_query.next())
{
QSqlRecord procedures = procedures_query.record();
QSqlField fieldSchema = procedures.field("PROCEDURE_SCHEMA");
if ( fieldSchema.isValid() && fieldSchema.value() != "sys" )
{
QSqlField field = procedures.field("PROCEDURE_NAME");
if ( field.isValid() )
{
SQLContext cnt;
QString procedureID = field.value().toString().toLower();
int index = procedureID.indexOf(";");
if ( index >= 0 )
{
procedureID = procedureID.left(index);
}
cnt.id = procedureID;
QString paramsLine;
if ( query.exec("exec sp_procedure_params_rowset '"+procedureID+"'") )
{
while(query.next())
{
QSqlRecord paramField = query.record();
QSqlField paramName = paramField.field("PARAMETER_NAME");
QString pname = paramName.value().toString();
if ( pname.compare("@RETURN_VALUE", Qt::CaseInsensitive) != 0 )
{
QSqlField paramType = paramField.field("TYPE_NAME");
pname.remove(0, 1);
QString ptype = paramType.value().toString().toLower();
if ( ptype == "nvarchar" )
{
ptype = "string";
}
cnt.params.insert(pname, ptype);
paramsLine += ", :" + pname;
}
}
query.finish();
if ( ! paramsLine.isEmpty() )
{
paramsLine.remove(0, 2);
}
}
cnt.text = "exec " + procedureID + " " + paramsLine;
m_sqls[procedureID] = cnt;
Q_EMIT dbiLoading(m_sqls.count(), procedureID);
}
}
}
procedures_query.finish();
}
}else
if ( dbType() == MYSQL )
{
// 取出存储过程名
QString sql = "SELECT `name`, `param_list`, `body`, `returns` FROM `mysql`.`proc` WHERE `language` = 'SQL' AND `db` = '"+dbName()+"';";
QSqlQuery query = QSqlQuery(m_handle);
if ( query.exec(sql) )
{
QSqlField field;
while(query.next())
{
QSqlRecord procedures = query.record();
QString param_line;
SQLContext cnt;
cnt.id = procedures.field("name").value().toString();
cnt.params = getParamList(param_line, procedures.field("param_list").value().toString());
cnt.text = "call " + cnt.id + "(" + param_line + ");";
//cnt.text = procedures.field("body").value().toString();
m_sqls[cnt.id] = cnt;
Q_EMIT dbiLoading(m_sqls.count(), cnt.id);
Q_EMIT dbiLoading(m_sqls.count(), cnt.text);
}
query.finish();
}
}else
if ( dbType() == POSTGRESQL )
{
// 取出存储过程名
QSqlQuery storedproc_query = QSqlQuery(m_handle);
QSqlQuery query = QSqlQuery(m_handle);
//.........这里部分代码省略.........