LuaUserData.hpp

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * LuaUserData.hpp                                                              *
00003 * A C++ equivalent of a Lua userdata.                                          *
00004 *                                                                              *
00005 *                                                                              *
00006 * Copyright (C) 2005-2007 by Leandro Motta Barros.                             *
00007 *                                                                              *
00008 * Permission is hereby granted, free of charge, to any person obtaining a copy *
00009 * of this software and associated documentation files (the "Software"), to     *
00010 * deal in the Software without restriction, including without limitation the   *
00011 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  *
00012 * sell copies of the Software, and to permit persons to whom the Software is   *
00013 * furnished to do so, subject to the following conditions:                     *
00014 *                                                                              *
00015 * The above copyright notice and this permission notice shall be included in   *
00016 * all copies or substantial portions of the Software.                          *
00017 *                                                                              *
00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   *
00019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     *
00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE *
00021 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER       *
00022 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      *
00023 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS *
00024 * IN THE SOFTWARE.                                                             *
00025 \******************************************************************************/
00026 
00027 #ifndef _DILUCULUM_LUA_USER_DATA_HPP_
00028 #define _DILUCULUM_LUA_USER_DATA_HPP_
00029 
00030 #include <boost/scoped_array.hpp>
00031 #include <lua.hpp>
00032 #include <Diluculum/Types.hpp>
00033 
00034 
00035 namespace Diluculum
00036 {
00045    class LuaUserData
00046    {
00047       public:
00048 
00053          LuaUserData (size_t size);
00054 
00060          LuaUserData (const LuaUserData& other);
00061 
00066          const LuaUserData& operator= (const LuaUserData& rhs);
00067 
00071          size_t getSize() const { return size_; }
00072 
00074          void* getData() { return data_.get(); }
00075 
00079          const void* getData() const { return data_.get(); }
00080 
00089          bool operator> (const LuaUserData& rhs) const;
00090 
00098          bool operator< (const LuaUserData& rhs) const;
00099 
00107          bool operator== (const LuaUserData& rhs) const;
00108 
00110          bool operator!= (const LuaUserData& rhs) const;
00111 
00112       private:
00114          size_t size_;
00115 
00117          boost::scoped_array<char> data_;
00118    };
00119 
00120 } // namespace Diluculum
00121 
00122 #endif // _DILUCULUM_LUA_USER_DATA_HPP_

Generated on Tue Feb 6 09:30:26 2007 for Diluculum by  doxygen 1.4.6