MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_WidgetUserData.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_WIDGET_USER_DATA_H__
23 #define __MYGUI_WIDGET_USER_DATA_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Any.h"
27
28 namespace MyGUI
29 {
30
32 class MYGUI_EXPORT UserData
33 {
34 public:
35 UserData();
36 virtual ~UserData();
37
39 void setUserString(const std::string& _key, const std::string& _value);
40
42 const std::string& getUserString(const std::string& _key) const;
43
45 const MapString& getUserStrings() const;
46
48 bool clearUserString(const std::string& _key);
49
51 bool isUserString(const std::string& _key) const;
52
54 void clearUserStrings();
55
57 void setUserData(Any _data);
58
60 template <typename ValueType>
61 ValueType* getUserData(bool _throw = true)
62 {
63 return mUserData.castType<ValueType>(_throw);
64 }
65
66 /*internal:*/
67 void _setInternalData(Any _data);
68
69 template <typename ValueType>
70 ValueType* _getInternalData(bool _throw = true)
71 {
72 return mInternalData.castType<ValueType>(_throw);
73 }
74
75 private:
76 // пользовательские данные
77 MapString mMapUserString;
78 Any mUserData;
79
80 // для внутренниего использования
81 Any mInternalData;
82 };
83
84 } // namespace MyGUI
85
86 #endif // __MYGUI_WIDGET_USER_DATA_H__
MyGUI_Prerequest.h
MyGUI::Any
Definition: MyGUI_Any.h:81
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::MapString
std::map< std::string, std::string > MapString
Definition: MyGUI_Types.h:53
MyGUI_Any.h
MyGUI::UserData
Definition: MyGUI_WidgetUserData.h:32
MyGUI::UserData::_getInternalData
ValueType * _getInternalData(bool _throw=true)
Definition: MyGUI_WidgetUserData.h:70
MyGUI::UserData::getUserData
ValueType * getUserData(bool _throw=true)
Definition: MyGUI_WidgetUserData.h:61