summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2014-02-01 11:48:54 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-02-02 09:42:58 (GMT)
commitf44ea24fda0f08195180215a30bc626d7c1907c5 (patch)
treea1bb160a98a497dbf01b82bbf559e99b6c1dfad9 /Sluift/Lua/Check.cpp
parent3d881ddd0b65d3a2bc1213386fb75fd95e4de691 (diff)
downloadswift-f44ea24fda0f08195180215a30bc626d7c1907c5.zip
swift-f44ea24fda0f08195180215a30bc626d7c1907c5.tar.bz2
Sluift: Add new_certificate
Change-Id: If4e4ef98c00f15c0a88557860f0377843a8713c0
Diffstat (limited to 'Sluift/Lua/Check.cpp')
-rw-r--r--Sluift/Lua/Check.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/Sluift/Lua/Check.cpp b/Sluift/Lua/Check.cpp
index 65ada7b..a9b8f02 100644
--- a/Sluift/Lua/Check.cpp
+++ b/Sluift/Lua/Check.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Remko Tronçon
+ * Copyright (c) 2013-2014 Remko Tronçon
* Licensed under the GNU General Public License.
* See the COPYING file for more information.
*/
@@ -12,6 +12,7 @@
#include <lua.hpp>
#include <Sluift/Lua/Exception.h>
+#include <Swiften/Base/ByteArray.h>
using namespace Swift;
@@ -43,6 +44,15 @@ std::string Lua::checkString(lua_State* L, int arg) {
return std::string(s);
}
+ByteArray Lua::checkByteArray(lua_State* L, int arg) {
+ size_t len;
+ const char *s = lua_tolstring(L, arg, &len);
+ if (!s) {
+ throw Lua::Exception(getArgTypeError(L, arg, LUA_TSTRING));
+ }
+ return createByteArray(s, len);
+}
+
void* Lua::checkUserDataRaw(lua_State* L, int arg) {
void* userData = lua_touserdata(L, arg);
if (!userData) {