当前位置: 首页>>代码示例>>C++>>正文


C++ CVariant::isArray方法代码示例

本文整理汇总了C++中CVariant::isArray方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isArray方法的具体用法?C++ CVariant::isArray怎么用?C++ CVariant::isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVariant的用法示例。


在下文中一共展示了CVariant::isArray方法的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;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:32,代码来源:PlaylistOperations.cpp

示例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 "";
}
开发者ID:evilhamster,项目名称:xbmc,代码行数:25,代码来源:SortUtils.cpp

示例3: PushObject

void CJSONVariantParser::PushObject(CVariant variant)
{
  if (m_status == ParseObject)
  {
    (*m_parse[m_parse.size() - 1])[m_key] = variant;
    m_parse.push_back(&(*m_parse[m_parse.size() - 1])[m_key]);
  }
  else if (m_status == ParseArray)
  {
    CVariant *temp = m_parse[m_parse.size() - 1];
    temp->push_back(variant);
    m_parse.push_back(&(*temp)[temp->size() - 1]);
  }
  else if (m_parse.size() == 0)
  {
    m_parse.push_back(new CVariant(variant));
  }

  if (variant.isObject())
    m_status = ParseObject;
  else if (variant.isArray())
    m_status = ParseArray;
  else
    m_status = ParseVariable;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: ExecuteAddon

JSONRPC_STATUS CAddonsOperations::ExecuteAddon(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
}
开发者ID:BigNoid,项目名称:xbmc,代码行数:47,代码来源:AddonsOperations.cpp

示例5: 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;
}
开发者ID:B0k0,项目名称:xbmc,代码行数:45,代码来源:DatabaseQuery.cpp

示例6: 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();
}
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:21,代码来源:AudioLibrary.cpp

示例7: PopObject

void CJSONVariantParser::PopObject()
{
  CVariant *variant = m_parse[m_parse.size() - 1];
  m_parse.pop_back();

  if (m_parse.size())
  {
    variant = m_parse[m_parse.size() - 1];
    if (variant->isObject())
      m_status = ParseObject;
    else if (variant->isArray())
      m_status = ParseArray;
    else
      m_status = ParseVariable;
  }
  else if (m_callback)
  {
    m_callback->onParsed(variant);
    delete variant;

    m_parse.clear();
    m_status = ParseVariable;
  }
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例8: GetTextures

JSONRPC_STATUS CTextureOperations::GetTextures(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:67,代码来源:TextureOperations.cpp

示例9: SetSettingValue

JSONRPC_STATUS CSettingsOperations::SetSettingValue(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, 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;
}
开发者ID:micahg,项目名称:xbmc,代码行数:61,代码来源:SettingsOperations.cpp


注:本文中的CVariant::isArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。