PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
util.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
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 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 
20 #ifndef UTIL_H
21 #define UTIL_H
22 
23 #include <qlineedit.h>
24 #include <qlistwidget.h>
25 #include <qcombobox.h>
26 #include <QListWidget>
27 #include <qtablewidget.h>
28 
29 #include <luabind/luabind.hpp>
30 #include <lua_inclues/lua.hpp>
31 
32 #ifdef Q_CC_GNU
33 #define gcc_force_inline __attribute__((always_inline, gnu_inline))
34 #else
35 #define gcc_force_inline
36 #endif
37 
38 class util
39 {
40 public:
41  static void updateFilter(QLineEdit* searchEdit, QListWidget* itemList, QComboBox* typeBox);
42  static void memclear(QListWidget* wid);
43  static void memclear(QTableWidget* wid);
44  static void clearLayoutItems(QLayout* layout);
45  static bool contains(const QComboBox* b, const QString &s);
46  static QString filePath(QString s);
47  static bool strempty(const char* str);
48 
49  static QString resolveRelativeOrAbsolute(const QString &path, const QStringList& relativeLookup);
50 };
51 
52 namespace varadic_util
53 {
54  template<int ...>
55  struct seq { };
56 
57  template<int N, int ...S>
58  struct gens : gens<N-1, N-1, S...> { };
59 
60  template<int ...S>
61  struct gens<0, S...> {
62  typedef seq<S...> type;
63  };
64 }
65 
66 
67 
68 namespace luabind_utils {
69  template<typename T>
70  static inline gcc_force_inline QList<T> convArrayTo(luabind::object& obj){
71  QList<T> container;
72  for (luabind::iterator it(obj), end; it != end; ++it)
73  {
74  try{
75  container << luabind::object_cast<T>(*it);
76  } catch (luabind::cast_failed& e) { }
77  }
78  return container;
79  }
80 }
81 
82 #endif // UTIL_H
Definition: util.h:55
Definition: util.h:58
Definition: util.h:38