本文整理汇总了C++中CVariant::isString方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isString方法的具体用法?C++ CVariant::isString怎么用?C++ CVariant::isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::isString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
}
示例2: 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;
}
示例3: 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;
}
示例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: 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;
}
示例7: 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 "";
}
示例8: 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;
}
}
示例9: 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;
}
示例10: 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());
}
示例11: GetLocalized
std::string CGUIDialogBoxBase::GetLocalized(const CVariant &var) const
{
if (var.isString())
return var.asString();
else if (var.isInteger() && var.asInteger())
return g_localizeStrings.Get((uint32_t)var.asInteger());
return "";
}
示例12: 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 "";
}
示例13: SetInputType
void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, CVariant heading)
{
m_inputType = type;
if (heading.isString())
m_inputHeading = heading.asString();
else if (heading.isInteger() && heading.asInteger())
m_inputHeading = g_localizeStrings.Get(static_cast<uint32_t>(heading.asInteger()));
//! @todo Verify the current input string?
}
示例14: SetDescription
void CGUIWindowSettingsCategory::SetDescription(const CVariant &label)
{
if (GetControl(CONTROL_DESCRIPTION) == NULL)
return;
if (label.isString())
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, label.asString());
else if (label.isInteger() && label.asInteger() >= 0)
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, (int)label.asInteger());
else
SET_CONTROL_LABEL(CONTROL_DESCRIPTION, "");
}
示例15: VariantToLocalizedString
std::string CBaseEvent::VariantToLocalizedString(const CVariant& variant)
{
if (variant.isString())
return variant.asString();
if (variant.isInteger() && variant.asInteger() > 0)
return g_localizeStrings.Get(static_cast<uint32_t>(variant.asInteger()));
if (variant.isUnsignedInteger() && variant.asUnsignedInteger() > 0)
return g_localizeStrings.Get(static_cast<uint32_t>(variant.asUnsignedInteger()));
return "";
}