MyGUI_WidgetUserData.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_WIDGET_USER_DATA_H_
#define MYGUI_WIDGET_USER_DATA_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Any.h"
namespace MyGUI
{
class MYGUI_EXPORT UserData
{
public:
virtual ~UserData() = default;
void setUserString(std::string_view _key, std::string_view _value);
std::string_view getUserString(std::string_view _key) const;
const MapString& getUserStrings() const;
bool clearUserString(std::string_view _key);
bool isUserString(std::string_view _key) const;
void clearUserStrings();
void setUserData(Any _data);
template<typename ValueType>
ValueType* getUserData(bool _throw = true) const
{
return mUserData.castType<ValueType>(_throw);
}
/*internal:*/
void _setInternalData(Any _data);
template<typename ValueType>
ValueType* _getInternalData(bool _throw = true) const
{
return mInternalData.castType<ValueType>(_throw);
}
private:
// пользовательские данные
MapString mMapUserString;
Any mUserData;
// для внутренниего использования
Any mInternalData;
};
} // namespace MyGUI
#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