diff options
Diffstat (limited to 'server/src/luaquerymapper.h')
-rw-r--r-- | server/src/luaquerymapper.h | 36 |
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; - }; |