MyGUI 3.4.3
MyGUI_ResizingPolicy.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_RESIZING_POLICY_H_
8#define MYGUI_RESIZING_POLICY_H_
9
10#include "MyGUI_Prerequest.h"
11
12namespace MyGUI
13{
14
16 {
17 enum Enum
18 {
23 };
24
26 mValue(_value)
27 {
28 }
29
30 static ResizingPolicy parse(std::string_view _value)
31 {
32 ResizingPolicy type;
33 int value = 0;
34 while (true)
35 {
36 std::string_view name = type.getValueName(value);
37 if (name.empty() || name == _value)
38 break;
39 value++;
40 }
41 type.mValue = Enum(value);
42 return type;
43 }
44
45 friend bool operator==(ResizingPolicy const& a, ResizingPolicy const& b)
46 {
47 return a.mValue == b.mValue;
48 }
49
50 friend bool operator!=(ResizingPolicy const& a, ResizingPolicy const& b)
51 {
52 return a.mValue != b.mValue;
53 }
54
55 friend std::ostream& operator<<(std::ostream& _stream, const ResizingPolicy& _value)
56 {
57 _stream << _value.getValueName(_value.mValue);
58 return _stream;
59 }
60
61 friend std::istream& operator>>(std::istream& _stream, ResizingPolicy& _value)
62 {
63 std::string value;
64 _stream >> value;
65 _value = parse(value);
66 return _stream;
67 }
68
69 std::string_view print() const
70 {
71 return getValueName(mValue);
72 }
73
74 int getValue() const
75 {
76 return mValue;
77 }
78
79 private:
80 std::string_view getValueName(int _index) const
81 {
82 if (_index < 0 || _index >= MAX)
83 return {};
84 static const std::string_view values[MAX] = {"Auto", "Fixed", "Fill"};
85 return values[_index];
86 }
87
88 private:
89 Enum mValue;
90 };
91
92} // namespace MyGUI
93
94#endif // MYGUI_RESIZING_POLICY_H_
#define MYGUI_EXPORT
ResizingPolicy(Enum _value=MAX)
friend bool operator!=(ResizingPolicy const &a, ResizingPolicy const &b)
friend std::ostream & operator<<(std::ostream &_stream, const ResizingPolicy &_value)
friend bool operator==(ResizingPolicy const &a, ResizingPolicy const &b)
std::string_view print() const
static ResizingPolicy parse(std::string_view _value)
friend std::istream & operator>>(std::istream &_stream, ResizingPolicy &_value)