Add missing index_tuple.hpp header.
[luabind.git] / examples / regexp / regex_wrap.cpp
blob6a924cb241127058b1e55ea2c991220f0aa0daa3
1 #include <boost/cregex.hpp>
3 extern "C"
5 #include "lua.h"
6 #include "lauxlib.h"
7 #include "lualib.h"
10 #include <luabind/luabind.hpp>
12 namespace
14 bool match(boost::RegEx& r, const char* s)
16 return r.Match(s);
19 bool search(boost::RegEx& r, const char* s)
21 return r.Search(s);
23 } // namespace unnamed
26 void wrap_regex(lua_State* L)
28 using boost::RegEx;
29 using namespace luabind;
31 module(L)
33 class_<RegEx>("regex")
34 .def(constructor<const char*>())
35 .def(constructor<const char*, bool>())
36 .def("match", match)
37 .def("search", search)
38 .def("what", &RegEx::What)
39 .def("matched", &RegEx::Matched)
40 .def("length", &RegEx::Length)
41 .def("position", &RegEx::Position)
45 int main()
47 lua_State* L = lua_open();
48 lua_baselibopen(L);
49 lua_strlibopen(L);
50 luabind::open(L);
52 wrap_regex(L);
54 lua_dofile(L, "regex.lua");
56 lua_close(L);