Initial revision
[luabind.git] / examples / regexp / regex_wrap.cpp
blob54afe91202ea51a9bc001d439f2907215048657f
1 #include <boost/cregex.hpp>
3 #include <luabind/luabind.hpp>
5 extern "C"
7 #include "lauxlib.h"
8 #include "lualib.h"
11 void wrap_regex(lua_State* L)
13 using boost::RegEx;
14 using namespace luabind;
16 class_<RegEx>(L, "regex")
17 .def(constructor<const char*>())
18 .def(constructor<const char*, bool>())
19 .def("match", (bool(RegEx::*)(const char*, unsigned int))&RegEx::Match)
20 .def("search", (bool(RegEx::*)(const char*, unsigned int))&RegEx::Search)
21 .def("what", &RegEx::What)
22 .def("matched", &RegEx::Matched)
23 .def("length", &RegEx::Length)
24 .def("position", &RegEx::Position)
25 .enum_("flags")
27 value("match_default", boost::match_default),
28 value("match_prev_avail", boost::match_prev_avail),
29 value("match_not_bob", boost::match_not_bob)
34 void test_wrap_regex()
36 lua_State* L = lua_open();
37 lua_baselibopen(L);
38 lua_strlibopen(L);
40 wrap_regex(L);
42 lua_dofile(L, "regex.lua");
44 lua_close(L);