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


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

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


在下文中一共展示了CVariant::push_back方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetSong

void CGUIDialogSongInfo::SetSong(CFileItem *item)
{
  *m_song = *item;
  m_song->LoadMusicTag();
  m_startUserrating = m_song->GetMusicInfoTag()->GetUserrating();
  MUSIC_INFO::CMusicInfoLoader::LoadAdditionalTagInfo(m_song.get());
   // set artist thumb as well
  CMusicDatabase db;
  db.Open();
  if (item->IsMusicDb())
  {
    std::vector<int> artists;
    CVariant artistthumbs;
    db.GetArtistsBySong(item->GetMusicInfoTag()->GetDatabaseId(), true, artists);
    for (std::vector<int>::const_iterator artistId = artists.begin(); artistId != artists.end(); ++artistId)
    {
      std::string thumb = db.GetArtForItem(*artistId, MediaTypeArtist, "thumb");
      if (!thumb.empty())
        artistthumbs.push_back(thumb);
    }
    if (artistthumbs.size())
    {
      m_song->SetProperty("artistthumbs", artistthumbs);
      m_song->SetProperty("artistthumb", artistthumbs[0]);
    }
  }
  else if (m_song->HasMusicInfoTag() && !m_song->GetMusicInfoTag()->GetArtist().empty())
  {
    int idArtist = db.GetArtistByName(m_song->GetMusicInfoTag()->GetArtist()[0]);
    std::string thumb = db.GetArtForItem(idArtist, MediaTypeArtist, "thumb");
    if (!thumb.empty())
      m_song->SetProperty("artistthumb", thumb);
  }
  m_needsUpdate = false;
}
开发者ID:krattai,项目名称:sht_tv,代码行数:35,代码来源:GUIDialogSongInfo.cpp

示例2: GetPlayers

JSONRPC_STATUS CPlayerOperations::GetPlayers(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  std::string media = parameterObject["media"].asString();
  result = CVariant(CVariant::VariantTypeArray);
  std::vector<std::string> players;

  if (media == "all")
  {
    CPlayerCoreFactory::GetInstance().GetPlayers(players);
  }
  else
  {
    bool video = false;
    if (media == "video")
      video = true;
    CPlayerCoreFactory::GetInstance().GetPlayers(players, true, video);
  }

  for (auto playername: players)
  {
    CVariant player(CVariant::VariantTypeObject);
    player["name"] = playername;

    player["playsvideo"] = CPlayerCoreFactory::GetInstance().PlaysVideo(playername);
    player["playsaudio"] = CPlayerCoreFactory::GetInstance().PlaysAudio(playername);
    player["type"] = CPlayerCoreFactory::GetInstance().GetPlayerType(playername);

    result.push_back(player);
  }

  return OK;
}
开发者ID:DaHenchmen,项目名称:DHMC,代码行数:32,代码来源:PlayerOperations.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: GetPlayers

JSONRPC_STATUS CPlayerOperations::GetPlayers(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  std::string media = parameterObject["media"].asString();
  result = CVariant(CVariant::VariantTypeArray);
  VECPLAYERCORES players;

  if (media == "all")
    CPlayerCoreFactory::GetInstance().GetPlayers(players);
  else
  {
    bool video = false;
    if (media == "video")
      video = true;

    CPlayerCoreFactory::GetInstance().GetPlayers(players, true, video);
  }

  for (VECPLAYERCORES::const_iterator itPlayer = players.begin(); itPlayer != players.end(); ++itPlayer)
  {
    PLAYERCOREID playerId = *itPlayer;
    const CPlayerCoreConfig* playerConfig = CPlayerCoreFactory::GetInstance().GetPlayerConfig(playerId);
    if (playerConfig == NULL)
      continue;

    CVariant player(CVariant::VariantTypeObject);
    player["playercoreid"] = static_cast<int>(playerId);
    player["name"] = playerConfig->GetName();

    switch (playerConfig->GetType())
    {
      case EPC_EXTPLAYER:
        player["type"] = "external";
        break;

      case EPC_UPNPPLAYER:
        player["type"] = "remote";
        break;

      default:
        player["type"] = "internal";
        break;
    }

    player["playsvideo"] = playerConfig->PlaysVideo();
    player["playsaudio"] = playerConfig->PlaysAudio();

    result.push_back(player);
  }

  return OK;
}
开发者ID:Karlson2k,项目名称:xbmc,代码行数:51,代码来源:PlayerOperations.cpp

示例5: Parse

void CXMLVariantParser::Parse(const TiXmlElement *valueNode, CVariant &value)
{
    CStdString type = valueNode->Attribute("type");
    if (type.Equals("object"))
    {
        const TiXmlElement *memberNode = valueNode->FirstChildElement("value");
        while (memberNode)
        {
            const char *member = memberNode->Attribute("key");

            if (member)
                Parse(memberNode, value[member]);

            memberNode = memberNode->NextSiblingElement("value");
        }
    }
    else if (type.Equals("array"))
    {
        const TiXmlElement *memberNode = valueNode->FirstChildElement("value");
        while (memberNode)
        {
            CVariant member;
            Parse(memberNode, member);
            value.push_back(member);
            memberNode = memberNode->NextSiblingElement("value");
        }
    }
    else if (type.Equals("integer"))
    {
        value = (int64_t)atoi(valueNode->FirstChild()->Value());
    }
    else if (type.Equals("unsignedinteger"))
    {
        value = (uint64_t)atol(valueNode->FirstChild()->Value());
    }
    else if (type.Equals("boolean"))
    {
        CStdString boolean = valueNode->FirstChild()->Value();
        value = boolean == "true";
    }
    else if (type.Equals("string"))
    {
        value = valueNode->FirstChild()->Value();
    }
    else if (type.Equals("double"))
    {
        value = (float)atof(valueNode->FirstChild()->Value());
    }
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例6: Save

bool CSmartPlaylistRule::Save(CVariant &obj) const
{
  if (obj.isNull() || m_parameter.empty())
    return false;

  CVariant rule(CVariant::VariantTypeObject);
  rule["field"] = TranslateField(m_field);
  rule["operator"] = TranslateOperator(m_operator);

  rule["value"] = CVariant(CVariant::VariantTypeArray);
  for (vector<CStdString>::const_iterator it = m_parameter.begin(); it != m_parameter.end(); it++)
    rule["value"].push_back(*it);

  obj.push_back(rule);
  return true;
}
开发者ID:mmankarious,项目名称:xbmc,代码行数:16,代码来源:SmartPlayList.cpp

示例7: GetTextures

bool CTextureDatabase::GetTextures(CVariant &items, const Filter &filter)
{
  try
  {
    if (NULL == m_pDB.get()) return false;
    if (NULL == m_pDS.get()) return false;

    std::string sql = "SELECT %s FROM texture JOIN sizes ON (texture.id=sizes.idtexture AND sizes.size=1)";
    std::string sqlFilter;
    if (!CDatabase::BuildSQL("", filter, sqlFilter))
      return false;

    sql = PrepareSQL(sql, !filter.fields.empty() ? filter.fields.c_str() : "*") + sqlFilter;
    if (!m_pDS->query(sql))
      return false;

    while (!m_pDS->eof())
    {
      CVariant texture;
      texture["textureid"] = m_pDS->fv(0).get_asInt();
      texture["url"] = m_pDS->fv(1).get_asString();
      texture["cachedurl"] = m_pDS->fv(2).get_asString();
      texture["imagehash"] = m_pDS->fv(3).get_asString();
      texture["lasthashcheck"] = m_pDS->fv(4).get_asString();
      CVariant size(CVariant::VariantTypeObject);
      // 5 is sizes.idtexture
      size["size"]  = m_pDS->fv(6).get_asInt();
      size["width"] = m_pDS->fv(7).get_asInt();
      size["height"] = m_pDS->fv(8).get_asInt();
      size["usecount"] = m_pDS->fv(9).get_asInt();
      size["lastused"] = m_pDS->fv(10).get_asString();
      texture["sizes"] = CVariant(CVariant::VariantTypeArray);
      texture["sizes"].push_back(size);
      items.push_back(texture);
      m_pDS->next();
    }
    m_pDS->close();
    return true;
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "%s, failed", __FUNCTION__);
  }
  return false;
}
开发者ID:Almarefa,项目名称:xbmc,代码行数:45,代码来源:TextureDatabase.cpp

示例8: ParseType

CVariant CDBusUtil::ParseType(DBusMessageIter *itr)
{
  CVariant value;
  const char *    string  = NULL;
  dbus_int32_t    int32   = 0;
  dbus_uint32_t   uint32  = 0;
  dbus_int64_t    int64   = 0;
  dbus_uint64_t   uint64  = 0;
  dbus_bool_t     boolean = false;
  double          doublev = 0;

  int type = dbus_message_iter_get_arg_type(itr);
  switch (type)
  {
  case DBUS_TYPE_OBJECT_PATH:
  case DBUS_TYPE_STRING:
    dbus_message_iter_get_basic(itr, &string);
    value = string;
    break;
  case DBUS_TYPE_UINT32:
    dbus_message_iter_get_basic(itr, &uint32);
    value = (uint64_t)uint32;
    break;
  case DBUS_TYPE_BYTE:
  case DBUS_TYPE_INT32:
    dbus_message_iter_get_basic(itr, &int32);
    value = (int64_t)int32;
    break;
  case DBUS_TYPE_UINT64:
    dbus_message_iter_get_basic(itr, &uint64);
    value = (uint64_t)uint64;
    break;
  case DBUS_TYPE_INT64:
    dbus_message_iter_get_basic(itr, &int64);
    value = (int64_t)int64;
    break;
  case DBUS_TYPE_BOOLEAN:
    dbus_message_iter_get_basic(itr, &boolean);
    value = (bool)boolean;
    break;
  case DBUS_TYPE_DOUBLE:
    dbus_message_iter_get_basic(itr, &doublev);
    value = (double)doublev;
    break;
  case DBUS_TYPE_ARRAY:
    DBusMessageIter array;
    dbus_message_iter_recurse(itr, &array);

    value = CVariant::VariantTypeArray;

    do
    {
      CVariant item = ParseType(&array);
      if (!item.isNull())
        value.push_back(item);
    } while (dbus_message_iter_next(&array));
    break;
  }

  return value;
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:61,代码来源:DBusUtil.cpp

示例9: 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

示例10: SerializeSettingListValues

void CSettingsOperations::SerializeSettingListValues(const std::vector<CVariant> &values, CVariant &obj)
{
  obj = CVariant(CVariant::VariantTypeArray);
  for (std::vector<CVariant>::const_iterator itValue = values.begin(); itValue != values.end(); ++itValue)
    obj.push_back(*itValue);
}
开发者ID:micahg,项目名称:xbmc,代码行数:6,代码来源:SettingsOperations.cpp


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