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


C++ Flags::remove方法代码示例

本文整理汇总了C++中Flags::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Flags::remove方法的具体用法?C++ Flags::remove怎么用?C++ Flags::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Flags的用法示例。


在下文中一共展示了Flags::remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

TEST(Flags, remove) {
  {
    Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
    Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L));
  }
  {
    Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE;
    Flags removed = ModifierFlag::SHIFT_R | ModifierFlag::CURSOR | ModifierFlag::EXTRA2 | ModifierFlag::NONE;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L));

    removed = ModifierFlag::SHIFT_R | ModifierFlag::NONE;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::CURSOR | ModifierFlag::EXTRA2));

    removed = 0;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_R | ModifierFlag::NONE));

    removed = 0;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::OPTION_L | ModifierFlag::COMMAND_R));
  }
  {
    // chain
    Flags flags = ModifierFlag::SHIFT_L | ModifierFlag::SHIFT_R | ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
    Flags removed = ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R;
    EXPECT_EQ(removed, flags.remove(ModifierFlag::SHIFT_L).remove(ModifierFlag::SHIFT_R));
  }
}
开发者ID:CharlseLee,项目名称:KeyRemap4MacBook,代码行数:27,代码来源:test.cpp

示例2: ptr

    bool
    KeyToKey::remap(RemapParams& remapParams)
    {
      if (remapParams.isremapped) return false;
      if (! fromkeychecker_.isFromKey(remapParams.params.ex_iskeydown, remapParams.params.key, FlagStatus::makeFlags(), fromKey_.key, fromKey_.flags)) return false;
      remapParams.isremapped = true;

      // ------------------------------------------------------------
      // handle EventType & Modifiers

      // Let's consider the following setting.
      //   __KeyToKey__ KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::A, ModifierFlag::SHIFT_R
      // In this setting, we need decrease SHIFT_R only once.
      // So, we transform values of fromKey_.
      //
      // [before]
      //   fromKey_.key   : KeyCode::SHIFT_R
      //   fromKey_.flags : ModifierFlag::SHIFT_R | ModifierFlag::NONE
      //
      // [after]
      //   fromKey_.key   : KeyCode::SHIFT_R
      //   fromKey_.flags : ModifierFlag::NONE
      //
      // Note: we need to apply this transformation after calling fromkeychecker_.isFromKey.

      Flags fromFlags = fromKey_.flags;
      fromFlags.remove(fromKey_.key.getModifierFlag());

      if (remapParams.params.ex_iskeydown) {
        retractInput();
      } else {
        restoreInput();
      }

      // ----------------------------------------
      // Handle beforeKeys_
      if (remapParams.params.ex_iskeydown) {
        FlagStatus::temporary_decrease(fromFlags);

        for (size_t i = 0; i < beforeKeys_.size(); ++i) {
          FlagStatus::temporary_increase(beforeKeys_[i].flags);

          Flags f = FlagStatus::makeFlags();
          KeyboardType keyboardType = remapParams.params.keyboardType;

          EventOutputQueue::FireKey::fire_downup(f, beforeKeys_[i].key, keyboardType);

          FlagStatus::temporary_decrease(beforeKeys_[i].flags);
        }

        FlagStatus::temporary_increase(fromFlags);
      }

      // ----------------------------------------
      // Handle toKeys_
      switch (toKeys_.size()) {
        case 0:
          break;

        case 1:
        {
          EventType newEventType = remapParams.params.ex_iskeydown ? EventType::DOWN : EventType::UP;
          KeyCode toKey = toKeys_[0].key;
          ModifierFlag toModifierFlag = toKey.getModifierFlag();

          if (toModifierFlag == ModifierFlag::NONE && ! VirtualKey::isKeyLikeModifier(toKey)) {
            // toKey
            FlagStatus::temporary_decrease(fromFlags);
            FlagStatus::temporary_increase(toKeys_[0].flags);

          } else {
            // toModifier or VirtualKey::isKeyLikeModifier
            if (toModifierFlag != ModifierFlag::NONE) {
              newEventType = EventType::MODIFY;
            }

            if (remapParams.params.ex_iskeydown) {
              FlagStatus::increase(toKeys_[0].flags | toModifierFlag);
              FlagStatus::decrease(fromFlags);
            } else {
              FlagStatus::decrease(toKeys_[0].flags | toModifierFlag);
              FlagStatus::increase(fromFlags);
            }
          }

          // ----------------------------------------
          Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(newEventType,
                                                                                         FlagStatus::makeFlags(),
                                                                                         toKey,
                                                                                         remapParams.params.keyboardType,
                                                                                         remapParams.params.repeat));
          if (! ptr) return false;
          Params_KeyboardEventCallBack& params = *ptr;

          if (remapParams.params.ex_iskeydown && ! isRepeatEnabled_) {
            KeyboardRepeat::cancel();
          } else {
            KeyboardRepeat::set(params);
          }
          EventOutputQueue::FireKey::fire(params);
//.........这里部分代码省略.........
开发者ID:Bilalh,项目名称:KeyRemap4MacBook,代码行数:101,代码来源:KeyToKey.cpp


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