SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
LuaString.h
Go to the documentation of this file.
1#ifndef LUASTRING
2#define LUASTRING
3
4#include <lua.h>
5#include <string>
6
12{
18 {
19 characters = "";
20 }
21
28 void read(lua_State * lua, int index)
29 {
30 characters = lua_tostring(lua, index);
31 }
32
41 bool readField(lua_State * lua, const char * name)
42 {
43 int returnType = lua_getfield(lua, 1, name);
44
46 {
47 read(lua, 2);
48 lua_pop(lua,1);
49 return true;
50 }
51 else
52 {
53 lua_pop(lua,1);
54 return false;
55 }
56 }
57
66 bool readGlobal(lua_State * lua, const char * name)
67 {
68 int returnType = lua_getglobal(lua, name);
69
71 {
72 read(lua, -1);
73 lua_pop(lua,1);
74 return true;
75 }
76 else
77 {
78 lua_pop(lua,1);
79 return false;
80 }
81 }
82
83
84 bool operator ==(const std::string & rhs){ return characters == rhs; }
85 operator std::string() { return characters; }
86
87 std::string characters;
88};
89
90#endif /* LUASTRING */
glm::vec< L, float, glm::qualifier::highp > vec
Definition commandLine.h:214
Interop for a string in Lua.
Definition LuaString.h:12
std::string characters
Definition LuaString.h:87
bool operator==(const std::string &rhs)
Definition LuaString.h:84
LuaString()
Construct the string "".
Definition LuaString.h:17
bool readField(lua_State *lua, const char *name)
Read the string from a table field.
Definition LuaString.h:41
bool readGlobal(lua_State *lua, const char *name)
Read the string from a global table field.
Definition LuaString.h:66
void read(lua_State *lua, int index)
Read the string from stack index index.
Definition LuaString.h:28