MyGUI  3.4.0
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 
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_
MyGUI::UserData
Definition: MyGUI_WidgetUserData.h:18
MyGUI::UserData::~UserData
virtual ~UserData()=default
MyGUI::Any
Definition: MyGUI_Any.h:64
MyGUI_Prerequest.h
MyGUI::UserData::getUserData
ValueType * getUserData(bool _throw=true) const
Definition: MyGUI_WidgetUserData.h:45
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:89
MyGUI::MapString
std::map< std::string, std::string > MapString
Definition: MyGUI_Types.h:39
MyGUI::UserData::_getInternalData
ValueType * _getInternalData(bool _throw=true) const
Definition: MyGUI_WidgetUserData.h:54
MyGUI
Definition: MyGUI_ActionController.h:15
MyGUI_Any.h