本文整理汇总了C++中InfoMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ InfoMap::insert方法的具体用法?C++ InfoMap::insert怎么用?C++ InfoMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InfoMap
的用法示例。
在下文中一共展示了InfoMap::insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: infoPredicate
mitk::PropertyPersistence::InfoResultType mitk::PropertyPersistence::GetInfo(const std::string &propertyName,
const MimeTypeNameType &mime,
bool allowMimeWildCard,
bool allowNameRegEx) const
{
SelectFunctionType select = [propertyName, mime](const InfoMap::value_type &x) {
return infoPredicate(x, propertyName, mime);
};
InfoMap selection = SelectInfo(m_InfoMap, select);
if (allowNameRegEx)
{
select = [propertyName, mime](const InfoMap::value_type &x) { return infoPredicateRegEx(x, propertyName, mime); };
InfoMap regExSelection = SelectInfo(m_InfoMap, select);
selection.insert(regExSelection.begin(), regExSelection.end());
}
if (selection.empty() && allowMimeWildCard)
{ // no perfect match => second run through with "any mime type"
select = [propertyName](const InfoMap::value_type &x) {
return infoPredicate(x, propertyName, PropertyPersistenceInfo::ANY_MIMETYPE_NAME());
};
selection = SelectInfo(m_InfoMap, select);
if (allowNameRegEx)
{
select = [propertyName](const InfoMap::value_type &x) {
return infoPredicateRegEx(x, propertyName, PropertyPersistenceInfo::ANY_MIMETYPE_NAME());
};
InfoMap regExSelection = SelectInfo(m_InfoMap, select);
selection.insert(regExSelection.begin(), regExSelection.end());
}
}
InfoResultType result;
for (const auto &pos : selection)
{
result.push_back(pos.second->UnRegExByName(propertyName).GetPointer());
}
return result;
}
示例2:
mitk::PropertyPersistence::InfoMap mitk::PropertyPersistence::SelectInfo(const InfoMap &infoMap,
const SelectFunctionType &selectFunction)
{
InfoMap result;
for (auto pos : infoMap)
{
if (selectFunction(pos))
{
result.insert(pos);
}
}
return result;
};
示例3: ProcessRequest
bool UPNPSubscription::ProcessRequest(HTTPRequest *pRequest)
{
if (!pRequest)
return false;
if (pRequest->m_sBaseUrl != "/Subscriptions")
return false;
if (pRequest->m_sMethod != "event")
return false;
LOG(VB_UPNP, LOG_DEBUG, LOC + QString("%1\n%2")
.arg(pRequest->m_sRawRequest).arg(pRequest->m_sPayload));
if (pRequest->m_sPayload.isEmpty())
return true;
pRequest->m_eResponseType = ResponseTypeHTML;
QString nt = pRequest->m_mapHeaders["nt"];
QString nts = pRequest->m_mapHeaders["nts"];
bool no = (pRequest->m_eType == RequestTypeNotify);
if (nt.isEmpty() || nts.isEmpty() || !no)
{
pRequest->m_nResponseStatus = 400;
return true;
}
pRequest->m_nResponseStatus = 412;
if (nt != "upnp:event" || nts != "upnp:propchange")
return true;
QString usn = pRequest->m_mapParams["usn"];
QString sid = pRequest->m_mapHeaders["sid"];
if (usn.isEmpty() || sid.isEmpty())
return true;
// N.B. Validating the usn and uuid here might mean blocking for some time
// while waiting for a subscription to complete. While this operates in a
// worker thread, worker threads are a limited resource which we could
// rapidly overload if a number of events arrive. Instead let the
// subscribing objects validate the usn - the uuid should be superfluous.
QString seq = pRequest->m_mapHeaders["seq"];
// mediatomb sends some extra character(s) at the end of the payload
// which throw Qt, so try and trim them off
int loc = pRequest->m_sPayload.lastIndexOf("propertyset>");
QString payload = (loc > -1) ? pRequest->m_sPayload.left(loc + 12) :
pRequest->m_sPayload;
LOG(VB_UPNP, LOG_DEBUG, LOC + QString("Payload:\n%1").arg(payload));
pRequest->m_nResponseStatus = 400;
QDomDocument body;
QString error;
int errorCol = 0;
int errorLine = 0;
if (!body.setContent(payload, true, &error, &errorLine, &errorCol))
{
LOG(VB_GENERAL, LOG_ERR, LOC +
QString("Failed to parse event: Line: %1 Col: %2 Error: '%3'")
.arg(errorLine).arg(errorCol).arg(error));
return true;
}
LOG(VB_UPNP, LOG_DEBUG, LOC + "/n/n" + body.toString(4) + "/n/n");
QDomNodeList properties = body.elementsByTagName("property");
InfoMap results;
// this deals with both one argument per property (compliant) and mutliple
// arguments per property as sent by mediatomb
for (int i = 0; i < properties.size(); i++)
{
QDomNodeList arguments = properties.at(i).childNodes();
for (int j = 0; j < arguments.size(); j++)
{
QDomElement e = arguments.at(j).toElement();
if (!e.isNull() && !e.text().isEmpty() && !e.tagName().isEmpty())
results.insert(e.tagName(), e.text());
}
}
// using MythObservable allows multiple objects to subscribe to the same
// service but is less efficient from an eventing perspective, especially
// if multiple objects are subscribing
if (!results.isEmpty())
{
pRequest->m_nResponseStatus = 200;
results.insert("usn", usn);
results.insert("seq", seq);
MythInfoMapEvent me("UPNP_EVENT", results);
dispatch(me);
}
return true;
}
示例4: GetAddon
bool CAddonDatabase::GetAddon(int id, AddonPtr &addon)
{
try
{
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS2.get()) return false;
std::string sql = "SELECT addon.*,"
" broken.reason,"
" addonextra.key, addonextra.value,"
" dependencies.addon, dependencies.version, dependencies.optional"
" FROM addon"
" LEFT JOIN broken"
" ON broken.addonID = addon.addonID"
" LEFT JOIN addonextra"
" ON addonextra.id = addon.id"
" LEFT JOIN dependencies"
" ON dependencies.id = addon.id";
sql += PrepareSQL(" WHERE addon.id=%i", id);
m_pDS2->query(sql);
if (!m_pDS2->eof())
{
const dbiplus::query_data &data = m_pDS2->get_result_set().records;
const dbiplus::sql_record* const record = data[0];
CAddonBuilder builder;
builder.SetId(record->at(addon_addonID).get_asString());
builder.SetType(TranslateType(record->at(addon_type).get_asString()));
builder.SetVersion(AddonVersion(record->at(addon_version).get_asString()));
builder.SetMinVersion(AddonVersion(record->at(addon_minversion).get_asString()));
builder.SetName(record->at(addon_name).get_asString());
builder.SetSummary(record->at(addon_summary).get_asString());
builder.SetDescription(record->at(addon_description).get_asString());
builder.SetChangelog(record->at(addon_changelog).get_asString());
builder.SetDisclaimer(record->at(addon_disclaimer).get_asString());
builder.SetAuthor(record->at(addon_author).get_asString());
builder.SetBroken(record->at(broken_reason).get_asString());
builder.SetPath(record->at(addon_path).get_asString());
builder.SetIcon(record->at(addon_icon).get_asString());
builder.SetFanart(record->at(addon_fanart).get_asString());
InfoMap extrainfo;
ADDONDEPS dependencies;
/* while this is a cartesion join and we'll typically get multiple rows, we rely on the fact that
extrainfo and dependencies are maps, so insert() will insert the first instance only */
for (dbiplus::query_data::const_iterator i = data.begin(); i != data.end(); ++i)
{
const dbiplus::sql_record* const record = *i;
if (!record->at(addonextra_key).get_asString().empty())
extrainfo.insert(std::make_pair(record->at(addonextra_key).get_asString(), record->at(addonextra_value).get_asString()));
if (!m_pDS2->fv(dependencies_addon).get_asString().empty())
dependencies.insert(std::make_pair(record->at(dependencies_addon).get_asString(), std::make_pair(AddonVersion(record->at(dependencies_version).get_asString()), record->at(dependencies_optional).get_asBool())));
}
builder.SetExtrainfo(std::move(extrainfo));
builder.SetDependencies(std::move(dependencies));
addon = builder.Build();
return NULL != addon.get();
}
}
catch (...)
{
CLog::Log(LOGERROR, "%s failed on addon %i", __FUNCTION__, id);
}
addon.reset();
return false;
}