本文整理汇总了C++中CVariant::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::empty方法的具体用法?C++ CVariant::empty怎么用?C++ CVariant::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::empty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowAndGetInput
int CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text, CVariant noLabel, CVariant yesLabel, CVariant customLabel, unsigned int autoCloseTime)
{
CGUIDialogYesNo *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO);
if (!dialog)
return false;
dialog->SetHeading(heading);
dialog->SetText(text);
if (autoCloseTime)
dialog->SetAutoClose(autoCloseTime);
dialog->m_bCanceled = false;
dialog->m_bCustom = false;
dialog->SetChoice(0, !noLabel.empty() ? noLabel : 106);
dialog->SetChoice(1, !yesLabel.empty() ? yesLabel : 107);
dialog->SetChoice(2, customLabel); // Button only visible when label is not empty
dialog->Open();
if (dialog->m_bCanceled)
return -1;
else if (dialog->m_bCustom)
return 2;
else if (dialog->IsConfirmed())
return 1;
else
return 0;
}
示例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: ExecuteAddon
JSONRPC_STATUS CAddonsOperations::ExecuteAddon(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, 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;
}
示例4: ShowAndGetInput
bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant text, bool &bCanceled, CVariant noLabel /* = "" */, CVariant yesLabel /* = "" */, unsigned int autoCloseTime)
{
CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
if (!dialog)
return false;
dialog->SetHeading(heading);
dialog->SetText(text);
if (autoCloseTime)
dialog->SetAutoClose(autoCloseTime);
dialog->m_bCanceled = false;
dialog->SetChoice(0, !noLabel.empty() ? noLabel : 106);
dialog->SetChoice(1, !yesLabel.empty() ? yesLabel : 107);
dialog->Open();
bCanceled = dialog->m_bCanceled;
return (dialog->IsConfirmed()) ? true : false;
}
示例5: ShowAndGetInput
bool CGUIDialogYesNo::ShowAndGetInput(CVariant heading, CVariant line0, CVariant line1, CVariant line2, bool &bCanceled, CVariant noLabel, CVariant yesLabel, unsigned int autoCloseTime /* = 0 */)
{
CGUIDialogYesNo *dialog = (CGUIDialogYesNo *)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
if (!dialog)
return false;
dialog->SetHeading(heading);
dialog->SetLine(0, line0);
dialog->SetLine(1, line1);
dialog->SetLine(2, line2);
if (autoCloseTime)
dialog->SetAutoClose(autoCloseTime);
dialog->SetChoice(0, !noLabel.empty() ? noLabel : 106);
dialog->SetChoice(1, !yesLabel.empty() ? yesLabel : 107);
dialog->m_bCanceled = false;
dialog->DoModal();
bCanceled = dialog->m_bCanceled;
return (dialog->IsConfirmed()) ? true : false;
}
示例6: validateOption
bool CMusicDbUrl::validateOption(const std::string &key, const CVariant &value)
{
if (!CDbUrl::validateOption(key, value))
return false;
// if the value is empty it will remove the option which is ok
// otherwise we only care about the "filter" option here
if (value.empty() || !StringUtils::EqualsNoCase(key, "filter"))
return true;
if (!value.isString())
return false;
CSmartPlaylist xspFilter;
if (!xspFilter.LoadFromJson(value.asString()))
return false;
// check if the filter playlist matches the item type
return xspFilter.GetType() == m_type;
}
示例7: 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();
}
示例8: validateOption
bool CMusicDbUrl::validateOption(const std::string &key, const CVariant &value)
{
if (!CDbUrl::validateOption(key, value))
return false;
// if the value is empty it will remove the option which is ok
// otherwise we only care about the "filter" option here
if (value.empty() || !StringUtils::EqualsNoCase(key, "filter"))
return true;
if (!value.isString())
return false;
if (!value.isObject())
return false;
// load type
CStdString type;
if (value.isMember("type") && value["type"].isString())
type = value["type"].asString();
// check if the filter playlist matches the item type
return type == m_type;
}
示例9: 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);
//.........这里部分代码省略.........
示例10: GetTextures
JSONRPC_STATUS CTextureOperations::GetTextures(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, 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;
}