MyGUI 3.2.2

MyGUI_WidgetUserData.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_WIDGET_USER_DATA_H_
8 #define MYGUI_WIDGET_USER_DATA_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Any.h"
12
13 namespace MyGUI
14 {
15
17 class MYGUI_EXPORT UserData
18 {
19 public:
20 UserData();
21 virtual ~UserData();
22
24 void setUserString(const std::string& _key, const std::string& _value);
25
27 const std::string& getUserString(const std::string& _key) const;
28
30 const MapString& getUserStrings() const;
31
33 bool clearUserString(const std::string& _key);
34
36 bool isUserString(const std::string& _key) const;
37
39 void clearUserStrings();
40
42 void setUserData(Any _data);
43
45 template <typename ValueType>
46 ValueType* getUserData(bool _throw = true) const
47 {
48 return mUserData.castType<ValueType>(_throw);
49 }
50
51 /*internal:*/
52 void _setInternalData(Any _data);
53
54 template <typename ValueType>
55 ValueType* _getInternalData(bool _throw = true) const
56 {
57 return mInternalData.castType<ValueType>(_throw);
58 }
59
60 private:
61 // пользовательские данные
62 MapString mMapUserString;
63 Any mUserData;
64
65 // для внутренниего использования
66 Any mInternalData;
67 };
68
69 } // namespace MyGUI
70
71 #endif // MYGUI_WIDGET_USER_DATA_H_
MyGUI_Prerequest.h
MyGUI::Any
Definition: MyGUI_Any.h:63
MyGUI
Definition: MyGUI_ActionController.h:14
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::UserData::getUserData
ValueType * getUserData(bool _throw=true) const
Definition: MyGUI_WidgetUserData.h:46
MyGUI::MapString
std::map< std::string, std::string > MapString
Definition: MyGUI_Types.h:38
MyGUI_Any.h
MyGUI::UserData
Definition: MyGUI_WidgetUserData.h:17
MyGUI::UserData::_getInternalData
ValueType * _getInternalData(bool _throw=true) const
Definition: MyGUI_WidgetUserData.h:55