本文整理汇总了C++中CVariant::isInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isInteger方法的具体用法?C++ CVariant::isInteger怎么用?C++ CVariant::isInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::isInteger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChannelGroupDetails
JSONRPC_STATUS CPVROperations::GetChannelGroupDetails(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;
FillChannelGroupDetails(channelGroup, parameterObject, result["channelgroupdetails"], false);
return OK;
}
示例2: OnMessage
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message)
{
switch (message.GetMessage())
{
case GUI_MSG_WINDOW_INIT:
{
m_delayedSetting.reset();
if (message.GetParam1() != WINDOW_INVALID)
{ // coming to this window first time (ie not returning back from some other window)
// so we reset our section and control states
m_iCategory = 0;
ResetControlStates();
}
if (AllowResettingSettings())
{
m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID);
m_resetSetting->SetLabel(10041);
m_resetSetting->SetHelp(10045);
m_resetSetting->SetControl(CreateControl("button"));
}
m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID);
m_dummyCategory->SetLabel(10046);
m_dummyCategory->SetHelp(10047);
break;
}
case GUI_MSG_WINDOW_DEINIT:
{
// cancel any delayed changes
if (m_delayedSetting != NULL)
{
m_delayedTimer.Stop();
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID());
OnMessage(message);
}
CGUIDialog::OnMessage(message);
FreeControls();
return true;
}
case GUI_MSG_FOCUSED:
{
CGUIDialog::OnMessage(message);
int focusedControl = GetFocusedControlID();
// cancel any delayed changes
if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl)
{
m_delayedTimer.Stop();
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid"
g_windowManager.SendThreadMessage(message, GetID());
}
// update the value of the previous setting (in case it was invalid)
else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
{
BaseSettingControlPtr control = GetSettingControl(m_iSetting);
if (control != NULL && control->GetSetting() != NULL && !control->IsValid())
{
CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid"
g_windowManager.SendThreadMessage(message, GetID());
}
}
CVariant description;
// check if we have changed the category and need to create new setting controls
if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size()))
{
int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS;
const CSettingCategory* category = m_categories.at(categoryIndex);
if (categoryIndex != m_iCategory)
{
if (!category->CanAccess())
{
// unable to go to this category - focus the previous one
SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0);
return false;
}
m_iCategory = categoryIndex;
CreateSettings();
}
description = category->GetHelp();
}
else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
{
m_iSetting = focusedControl;
CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
if (setting != NULL)
description = setting->GetHelp();
}
// set the description of the currently focused category/setting
if (description.isInteger() ||
(description.isString() && !description.empty()))
SetDescription(description);
//.........这里部分代码省略.........
示例3: Open
//.........这里部分代码省略.........
CPVRRecordings *recordingsContainer = g_PVRRecordings;
if (recordingsContainer == NULL)
return FailedToExecute;
CFileItemPtr fileItem = recordingsContainer->GetById((int)parameterObject["item"]["recordingid"].asInteger());
if (fileItem == NULL)
return InvalidParams;
CFileItemList *l = new CFileItemList; //don't delete,
l->Add(std::make_shared<CFileItem>(*fileItem));
CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l));
return ACK;
}
else
{
CFileItemList list;
if (FillFileItemList(parameterObject["item"], list) && list.Size() > 0)
{
bool slideshow = true;
for (int index = 0; index < list.Size(); index++)
{
if (!list[index]->IsPicture())
{
slideshow = false;
break;
}
}
if (slideshow)
{
CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (!slideshow)
return FailedToExecute;
SendSlideshowAction(ACTION_STOP);
slideshow->Reset();
for (int index = 0; index < list.Size(); index++)
slideshow->Add(list[index].get());
return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
}
else
{
// Handle the "playerid" option
if (!optionPlayer.isNull())
{
PLAYERCOREID playerId = EPC_NONE;
if (optionPlayer.isInteger())
{
playerId = (PLAYERCOREID)optionPlayer.asInteger();
// check if the there's actually a player with the given player ID
if (CPlayerCoreFactory::GetInstance().GetPlayerConfig(playerId) == NULL)
return InvalidParams;
// check if the player can handle at least the first item in the list
VECPLAYERCORES possiblePlayers;
CPlayerCoreFactory::GetInstance().GetPlayers(*list.Get(0).get(), possiblePlayers);
VECPLAYERCORES::const_iterator matchingPlayer = std::find(possiblePlayers.begin(), possiblePlayers.end(), playerId);
if (matchingPlayer == possiblePlayers.end())
return InvalidParams;
}
else if (!optionPlayer.isString() || optionPlayer.asString().compare("default") != 0)
return InvalidParams;
// set the next player to be used
g_application.m_eForcedNextPlayer = playerId;
}
// Handle "shuffled" option
if (optionShuffled.isBoolean())
list.SetProperty("shuffled", optionShuffled);
// Handle "repeat" option
if (!optionRepeat.isNull())
list.SetProperty("repeat", ParseRepeatState(optionRepeat));
// Handle "resume" option
if (list.Size() == 1)
{
if (optionResume.isBoolean() && optionResume.asBoolean())
list[0]->m_lStartOffset = STARTOFFSET_RESUME;
else if (optionResume.isDouble())
list[0]->SetProperty("StartPercent", optionResume);
else if (optionResume.isObject())
list[0]->m_lStartOffset = (int)(ParseTimeInSeconds(optionResume) * 75.0);
}
auto l = new CFileItemList(); //don't delete
l->Copy(list);
CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l));
}
return ACK;
}
else
return InvalidParams;
}
return InvalidParams;
}
示例4: 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;
}
示例5:
TEST(TestUrlOptions, AddOption)
{
const char *keyChar = "char";
const char *keyString = "string";
const char *keyEmpty = "empty";
const char *keyInt = "int";
const char *keyFloat = "float";
const char *keyDouble = "double";
const char *keyBool = "bool";
const char *valueChar = "valueChar";
const std::string valueString = "valueString";
const char *valueEmpty = "";
int valueInt = 1;
float valueFloat = 1.0f;
double valueDouble = 1.0;
bool valueBool = true;
CVariant variantValue;
CUrlOptions urlOptions;
urlOptions.AddOption(keyChar, valueChar);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyChar, variantValue));
EXPECT_TRUE(variantValue.isString());
EXPECT_STREQ(valueChar, variantValue.asString().c_str());
}
urlOptions.AddOption(keyString, valueString);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyString, variantValue));
EXPECT_TRUE(variantValue.isString());
EXPECT_STREQ(valueString.c_str(), variantValue.asString().c_str());
}
urlOptions.AddOption(keyEmpty, valueEmpty);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyEmpty, variantValue));
EXPECT_TRUE(variantValue.isString());
EXPECT_STREQ(valueEmpty, variantValue.asString().c_str());
}
urlOptions.AddOption(keyInt, valueInt);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyInt, variantValue));
EXPECT_TRUE(variantValue.isInteger());
EXPECT_EQ(valueInt, (int)variantValue.asInteger());
}
urlOptions.AddOption(keyFloat, valueFloat);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyFloat, variantValue));
EXPECT_TRUE(variantValue.isDouble());
EXPECT_EQ(valueFloat, variantValue.asFloat());
}
urlOptions.AddOption(keyDouble, valueDouble);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyDouble, variantValue));
EXPECT_TRUE(variantValue.isDouble());
EXPECT_EQ(valueDouble, variantValue.asDouble());
}
urlOptions.AddOption(keyBool, valueBool);
{
CVariant variantValue;
EXPECT_TRUE(urlOptions.GetOption(keyBool, variantValue));
EXPECT_TRUE(variantValue.isBoolean());
EXPECT_EQ(valueBool, variantValue.asBoolean());
}
}