本文整理汇总了C++中DynamicIntegerSettingOptions::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicIntegerSettingOptions::push_back方法的具体用法?C++ DynamicIntegerSettingOptions::push_back怎么用?C++ DynamicIntegerSettingOptions::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicIntegerSettingOptions
的用法示例。
在下文中一共展示了DynamicIntegerSettingOptions::push_back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIntegerOptions
static bool GetIntegerOptions(const CSetting* setting, DynamicIntegerSettingOptions& options, std::set<int>& selectedOptions)
{
const CSettingInt *pSettingInt = NULL;
if (setting->GetType() == SettingTypeInteger)
{
pSettingInt = static_cast<const CSettingInt*>(setting);
selectedOptions.insert(pSettingInt->GetValue());
}
else if (setting->GetType() == SettingTypeList)
{
const CSettingList *settingList = static_cast<const CSettingList*>(setting);
if (settingList->GetElementType() != SettingTypeInteger)
return false;
pSettingInt = static_cast<const CSettingInt*>(settingList->GetDefinition());
std::vector<CVariant> list = CSettingUtils::GetList(settingList);
for (const auto& itValue : list)
{
if (!itValue.isInteger())
return false;
selectedOptions.insert((int)itValue.asInteger());
}
}
else
return false;
switch (pSettingInt->GetOptionsType())
{
case SettingOptionsTypeStatic:
{
const StaticIntegerSettingOptions& settingOptions = pSettingInt->GetOptions();
for (const auto& option : settingOptions)
options.push_back(std::make_pair(g_localizeStrings.Get(option.first), option.second));
break;
}
case SettingOptionsTypeDynamic:
{
DynamicIntegerSettingOptions settingOptions = const_cast<CSettingInt*>(pSettingInt)->UpdateDynamicOptions();
for (const auto& option : settingOptions)
options.push_back(std::make_pair(option.first, option.second));
break;
}
case SettingOptionsTypeNone:
default:
{
const CSettingControlFormattedRange *control = static_cast<const CSettingControlFormattedRange*>(pSettingInt->GetControl());
for (int i = pSettingInt->GetMinimum(); i <= pSettingInt->GetMaximum(); i += pSettingInt->GetStep())
{
std::string strLabel;
if (i == pSettingInt->GetMinimum() && control->GetMinimumLabel() > -1)
strLabel = g_localizeStrings.Get(control->GetMinimumLabel());
else if (control->GetFormatLabel() > -1)
strLabel = StringUtils::Format(g_localizeStrings.Get(control->GetFormatLabel()).c_str(), i);
else
strLabel = StringUtils::Format(control->GetFormatString().c_str(), i);
options.push_back(std::make_pair(strLabel, i));
}
break;
}
}
return true;
}