当前位置: 首页>>代码示例>>C++>>正文


C++ DynamicIntegerSettingOptions::push_back方法代码示例

本文整理汇总了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;
}
开发者ID:,项目名称:,代码行数:67,代码来源:


注:本文中的DynamicIntegerSettingOptions::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。