7#ifndef MYGUI_MENU_ITEM_TYPE_H_
8#define MYGUI_MENU_ITEM_TYPE_H_
28 MenuItemType(Enum _value = MAX) :
33 static MenuItemType parse(std::string_view _value)
39 std::string_view name = type.getValueName(value);
40 if (name.empty() || name == _value)
44 type.mValue =
static_cast<Enum>(value);
48 friend bool operator==(MenuItemType
const& a, MenuItemType
const& b)
50 return a.mValue == b.mValue;
53 friend bool operator!=(MenuItemType
const& a, MenuItemType
const& b)
55 return a.mValue != b.mValue;
58 friend std::ostream& operator<<(std::ostream& _stream,
const MenuItemType& _value)
60 _stream << _value.getValueName(_value.mValue);
64 friend std::istream& operator>>(std::istream& _stream, MenuItemType& _value)
68 _value = parse(value);
72 std::string_view print()
const
74 return getValueName(mValue);
83 std::string_view getValueName(
int _index)
const
85 if (_index < 0 || _index >= MAX)
87 static const std::string_view values[MAX] = {
"Normal",
"Popup",
"Separator"};
88 return values[_index];