2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef LUAAPI__LOADER_H
12 #define LUAAPI__LOADER_H
16 #include <boost/variant.hpp>
19 #include "loader/image.h"
20 #include "luaapi/luavalue.h"
35 bool operator()(const QRect
& a
, const QRect
& b
) {
36 return a
.x() != b
.x() ? a
.x() < b
.x() :
37 a
.y() != b
.y() ? a
.y() < b
.y() :
38 a
.width() != b
.width() ? a
.width() < b
.width() :
39 a
.height() < b
.height();
43 typedef std::map
<QRect
, QImage
, RectLess
> ImageMap
;
44 typedef boost::variant
<QImage
, ImageMap
> ImageOrMap
;
48 QString m_error_string
;
53 static const luaL_Reg lualibs
[];
55 template<typename T
> struct create_value_data
;
56 template<typename T
> static void retrieve(create_value_data
<T
>*, lua_State
*l
, int pos
);
57 template<typename T
> static int create_value_func(lua_State
*l
);
58 static int import_func(lua_State
* l
);
60 void initialize(::Loader::Context
*ctx
);
63 * Add the theme table to the environment, with all theme metadata.
65 void addMetaData(const ThemeInfo
& theme
);
67 Loader(::Loader::Context
*ctx
, const ThemeInfo
& theme
);
72 lua_State
* state() const { return m_state
; }
73 bool runFile(const QString
& file
, bool set_dir
= true);
75 template<typename T
> T
getValue(const QString
& key
, int size
= 0,
76 const LuaValueMap
* args
= NULL
, bool allow_nil
= false);
78 bool error() { return m_error
; }
79 void clearError() { m_error
= false; }
80 QString
errorString() { return m_error_string
; }
83 } //end namespace LuaApi
86 #endif // LUAAPI__LOADERAPI_H