00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 }
00316
00317 #endif // _DILUCULUM_LUA_VARIABLE_HPP_