summaryrefslogtreecommitdiff
path: root/server/src/luaquerymapper.h
diff options
context:
space:
mode:
authordeva <deva>2009-07-24 16:05:18 +0000
committerdeva <deva>2009-07-24 16:05:18 +0000
commit680c646011ec55dd4c639a5b61d8c42a10272ae2 (patch)
tree171aea7bbd680a1dc7cf80bc5cdabc55c82a7618 /server/src/luaquerymapper.h
parent408c7c5b36e1058a76741a22876593ee8c042dd4 (diff)
More extensive testing, and documentation in the header files.
Diffstat (limited to 'server/src/luaquerymapper.h')
-rw-r--r--server/src/luaquerymapper.h36
1 files changed, 27 insertions, 9 deletions
diff --git a/server/src/luaquerymapper.h b/server/src/luaquerymapper.h
index 4648606..e8a25f8 100644
--- a/server/src/luaquerymapper.h
+++ b/server/src/luaquerymapper.h
@@ -33,7 +33,9 @@
#include <lauxlib.h>
// For class Value
-#include "database.h"
+#include "dbtypes.h"
+
+#include "exception.h"
/**
* The LUAQueryMapper class takes the result of an external data query and
@@ -41,23 +43,39 @@
*/
class LUAQueryMapper {
public:
- LUAQueryMapper();
+ /**
+ * Constructor.
+ * Initialises the LUA library, and opens a LUA instance.
+ * Throws an exception if any of these things fail.
+ */
+ LUAQueryMapper() throw(Exception);
~LUAQueryMapper();
/**
* Applies the mapping program to the result-namespace, and returns the
- * resulting value.
+ * resulting value. The map must return 3 values; value (a string), timestamp
+ * (an integer) and the source (string).
+ * If the program fails to load, fails to run, returns wrong number of values,
+ * or the wrong types, it will thorw an exception.
+ * @param mapper A std::string containing the mapping program.
+ * @return A Value object containing the three result values.
*/
- Value map(const std::string &mapper);
-
- void error(std::string message);
-
- void addQueryResult(QueryResult &result);
+ Value map(const std::string &mapper) throw(Exception);
+
+ /**
+ * Add a result to be included in the mapper namespace.
+ * If in some way the generated values fail (illegal names for example) an exception
+ * will be thrown.
+ * @param result The QueryResult object containing the values to add to the
+ * namespace.
+ */
+ void addQueryResult(QueryResult &result) throw(Exception);
private:
+ void error(std::string message) throw(Exception);
+
lua_State *L;
int clean_top;
-
};