]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_sqlv2.h
Change this to use our md5 provider rather than MD5() in the query
[user/henk/code/inspircd.git] / src / modules / extra / m_sqlv2.h
index 76d39a8f63bccfbed96095ed62011d61f72507a3..f9da56c89d242171b1c30ddcd17898374618a9a5 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #ifndef INSPIRCD_SQLAPI_2
 #define INSPIRCD_SQLAPI_2
 
@@ -30,6 +43,7 @@ typedef std::deque<std::string> ParamL;
  */
 class SQLexception : public ModuleException
 {
+ public:
        SQLexception(const std::string &reason) : ModuleException(reason)
        {
        }
@@ -171,18 +185,18 @@ public:
        
        /** An overloaded operator for pushing parameters onto the parameter list
         */
-       SQLquery& operator,(const std::string &foo)
+       template<typename T> SQLquery& operator,(const T &foo)
        {
-               p.push_back(foo);
+               p.push_back(ConvToStr(foo));
                return *this;
        }
        
        /** An overloaded operator for pushing parameters onto the parameter list.
         * This has higher precedence than 'operator,' and can save on parenthesis.
         */
-       SQLquery& operator%(const std::string &foo)
+       template<typename T> SQLquery& operator%(const T &foo)
        {
-               p.push_back(foo);
+               p.push_back(ConvToStr(foo));
                return *this;
        }
 };
@@ -414,4 +428,43 @@ public:
        virtual void Free(SQLfieldList* fl) = 0;
 };
 
+
+/** SQLHost represents a <database> config line and is useful
+ * for storing in a map and iterating on rehash to see which
+ * <database> tags was added/removed/unchanged.
+ */
+class SQLhost
+{
+ public:
+       std::string             id;             /* Database handle id */
+       std::string             host;   /* Database server hostname */
+       std::string             ip;             /* resolved IP, needed for at least pgsql.so */
+       unsigned int    port;   /* Database server port */
+       std::string             name;   /* Database name */
+       std::string             user;   /* Database username */
+       std::string             pass;   /* Database password */
+       bool                    ssl;    /* If we should require SSL */
+
+       SQLhost()
+       {
+       }
+
+       SQLhost(const std::string& i, const std::string& h, unsigned int p, const std::string& n, const std::string& u, const std::string& pa, bool s)
+       : id(i), host(h), port(p), name(n), user(u), pass(pa), ssl(s)
+       {
+       }
+
+       /** Overload this to return a correct Data source Name (DSN) for
+        * the current SQL module.
+        */
+       std::string GetDSN();
+};
+
+/** Overload operator== for two SQLhost objects for easy comparison.
+ */
+bool operator== (const SQLhost& l, const SQLhost& r)
+{
+       return (l.id == r.id && l.host == r.host && l.port == r.port && l.name == r.name && l.user == l.user && l.pass == r.pass && l.ssl == r.ssl);
+}
+
 #endif