MyGUI 3.4.1
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
13namespace MyGUI
14{
15
18 {
19 public:
20 virtual ~UserData() = default;
21
23 void setUserString(const std::string& _key, const std::string& _value);
24
26 const std::string& getUserString(const std::string& _key) const;
27
29 const MapString& getUserStrings() const;
30
32 bool clearUserString(const std::string& _key);
33
35 bool isUserString(const std::string& _key) const;
36
38 void clearUserStrings();
39
41 void setUserData(Any _data);
42
44 template <typename ValueType>
45 ValueType* getUserData(bool _throw = true) const
46 {
47 return mUserData.castType<ValueType>(_throw);
48 }
49
50 /*internal:*/
51 void _setInternalData(Any _data);
52
53 template <typename ValueType>
54 ValueType* _getInternalData(bool _throw = true) const
55 {
56 return mInternalData.castType<ValueType>(_throw);
57 }
58
59 private:
60 // пользовательские данные
61 MapString mMapUserString;
62 Any mUserData;
63
64 // для внутренниего использования
65 Any mInternalData;
66 };
67
68} // namespace MyGUI
69
70#endif // MYGUI_WIDGET_USER_DATA_H_
#define MYGUI_EXPORT
ValueType * getUserData(bool _throw=true) const
virtual ~UserData()=default
ValueType * _getInternalData(bool _throw=true) const
std::map< std::string, std::string > MapString
Definition: MyGUI_Types.h:39