MyGUI 3.4.1
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 {
22 MAX
23 };
24
25 ResizingPolicy(Enum _value = MAX) :
26 mValue(_value)
27 {
28 }
29
30 static ResizingPolicy parse(const std::string& _value)
31 {
32 ResizingPolicy type;
33 int value = 0;
34 while (true)
35 {
36 const char* name = type.getValueName(value);
37 if (strcmp(name, "") == 0 || 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 print() const
70 {
71 return getValueName(mValue);
72 }
73
74 int getValue() const
75 {
76 return mValue;
77 }
78
79 private:
80 const char* getValueName(int _index) const
81 {
82 static const char* values[MAX + 1] = { "Auto", "Fixed", "Fill", "" };
83 return values[(_index < MAX && _index >= 0) ? _index : MAX];
84 }
85
86 private:
87 Enum mValue;
88 };
89
90} // namespace MyGUI
91
92#endif // MYGUI_RESIZING_POLICY_H_
#define MYGUI_EXPORT
bool operator==(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
bool operator!=(const UString::_const_fwd_iterator &left, const UString::_const_fwd_iterator &right)
static ResizingPolicy parse(const std::string &_value)
std::string print() const
ResizingPolicy(Enum _value=MAX)