本文整理汇总了C++中DataList::emplace_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DataList::emplace_back方法的具体用法?C++ DataList::emplace_back怎么用?C++ DataList::emplace_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::emplace_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getData
Client::DataList Client::getData(const string& query) {
QJsonDocument root;
QString temp = QString::fromStdString(query);
QByteArray bytearray = query.c_str();
QString query_string = QString::fromUtf8(bytearray.data(), bytearray.size());
qDebug() << "query_string: " << query_string;
QString uri = getQueryString(query_string);
qDebug() << "uri: " << uri;
get(uri, root);
DataList result;
QVariantMap variant = root.toVariant().toMap();
// Iterate through the weather data
for (const QVariant &i : variant["businesses"].toList()) {
QVariantMap item = i.toMap();
QString name = removeTestInfo(item["name"].toString());
qDebug() << "name: " << name;
QString business_url = item["business_url"].toString();
qDebug() << "business_url: " << business_url;
QString s_photo_url = item["s_photo_url"].toString();
qDebug() << "s_photo_url: " << s_photo_url;
QString photo_url = item["photo_url"].toString();
qDebug() << "photo_url: " << photo_url;
QString rating_s_img_url = item["rating_s_img_url"].toString();
qDebug() << "rating_s_img_url: " << rating_s_img_url;
QString address = item["address"].toString();
qDebug() << "address: " << address;
QString telephone = item["telephone"].toString();
qDebug() << "telephone: " << telephone;
QVariantList deals = item["deals"].toList();
QString summary;
if ( deals.count() > 0 ) {
QVariantMap temp = deals.first().toMap();
summary = temp["description"].toString();
}
qDebug() << "summary: " << summary;
// Add a result to the weather list
result.emplace_back(
Data { name.toStdString(), business_url.toStdString(), s_photo_url.toStdString(),
photo_url.toStdString(), rating_s_img_url.toStdString(),
address.toStdString(), telephone.toStdString(), summary.toStdString() });
}
return result;
}