MyGUI: MyGUI_WidgetUserData.h Source File

MyGUI 3.4.3

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
17 class MYGUI_EXPORT UserData
18 {
19 public:
20 virtual ~UserData() = default;
21
23 void setUserString(std::string_view _key, std::string_view _value);
24
26 std::string_view getUserString(std::string_view _key) const;
27
29 const MapString& getUserStrings() const;
30
32 bool clearUserString(std::string_view _key);
33
35 bool isUserString(std::string_view _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_
MyGUI_Any.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI::Any
Definition MyGUI_Any.h:56
MyGUI::UserData
Definition MyGUI_WidgetUserData.h:18
MyGUI::UserData::clearUserString
bool clearUserString(std::string_view _key)
Definition MyGUI_WidgetUserData.cpp:33
MyGUI::UserData::isUserString
bool isUserString(std::string_view _key) const
Definition MyGUI_WidgetUserData.cpp:44
MyGUI::UserData::setUserString
void setUserString(std::string_view _key, std::string_view _value)
Definition MyGUI_WidgetUserData.cpp:14
MyGUI::UserData::getUserString
std::string_view getUserString(std::string_view _key) const
Definition MyGUI_WidgetUserData.cpp:20
MyGUI::UserData::getUserData
ValueType * getUserData(bool _throw=true) const
Definition MyGUI_WidgetUserData.h:45
MyGUI::UserData::~UserData
virtual ~UserData()=default
MyGUI::UserData::setUserData
void setUserData(Any _data)
Definition MyGUI_WidgetUserData.cpp:54
MyGUI::UserData::clearUserStrings
void clearUserStrings()
Definition MyGUI_WidgetUserData.cpp:49
MyGUI::UserData::_getInternalData
ValueType * _getInternalData(bool _throw=true) const
Definition MyGUI_WidgetUserData.h:54
MyGUI::UserData::getUserStrings
const MapString & getUserStrings() const
Definition MyGUI_WidgetUserData.cpp:28
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::MapString
std::map< std::string, std::string, std::less<> > MapString
Definition MyGUI_Types.h:40