From 680c646011ec55dd4c639a5b61d8c42a10272ae2 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 24 Jul 2009 16:05:18 +0000 Subject: More extensive testing, and documentation in the header files. --- server/src/luaquerymapper.h | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'server/src/luaquerymapper.h') 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 // 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; - }; -- cgit v1.2.3