本文整理汇总了C++中CVariant::end_array方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::end_array方法的具体用法?C++ CVariant::end_array怎么用?C++ CVariant::end_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::end_array方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleItemsParameter
bool CPlaylistOperations::HandleItemsParameter(int playlistid, const CVariant &itemParam, CFileItemList &items)
{
std::vector<CVariant> vecItems;
if (itemParam.isArray())
vecItems.assign(itemParam.begin_array(), itemParam.end_array());
else
vecItems.push_back(itemParam);
bool success = false;
for (std::vector<CVariant>::iterator itemIt = vecItems.begin(); itemIt != vecItems.end(); ++itemIt)
{
if (!CheckMediaParameter(playlistid, *itemIt))
continue;
switch (playlistid)
{
case PLAYLIST_VIDEO:
(*itemIt)["media"] = "video";
break;
case PLAYLIST_MUSIC:
(*itemIt)["media"] = "music";
break;
case PLAYLIST_PICTURE:
(*itemIt)["media"] = "pictures";
break;
}
success |= FillFileItemList(*itemIt, items);
}
return success;
}
示例2: ArrayToString
std::string ArrayToString(SortAttribute attributes, const CVariant &variant, const std::string &seperator = " / ")
{
std::vector<std::string> strArray;
if (variant.isArray())
{
for (CVariant::const_iterator_array it = variant.begin_array(); it != variant.end_array(); it++)
{
if (attributes & SortAttributeIgnoreArticle)
strArray.push_back(SortUtils::RemoveArticles(it->asString()));
else
strArray.push_back(it->asString());
}
return StringUtils::Join(strArray, seperator);
}
else if (variant.isString())
{
if (attributes & SortAttributeIgnoreArticle)
return SortUtils::RemoveArticles(variant.asString());
else
return variant.asString();
}
return "";
}
示例3: InternalWrite
bool CJSONVariantWriter::InternalWrite(yajl_gen g, const CVariant &value)
{
bool success = false;
switch (value.type())
{
case CVariant::VariantTypeInteger:
success = yajl_gen_status_ok == yajl_gen_integer(g, (long long int)value.asInteger());
break;
case CVariant::VariantTypeUnsignedInteger:
success = yajl_gen_status_ok == yajl_gen_integer(g, (long long int)value.asUnsignedInteger());
break;
case CVariant::VariantTypeDouble:
success = yajl_gen_status_ok == yajl_gen_double(g, value.asDouble());
break;
case CVariant::VariantTypeBoolean:
success = yajl_gen_status_ok == yajl_gen_bool(g, value.asBoolean() ? 1 : 0);
break;
case CVariant::VariantTypeString:
success = yajl_gen_status_ok == yajl_gen_string(g, (const unsigned char*)value.c_str(), (size_t)value.size());
break;
case CVariant::VariantTypeArray:
success = yajl_gen_status_ok == yajl_gen_array_open(g);
for (CVariant::const_iterator_array itr = value.begin_array(); itr != value.end_array() && success; ++itr)
success &= InternalWrite(g, *itr);
if (success)
success = yajl_gen_status_ok == yajl_gen_array_close(g);
break;
case CVariant::VariantTypeObject:
success = yajl_gen_status_ok == yajl_gen_map_open(g);
for (CVariant::const_iterator_map itr = value.begin_map(); itr != value.end_map() && success; ++itr)
{
success &= yajl_gen_status_ok == yajl_gen_string(g, (const unsigned char*)itr->first.c_str(), (size_t)itr->first.length());
if (success)
success &= InternalWrite(g, itr->second);
}
if (success)
success &= yajl_gen_status_ok == yajl_gen_map_close(g);
break;
case CVariant::VariantTypeConstNull:
case CVariant::VariantTypeNull:
default:
success = yajl_gen_status_ok == yajl_gen_null(g);
break;
}
return success;
}
示例4: ActivateWindow
JSONRPC_STATUS CGUIOperations::ActivateWindow(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant params = parameterObject["parameters"];
std::string cmd = "ActivateWindow(" + parameterObject["window"].asString();
for (CVariant::iterator_array param = params.begin_array(); param != params.end_array(); param++)
{
if (param->isString() && !param->empty())
cmd += "," + param->asString();
}
cmd += ")";
CBuiltins::Get().Execute(cmd);
return ACK;
}
示例5: ExecuteAddon
JSONRPC_STATUS CAddonsOperations::ExecuteAddon(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
std::string id = parameterObject["addonid"].asString();
AddonPtr addon;
if (!CServiceBroker::GetAddonMgr().GetAddon(id, addon) || addon.get() == NULL ||
addon->Type() < ADDON_VIZ || addon->Type() >= ADDON_MAX)
return InvalidParams;
std::string argv;
CVariant params = parameterObject["params"];
if (params.isObject())
{
for (CVariant::const_iterator_map it = params.begin_map(); it != params.end_map(); it++)
{
if (it != params.begin_map())
argv += ",";
argv += it->first + "=" + it->second.asString();
}
}
else if (params.isArray())
{
for (CVariant::const_iterator_array it = params.begin_array(); it != params.end_array(); it++)
{
if (it != params.begin_array())
argv += ",";
argv += StringUtils::Paramify(it->asString());
}
}
else if (params.isString())
{
if (!params.empty())
argv = StringUtils::Paramify(params.asString());
}
std::string cmd;
if (params.empty())
cmd = StringUtils::Format("RunAddon(%s)", id.c_str());
else
cmd = StringUtils::Format("RunAddon(%s, %s)", id.c_str(), argv.c_str());
if (params["wait"].asBoolean())
CApplicationMessenger::GetInstance().SendMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd);
else
CApplicationMessenger::GetInstance().PostMsg(TMSG_EXECUTE_BUILT_IN, -1, -1, nullptr, cmd);
return ACK;
}
示例6: Load
bool CDatabaseQueryRuleCombination::Load(const CVariant &obj, const IDatabaseQueryRuleFactory *factory)
{
if (!obj.isObject() && !obj.isArray())
return false;
CVariant child;
if (obj.isObject())
{
if (obj.isMember("and") && obj["and"].isArray())
{
m_type = CombinationAnd;
child = obj["and"];
}
else if (obj.isMember("or") && obj["or"].isArray())
{
m_type = CombinationOr;
child = obj["or"];
}
else
return false;
}
else
child = obj;
for (CVariant::const_iterator_array it = child.begin_array(); it != child.end_array(); it++)
{
if (!it->isObject())
continue;
if (it->isMember("and") || it->isMember("or"))
{
boost::shared_ptr<CDatabaseQueryRuleCombination> combo(factory->CreateCombination());
if (combo && combo->Load(*it, factory))
m_combinations.push_back(combo);
}
else
{
boost::shared_ptr<CDatabaseQueryRule> rule(factory->CreateRule());
if (rule && rule->Load(*it))
m_rules.push_back(rule);
}
}
return true;
}
示例7: CheckForAdditionalProperties
bool CAudioLibrary::CheckForAdditionalProperties(const CVariant &properties, const std::set<std::string> &checkProperties, std::set<std::string> &foundProperties)
{
if (!properties.isArray() || properties.empty())
return false;
std::set<std::string> checkingProperties = checkProperties;
for (CVariant::const_iterator_array itr = properties.begin_array(); itr != properties.end_array() && !checkingProperties.empty(); itr++)
{
if (!itr->isString())
continue;
std::string property = itr->asString();
if (checkingProperties.find(property) != checkingProperties.end())
{
checkingProperties.erase(property);
foundProperties.insert(property);
}
}
return !foundProperties.empty();
}
示例8: GetTextures
JSONRPC_STATUS CTextureOperations::GetTextures(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CFileItemList listItems;
CTextureDatabase db;
if (!db.Open())
return InternalError;
CDatabase::Filter dbFilter;
const CVariant &filter = parameterObject["filter"];
if (filter.isObject())
{
CVariant xspObj(CVariant::VariantTypeObject);
if (filter.isMember("field"))
{
xspObj["and"] = CVariant(CVariant::VariantTypeArray);
xspObj["and"].push_back(filter);
}
else
xspObj = filter;
// decipher the rules
CDatabaseQueryRuleCombination rule;
if (!rule.Load(xspObj, &db))
return InvalidParams;
dbFilter.AppendWhere(rule.GetWhereClause(db, ""));
}
// fetch textures from the database
CVariant items = CVariant(CVariant::VariantTypeArray);
if (!db.GetTextures(items, dbFilter))
return InternalError;
// return only what was asked for, plus textureid
CVariant prop = parameterObject["properties"];
prop.push_back("textureid");
if (!items.empty() && prop.isArray())
{
std::set<std::string> fields;
CVariant &item = items[0];
for (CVariant::const_iterator_map field = item.begin_map(); field != item.end_map(); ++field)
{
if (std::find(prop.begin_array(), prop.end_array(), field->first) == prop.end_array())
fields.insert(field->first);
}
// erase these fields
for (CVariant::iterator_array item = items.begin_array(); item != items.end_array(); ++item)
{
for (std::set<std::string>::const_iterator i = fields.begin(); i != fields.end(); ++i)
item->erase(*i);
}
if (fields.find("url") == fields.end())
{
// wrap cached url to something retrieval from Files.GetFiles()
for (CVariant::iterator_array item = items.begin_array(); item != items.end_array(); ++item)
{
CVariant &cachedUrl = (*item)["url"];
cachedUrl = CTextureUtils::GetWrappedImageURL(cachedUrl.asString());
}
}
}
result["textures"] = items;
return OK;
}
示例9: SetSettingValue
JSONRPC_STATUS CSettingsOperations::SetSettingValue(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
std::string settingId = parameterObject["setting"].asString();
CVariant value = parameterObject["value"];
SettingPtr setting = CServiceBroker::GetSettings().GetSetting(settingId);
if (setting == NULL ||
!setting->IsVisible())
return InvalidParams;
switch (setting->GetType())
{
case SettingTypeBool:
if (!value.isBoolean())
return InvalidParams;
result = std::static_pointer_cast<CSettingBool>(setting)->SetValue(value.asBoolean());
break;
case SettingTypeInteger:
if (!value.isInteger() && !value.isUnsignedInteger())
return InvalidParams;
result = std::static_pointer_cast<CSettingInt>(setting)->SetValue((int)value.asInteger());
break;
case SettingTypeNumber:
if (!value.isDouble())
return InvalidParams;
result = std::static_pointer_cast<CSettingNumber>(setting)->SetValue(value.asDouble());
break;
case SettingTypeString:
if (!value.isString())
return InvalidParams;
result = std::static_pointer_cast<CSettingString>(setting)->SetValue(value.asString());
break;
case SettingTypeList:
{
if (!value.isArray())
return InvalidParams;
std::vector<CVariant> values;
for (CVariant::const_iterator_array itValue = value.begin_array(); itValue != value.end_array(); ++itValue)
values.push_back(*itValue);
result = CServiceBroker::GetSettings().SetList(settingId, values);
break;
}
case SettingTypeNone:
case SettingTypeAction:
default:
return InvalidParams;
}
return OK;
}