LuaVariable.hpp

Go to the documentation of this file.
00001 /******************************************************************************\
00002 * LuaVariable.hpp                                                              *
00003 * A variable living in a Lua interpreter.                                      *
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_VARIABLE_HPP_
00028 #define _DILUCULUM_LUA_VARIABLE_HPP_
00029 
00030 #include <vector>
00031 #include <Diluculum/LuaValue.hpp>
00032 
00033 
00034 namespace Diluculum
00035 {
00043    class LuaVariable
00044    {
00045       friend class LuaState;
00046 
00047       public:
00069          const LuaValue& operator= (const LuaValue& rhs);
00070 
00076          LuaValue value() const;
00077 
00087          LuaVariable operator[] (const LuaValue& key) const;
00088 
00102          LuaValueList operator()(const LuaValueList& params);
00103 
00115          LuaValueList operator()();
00116 
00129          LuaValueList operator() (const LuaValue& param);
00130 
00145          LuaValueList operator() (const LuaValue& param1,
00146                                   const LuaValue& param2);
00147 
00164          LuaValueList operator() (const LuaValue& param1,
00165                                   const LuaValue& param2,
00166                                   const LuaValue& param3);
00167 
00186          LuaValueList operator() (const LuaValue& param1,
00187                                   const LuaValue& param2,
00188                                   const LuaValue& param3,
00189                                   const LuaValue& param4);
00190 
00211          LuaValueList operator() (const LuaValue& param1,
00212                                   const LuaValue& param2,
00213                                   const LuaValue& param3,
00214                                   const LuaValue& param4,
00215                                   const LuaValue& param5);
00216 
00225          bool operator== (const LuaValue& rhs) const
00226          { return value() == rhs; }
00227 
00234          bool operator== (const LuaVariable& rhs) const
00235          { return state_ == rhs.state_ && keys_ == rhs.keys_; }
00236 
00243          bool operator!= (const LuaVariable& rhs) const
00244          { return state_ != rhs.state_ || keys_ != rhs.keys_; }
00245 
00247          typedef std::vector<LuaValue> KeyList;
00248 
00253          const KeyList& getKeys() const { return keys_; }
00254 
00265          void pushLastTable();
00266 
00271          lua_State* getState() { return state_; }
00272 
00273       private:
00274 
00292          LuaVariable (lua_State* state, const LuaValue& key,
00293                       const KeyList& predKeys = KeyList());
00294 
00300          void pushTheReferencedValue() const;
00301 
00303          lua_State* state_;
00304 
00312          KeyList keys_;
00313    };
00314 
00315 } // namespace Diluculum
00316 
00317 #endif // _DILUCULUM_LUA_VARIABLE_HPP_

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