本文整理汇总了C++中CVariant::asString方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::asString方法的具体用法?C++ CVariant::asString怎么用?C++ CVariant::asString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::asString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 "";
}
示例2: urlOptions
TEST(TestUrlOptions, AddOptions)
{
std::string ref = "foo=bar&key=value";
CUrlOptions urlOptions(ref);
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("foo", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("bar", value.asString().c_str());
}
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("key", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("value", value.asString().c_str());
}
ref = "foo=bar&key";
urlOptions.Clear();
urlOptions.AddOptions(ref);
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("foo", value));
EXPECT_TRUE(value.isString());
EXPECT_STREQ("bar", value.asString().c_str());
}
{
CVariant value;
EXPECT_TRUE(urlOptions.GetOption("key", value));
EXPECT_TRUE(value.isString());
EXPECT_TRUE(value.empty());
}
}
示例3: GoTo
JSONRPC_STATUS CPlayerOperations::GoTo(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant to = parameterObject["to"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_ITEM;
else if (strTo == "next")
actionID = ACTION_NEXT_ITEM;
else
return InvalidParams;
CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(new CAction(actionID)));
}
else if (to.isInteger())
{
if (IsPVRChannel())
CApplicationMessenger::GetInstance().SendMsg(TMSG_GUI_ACTION, WINDOW_INVALID, -1, static_cast<void*>(
new CAction(ACTION_CHANNEL_SWITCH, static_cast<float>(to.asInteger()))));
else
CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, static_cast<int>(to.asInteger()));
}
else
return InvalidParams;
break;
case Picture:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_PICTURE;
else if (strTo == "next")
actionID = ACTION_NEXT_PICTURE;
else
return InvalidParams;
SendSlideshowAction(actionID);
}
else
return FailedToExecute;
break;
case None:
default:
return FailedToExecute;
}
OnPlaylistChanged();
return ACK;
}
示例4: GoTo
JSONRPC_STATUS CPlayerOperations::GoTo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant to = parameterObject["to"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_ITEM;
else if (strTo == "next")
actionID = ACTION_NEXT_ITEM;
else
return InvalidParams;
CApplicationMessenger::Get().SendAction(CAction(actionID));
}
else if (to.isInteger())
{
if (IsPVRChannel())
CApplicationMessenger::Get().SendAction(CAction(ACTION_CHANNEL_SWITCH, (float)to.asInteger()));
else
CApplicationMessenger::Get().PlayListPlayerPlay((int)to.asInteger());
}
else
return InvalidParams;
break;
case Picture:
if (to.isString())
{
std::string strTo = to.asString();
int actionID;
if (strTo == "previous")
actionID = ACTION_PREV_PICTURE;
else if (strTo == "next")
actionID = ACTION_NEXT_PICTURE;
else
return InvalidParams;
SendSlideshowAction(actionID);
}
else
return FailedToExecute;
break;
case None:
default:
return FailedToExecute;
}
OnPlaylistChanged();
return ACK;
}
示例5: SetShuffle
JSONRPC_STATUS CPlayerOperations::SetShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CGUIWindowSlideShow *slideshow = NULL;
CVariant shuffle = parameterObject["shuffle"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
{
if (IsPVRChannel())
return FailedToExecute;
int playlistid = GetPlaylist(GetPlayer(parameterObject["playerid"]));
if (g_playlistPlayer.IsShuffled(playlistid))
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, false);
OnPlaylistChanged();
}
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::Get().PlayListPlayerShuffle(playlistid, true);
OnPlaylistChanged();
}
}
break;
}
case Picture:
slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (slideshow == NULL)
return FailedToExecute;
if (slideshow->IsShuffled())
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
return FailedToExecute;
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
slideshow->Shuffle();
}
break;
default:
return FailedToExecute;
}
return ACK;
}
示例6: SetShuffle
JSONRPC_STATUS CPlayerOperations::SetShuffle(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CGUIWindowSlideShow *slideshow = NULL;
CVariant shuffle = parameterObject["shuffle"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
{
if (IsPVRChannel())
return FailedToExecute;
int playlistid = GetPlaylist(GetPlayer(parameterObject["playerid"]));
if (CServiceBroker::GetPlaylistPlayer().IsShuffled(playlistid))
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 0);
OnPlaylistChanged();
}
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
{
CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_SHUFFLE, playlistid, 1);
OnPlaylistChanged();
}
}
break;
}
case Picture:
slideshow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowSlideShow>(WINDOW_SLIDESHOW);
if (slideshow == NULL)
return FailedToExecute;
if (slideshow->IsShuffled())
{
if ((shuffle.isBoolean() && !shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
return FailedToExecute;
}
else
{
if ((shuffle.isBoolean() && shuffle.asBoolean()) ||
(shuffle.isString() && shuffle.asString() == "toggle"))
slideshow->Shuffle();
}
break;
default:
return FailedToExecute;
}
return ACK;
}
示例7: FilterVar
static bool FilterVar(bool valid, const CVariant& variant,
const std::string& check)
{
if (!valid)
return false;
if (variant.isNull() || variant.asString().empty())
return false;
std::string regions = variant.asString();
return regions.find(check) == std::string::npos;
}
示例8: PumpNetworkEvents
bool CConnmanNetworkManager::PumpNetworkEvents(INetworkEventsCallback *callback)
{
bool result = false;
if (m_connection)
{
dbus_connection_read_write(m_connection, 0);
DBusMessage *msg = dbus_connection_pop_message(m_connection);
if (msg)
{
CDBusReplyPtr reply = CDBusReplyPtr(new CDBusReply(msg));
if (dbus_message_is_signal(msg, "net.connman.Manager", "PropertyChanged"))
{
CVariant key = reply->GetNextArgument();
m_properties[key.asString()] = reply->GetNextArgument();
UpdateNetworkManager();
if (strcmp(key.asString().c_str(), "Services") == 0)
callback->OnConnectionListChange(m_connections);
result = true;
}
else if (dbus_message_is_signal(msg, "net.connman.Manager", "StateChanged"))
{
CVariant stateString = reply->GetNextArgument();
result = true;
callback->OnConnectionStateChange(CConnmanConnection::ParseConnectionState(stateString.asString().c_str()));
}
else if (dbus_message_is_signal(msg, "net.connman.Manager", "NameAcquired"))
{
}
else
CLog::Log(LOGINFO, "ConnmanNetworkManager: Recieved an unknown signal %s", dbus_message_get_member(msg));
dbus_message_unref(msg);
}
}
for (size_t i = 0; i < m_connections.size(); i++)
{
if (((CConnmanConnection *)m_connections[i].get())->PumpNetworkEvents())
{
callback->OnConnectionChange(m_connections[i]);
result = true;
}
}
return result;
}
示例9: GetDirectory
bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
CStdString directory = strDirectory;
// check if the path contains a filter and if so load it and
// remove it from the path to get proper GUI view states etc
CSmartPlaylist filterXsp;
CMusicDbUrl musicUrl;
if (musicUrl.FromString(strDirectory))
{
CVariant filter;
if (musicUrl.GetOption("filter", filter))
{
// load the filter and if it's type does not match the
// path's item type reset it
if (filterXsp.LoadFromJson(filter.asString()) && !filterXsp.GetType().Equals(musicUrl.GetType().c_str()))
filterXsp.Reset();
// remove the "filter" option from the path
musicUrl.AddOption("filter", "");
}
directory = musicUrl.ToString();
}
items.SetArt("thumb", "");
bool bResult = CGUIMediaWindow::GetDirectory(directory, items);
if (bResult)
CMusicThumbLoader::FillThumb(items);
// (re-)apply the previously retrieved filter
// because it was reset in CGUIMediaWindow::GetDirectory()
if (!filterXsp.IsEmpty())
m_filter = filterXsp;
// add in the "New Playlist" item if we're in the playlists folder
if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
{
CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false));
newPlaylist->SetLabel(g_localizeStrings.Get(16035));
newPlaylist->SetLabelPreformated(true);
newPlaylist->m_bIsFolder = true;
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newplaylist://", false));
newPlaylist->SetLabel(g_localizeStrings.Get(525));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
newPlaylist->SetLabel(g_localizeStrings.Get(21437));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
}
return bResult;
}
示例10: ShowAndGetInput
// Show keyboard with initial value (aTextString) and replace with result string.
// Returns: true - successful display and input (empty result may return true or false depending on parameter)
// false - unsuccessful display of the keyboard or cancelled editing
bool CGUIKeyboardFactory::ShowAndGetInput(std::string& aTextString, CVariant heading, bool allowEmptyResult, bool hiddenInput /* = false */, unsigned int autoCloseMs /* = 0 */)
{
bool confirmed = false;
CGUIKeyboard *kb = NULL;
//heading can be a string or a localization id
std::string headingStr;
if (heading.isString())
headingStr = heading.asString();
else if (heading.isInteger() && heading.asInteger())
headingStr = g_localizeStrings.Get((uint32_t)heading.asInteger());
#if defined(TARGET_DARWIN_IOS)
kb = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardTouch>(WINDOW_DIALOG_KEYBOARD_TOUCH);
#else
kb = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogKeyboardGeneric>(WINDOW_DIALOG_KEYBOARD);
#endif
if (kb)
{
g_activeKeyboard = kb;
kb->startAutoCloseTimer(autoCloseMs);
confirmed = kb->ShowAndGetInput(keyTypedCB, aTextString, aTextString, headingStr, hiddenInput);
g_activeKeyboard = NULL;
}
if (confirmed)
{
if (!allowEmptyResult && aTextString.empty())
confirmed = false;
}
return confirmed;
}
示例11: Zoom
JSONRPC_STATUS CPlayerOperations::Zoom(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CVariant zoom = parameterObject["zoom"];
switch (GetPlayer(parameterObject["playerid"]))
{
case Picture:
if (zoom.isInteger())
SendSlideshowAction(ACTION_ZOOM_LEVEL_NORMAL + ((int)zoom.asInteger() - 1));
else if (zoom.isString())
{
std::string strZoom = zoom.asString();
if (strZoom == "in")
SendSlideshowAction(ACTION_ZOOM_IN);
else if (strZoom == "out")
SendSlideshowAction(ACTION_ZOOM_OUT);
else
return InvalidParams;
}
else
return InvalidParams;
return ACK;
case Video:
case Audio:
case None:
default:
return FailedToExecute;
}
}
示例12: Supports
bool CInputStream::Supports(const CFileItem &fileitem)
{
// check if a specific inputstream addon is requested
CVariant addon = fileitem.GetProperty("inputstreamaddon");
if (!addon.isNull())
{
if (addon.asString() != ID())
return false;
else
return true;
}
// check paths
CSingleLock lock(m_parentSection);
bool match = false;
for (auto &path : m_pathList)
{
if (path.empty())
continue;
CRegExp r(true, CRegExp::asciiOnly, path.c_str());
if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5)
{
match = true;
break;
}
}
return match;
}
示例13: SetHeading
void CGUIDialogKeyboard::SetHeading(const CVariant &heading)
{
if (heading.isString())
m_strHeading = heading.asString();
else if (heading.isInteger() && heading.asInteger())
m_strHeading = g_localizeStrings.Get((uint32_t)heading.asInteger());
}
示例14: GetChannels
JSONRPC_STATUS CPVROperations::GetChannels(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
if (!g_PVRManager.IsStarted())
return FailedToExecute;
CPVRChannelGroupsContainer *channelGroupContainer = g_PVRChannelGroups;
if (channelGroupContainer == NULL)
return FailedToExecute;
CPVRChannelGroupPtr channelGroup;
CVariant id = parameterObject["channelgroupid"];
if (id.isInteger())
channelGroup = channelGroupContainer->GetByIdFromAll((int)id.asInteger());
else if (id.isString())
channelGroup = channelGroupContainer->GetGroupAll(id.asString() == "allradio");
if (channelGroup == NULL)
return InvalidParams;
CFileItemList channels;
if (channelGroup->GetMembers(channels) < 0)
return InvalidParams;
HandleFileItemList("channelid", false, "channels", channels, parameterObject, result, true);
return OK;
}
示例15: GetLocalized
CStdString IDirectory::GetLocalized(const CVariant &var) const
{
if (var.isString())
return var.asString();
else if (var.isInteger() && var.asInteger())
return g_localizeStrings.Get(var.asInteger());
return "";
}