summaryrefslogtreecommitdiff
path: root/src/modules/extra/m_sqlv2.h
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-21 08:37:42 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-21 08:37:42 +0000
commit2c6c072c1f5f19d1471feb43fa94bba0030e5fb6 (patch)
treeef8a94f1495cffad286323c3b959c93463d54ab7 /src/modules/extra/m_sqlv2.h
parent7fcb5797a6b98757d766997a1f4e48bf1eee8042 (diff)
API header and client module updates for new multi-parameter query request. Needs proper implementation in m_pgsql and documentation
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4471 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_sqlv2.h')
-rw-r--r--src/modules/extra/m_sqlv2.h56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/modules/extra/m_sqlv2.h b/src/modules/extra/m_sqlv2.h
index 714af2db6..aa90c7b95 100644
--- a/src/modules/extra/m_sqlv2.h
+++ b/src/modules/extra/m_sqlv2.h
@@ -1,16 +1,22 @@
#ifndef INSPIRCD_SQLAPI_2
#define INSPIRCD_SQLAPI_2
-#define SQLREQID "SQLv2 Request"
-#define SQLRESID "SQLv2 Result"
-#define SQLSUCCESS "You shouldn't be reading this (success)"
-
#include <string>
#include <vector>
#include <map>
#include "modules.h"
+/* This is the voodoo magic which lets us pass multiple parameters
+ * to the SQLrequest constructor..voodoo...
+ */
+#define SQLreq(a, b, c, d, e...) SQLrequest(a, b, c, (SQLquery(d), ##e))
+
+#define SQLREQID "SQLv2 Request"
+#define SQLRESID "SQLv2 Result"
+#define SQLSUCCESS "You shouldn't be reading this (success)"
+
enum SQLerrorNum { NO_ERROR, BAD_DBID, BAD_CONN, QSEND_FAIL };
+typedef std::vector<std::string> ParamL;
class SQLexception : public ModuleException
{
@@ -69,18 +75,54 @@ public:
}
};
+class SQLquery
+{
+public:
+ std::string q;
+ ParamL p;
+
+ SQLquery(const std::string &query)
+ : q(query)
+ {
+ log(DEBUG, "SQLquery constructor: %s", q.c_str());
+ }
+
+ SQLquery(const std::string &query, const ParamL &params)
+ : q(query), p(params)
+ {
+ log(DEBUG, "SQLquery constructor with %d params: %s", p.size(), q.c_str());
+ }
+
+ SQLquery& operator,(const std::string &foo)
+ {
+ p.push_back(foo);
+ return *this;
+ }
+
+ SQLquery& operator%(const std::string &foo)
+ {
+ p.push_back(foo);
+ return *this;
+ }
+};
+
class SQLrequest : public Request
{
public:
- std::string query;
+ SQLquery query;
std::string dbid;
bool pri;
unsigned long id;
SQLerror error;
- SQLrequest(Module* s, Module* d, const std::string &q, const std::string &id, bool p = false)
- : Request(SQLREQID, s, d), query(q), dbid(id), pri(p), id(0)
+ SQLrequest(Module* s, Module* d, const std::string &databaseid, const SQLquery &q)
+ : Request(SQLREQID, s, d), query(q), dbid(databaseid), pri(false), id(0)
+ {
+ }
+
+ void Priority(bool p = true)
{
+ pri = p;
}
void SetSource(Module* mod)