本文整理汇总了C++中CVariant::isUnsignedInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ CVariant::isUnsignedInteger方法的具体用法?C++ CVariant::isUnsignedInteger怎么用?C++ CVariant::isUnsignedInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVariant
的用法示例。
在下文中一共展示了CVariant::isUnsignedInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 "";
}
示例2: 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;
}