MyGUI  3.2.0
MyGUI_WidgetUserData.cpp
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #include "MyGUI_Precompiled.h"
00023 #include "MyGUI_WidgetUserData.h"
00024 #include "MyGUI_Constants.h"
00025 
00026 namespace MyGUI
00027 {
00028 
00029     UserData::UserData()
00030     {
00031     }
00032 
00033     UserData::~UserData()
00034     {
00035     }
00036 
00037     void UserData::setUserString(const std::string& _key, const std::string& _value)
00038     {
00039         mMapUserString[_key] = _value;
00040     }
00041 
00043     const std::string& UserData::getUserString(const std::string& _key) const
00044     {
00045         MapString::const_iterator iter = mMapUserString.find(_key);
00046         if (iter != mMapUserString.end())
00047             return iter->second;
00048         return Constants::getEmptyString();
00049     }
00050 
00051     const MapString& UserData::getUserStrings() const
00052     {
00053         return mMapUserString;
00054     }
00055 
00056     bool UserData::clearUserString(const std::string& _key)
00057     {
00058         MapString::iterator iter = mMapUserString.find(_key);
00059         if (iter != mMapUserString.end())
00060         {
00061             mMapUserString.erase(iter);
00062             return true;
00063         }
00064         return false;
00065     }
00066 
00067     bool UserData::isUserString(const std::string& _key) const
00068     {
00069         return mMapUserString.find(_key) != mMapUserString.end();
00070     }
00071 
00072     void UserData::clearUserStrings()
00073     {
00074         mMapUserString.clear();
00075     }
00076 
00077     void UserData::setUserData(Any _data)
00078     {
00079         mUserData = _data;
00080     }
00081 
00082     void UserData::_setInternalData(Any _data)
00083     {
00084         mInternalData = _data;
00085     }
00086 
00087 } // namespace MyGUI