本文整理汇总了C++中QueryResult::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::size方法的具体用法?C++ QueryResult::size怎么用?C++ QueryResult::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
int32 MyCSG::process()
{
QueryResult tableresult = database.query("SHOW TABLE STATUS");
//////////////////////////////////////
// Fetch all column names & types
for (auto table : *tableresult)
{
cout << "(" << table.first + 1 << " / " << tableresult->size() << ")\tAnalysing: " <<
table.second.at(0).Get() << endl;
QueryResult columns = database.query("SHOW COLUMNS FROM " + table.second.at(0).Get());
Table t(table.second.at(0).Get());
for (auto dbcol : *columns)
t.addCol(Column(dbcol.second.at(0), dbcol.second.at(1), dbcol.second.at(3).Get() == "PRI"));
analysedTables.push_back(t);
cout << "\t>> Found " << columns->size() << " Columns\n";
}
for (uint8 i = 0;; ++i)
{
unique_ptr<OutputFile> file = nullptr;
switch (i)
{
case 0:
file.reset(new FileStructure_h());
break;
case 1:
file.reset(new FileStorage_h());
break;
case 2:
file.reset(new FileStorage_cpp());
break;
case 3:
file.reset(new FileChecks_h());
break;
case 4:
file.reset(new FileChecks_cpp());
break;
case 5:
file.reset(new FileLoader_h());
case 6:
file.reset(new FileLoader_cpp());
break;
default:
return EXIT_SUCCESS;
}
if (!file->isOpen())
return EXIT_FAILURE;
file->Write();
}
cout << endl;
}
示例2: getStateId
QString Bookmark::getStateId( QString name )
{
QString query = "select Id from UserStates where StateName like \'" ;
query += name ;
query += "\' " ;
QueryResult qr ;
this->execQuery( query , qr );
if ( qr.size() == 0 )
return QString() ;
else
return qr.getField(0,0) ;
}
示例3: setArticleItemDecorations
void BookmarkGui::setArticleItemDecorations( QTreeWidgetItem* item , const QString& id_articolo , const QString& id )
{
QueryResult article ;
Bookmark bk ;
bk.getFavoriteFullData( article , id_articolo ) ;
QIcon doc_icon(":/icons/crystal/doc-icon.png") ;
item->setIcon( 0 , doc_icon );
if ( article.size() == 0 ) return ;
item->setText( 0 , article.getField( "Titolo" , article.begin() ) );
item->setText( 1 , id_articolo ) ;
item->setText( 2 , id ) ;
}
示例4: fillFavoriteInfo
void BookmarkGui::fillFavoriteInfo( const QString& id )
{
QueryResult article ;
Bookmark bk ;
bk.getFavoriteFullData( article , id ) ;
if ( article.size() == 0 ) return ;
QString query_autori = "SELECT autore FROM autori WHERE id in (SELECT idautore FROM articoli_autori WHERE idarticolo = " ;
query_autori += id ;
query_autori += " ) " ;
QueryDB db ;
QueryResult qr_autori = db.execQuery( query_autori ) ;
QString query_data = "SELECT mese,anno FROM riviste WHERE id = " ;
query_data += article.getField( "IdRivista" , article.begin() ) ;
QueryResult qr_data = db.execQuery( query_data ) ;
QString abstract ;
abstract += article.getField( "Abstract" , article.begin() ) ;
abstract += "<br/> <br/> <i>" ;
for ( QueryResult::iterator itr = qr_autori.begin() ; itr < qr_autori.end() ; itr++ )
{
abstract += qr_autori.getField( "Autore" , itr ) ;
if ( itr < qr_autori.end() - 1 ) abstract += "; " ;
}
abstract += "</i><br/>" ;
abstract += qr_data.getField( "Mese" , qr_data.begin() ) ;
abstract += " " ;
abstract += qr_data.getField( "Anno" , qr_data.begin() ) ;
QString title = "<b>" ;
title += article.getField( "Titolo" , article.begin() ) ;
title += "</b>" ;
ui->Title->setHtml( title ) ;
ui->Abstract->setHtml( abstract ) ;
this->current_favorite = id ;
if ( bk.isFavoriteBookmarked(id) )
ui->AddFavorite->setDisabled( true );
else
ui->AddFavorite->setDisabled( false );
}
示例5: LoadWardenDataResult
void CWardenDataStorage::LoadWardenDataResult()
{
// Check if Warden is enabled by config before loading anything
if (!sWorld.getConfig(CONFIG_BOOL_ANTICHEAT_WARDEN))
{
sLog.outString(">> Warden disabled, loading checks skipped.");
sLog.outString();
return;
}
QueryResult *result = LoginDatabase.Query("SELECT `check`, `data`, `result`, `address`, `length`, `str` FROM warden_data_result");
uint32 count = 0;
if (!result)
{
BarGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
return;
}
BarGoLink bar((int)result->GetRowCount());
do
{
++count;
bar.step();
Field *fields = result->Fetch();
uint8 type = fields[0].GetUInt8();
uint32 id = GenerateInternalDataID();
WardenData *wd = new WardenData();
wd->Type = type;
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == DRIVER_CHECK)
{
std::string data = fields[1].GetCppString();
wd->i.SetHexStr(data.c_str());
int len = data.size() / 2;
if (wd->i.GetNumBytes() < len)
{
uint8 temp[24];
memset(temp, 0, len);
memcpy(temp, wd->i.AsByteArray(), wd->i.GetNumBytes());
std::reverse(temp, temp + len);
wd->i.SetBinary((uint8*)temp, len);
}
}
if (type == MEM_CHECK || type == MODULE_CHECK)
MemCheckIds.push_back(id);
if (type == MEM_CHECK || type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == PROC_CHECK)
{
wd->Address = fields[3].GetUInt32();
wd->Length = fields[4].GetUInt8();
}
// PROC_CHECK support missing
if (type == MEM_CHECK || type == MPQ_CHECK || type == LUA_STR_CHECK || type == DRIVER_CHECK || type == MODULE_CHECK)
wd->str = fields[5].GetCppString();
_data_map[id] = wd;
if (type == MPQ_CHECK || type == MEM_CHECK)
{
std::string result = fields[2].GetCppString();
WardenDataResult *wr = new WardenDataResult();
wr->res.SetHexStr(result.c_str());
int len = result.size() / 2;
if (wr->res.GetNumBytes() < len)
{
uint8 *temp = new uint8[len];
memset(temp, 0, len);
memcpy(temp, wr->res.AsByteArray(), wr->res.GetNumBytes());
std::reverse(temp, temp + len);
wr->res.SetBinary((uint8*)temp, len);
delete [] temp;
}
_result_map[id] = wr;
}
} while (result->NextRow());
delete result;
sLog.outString();
sLog.outString(">> Loaded %u warden data and results", count);
}
示例6: LoadWardenDataResult
void CWardenDataStorage::LoadWardenDataResult()
{
QueryResult result = LoginDatabase.Query("SELECT `check`, `data`, `result`, `address`, `length`, `str` FROM warden_data_result");
uint32 count = 0;
if (!result)
{
sLog->outString();
sLog->outString(">> Loaded %u warden data and results", count);
return;
}
do
{
++count;
Field *fields = result->Fetch();
uint8 type = fields[0].GetUInt8();
uint32 id = GenerateInternalDataID();
WardenData *wd = new WardenData();
wd->Type = type;
if (type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == DRIVER_CHECK)
{
std::string data = fields[1].GetString();
wd->i.SetHexStr(data.c_str());
int len = data.size() / 2;
if (wd->i.GetNumBytes() < len)
{
uint8 temp[24];
memset(temp, 0, len);
memcpy(temp, wd->i.AsByteArray(), wd->i.GetNumBytes());
std::reverse(temp, temp + len);
wd->i.SetBinary((uint8*)temp, len);
}
}
if (type == MEM_CHECK || type == MODULE_CHECK)
MemCheckIds.push_back(id);
if (type == MEM_CHECK || type == PAGE_CHECK_A || type == PAGE_CHECK_B || type == PROC_CHECK)
{
wd->Address = fields[3].GetUInt32();
wd->Length = fields[4].GetUInt8();
}
// PROC_CHECK support missing
if (type == MEM_CHECK || type == MPQ_CHECK || type == LUA_STR_CHECK || type == DRIVER_CHECK || type == MODULE_CHECK)
wd->str = fields[5].GetString();
_data_map[id] = wd;
if (type == MPQ_CHECK || type == MEM_CHECK)
{
std::string result = fields[2].GetString();
WardenDataResult *wr = new WardenDataResult();
wr->res.SetHexStr(result.c_str());
int len = result.size() / 2;
if (wr->res.GetNumBytes() < len)
{
uint8 *temp = new uint8[len];
memset(temp, 0, len);
memcpy(temp, wr->res.AsByteArray(), wr->res.GetNumBytes());
std::reverse(temp, temp + len);
wr->res.SetBinary((uint8*)temp, len);
delete [] temp;
}
_result_map[id] = wr;
}
} while (result->NextRow());
sLog->outString();
sLog->outString(">> Loaded %u warden data and results", count);
}
示例7: format
void XMLResultFormatter::format(const QueryResult& result,
std::stringstream& ss)
{
m_xmlDoc.clear();
m_xmlDoc.addDeclarationNode(result.getEncoding());
XMLNodeWrapperPtr pRootNode = m_xmlDoc.appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "result");
if (result.hasError())
{
formatError(pRootNode, result.getErrorMsg());
}
else
{
XMLNodeWrapperPtr resultNode = pRootNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "hits");
string str;
NumberFormatter::append(str, (int32_t)result.size());
resultNode->appendAttribute("number_hits", str);
str.clear();
NumberFormatter::append(str, result.getTotalHits());
resultNode->appendAttribute("total_hits", str);
str.clear();
NumberFormatter::append(str, result.getTimeCost());
resultNode->appendAttribute("cost", str);
QueryResult::Iterator it = result.iterator();
while (it.hasNext())
{
XMLNodeWrapperPtr pHitNode = resultNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "hit");
const ResultDocPtr& pResDoc = it.next();
if (result.hasShardId())
{
str.clear();
NumberFormatter::append(str, pResDoc->getShardId());
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"shardid", str);
}
if (result.hasDocId())
{
str.clear();
NumberFormatter::append(str, pResDoc->getDocId());
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"docid", str);
}
if (result.hasScore())
{
str.clear();
NumberFormatter::append(str, pResDoc->getScore(), 2);
pHitNode->appendNode(XMLDocumentWrapper::NODE_ELEMENT,
"score", str);
}
if (result.hasFields())
{
XMLNodeWrapperPtr pFieldsNode = pHitNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, "fields");
ResultDoc::Iterator fieldIt = pResDoc->iterator();
while (fieldIt.hasNext())
{
const ResultDoc::Field& field = fieldIt.next();
XMLNodeWrapperPtr pCDataNode = pFieldsNode->appendNode(
XMLDocumentWrapper::NODE_ELEMENT, field.first);
pCDataNode->appendNode(XMLDocumentWrapper::NODE_CDATA,
"", field.second);
}
}
} // end while
const QueryTracerPtr& pTracer = result.getTracer();
if (pTracer)
{
formatTracer(pRootNode, pTracer);
}
}
m_xmlDoc.print(ss);
}