]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/sql.h
Replace most usages of "GECOS" with "real" or "real name".
[user/henk/code/inspircd.git] / include / modules / sql.h
index dd33fc6761201bf84c93837fd075e2048a2b3096..1f5bb7ff3f7cb469e79f6d3950d18666c1999622 100644 (file)
@@ -42,7 +42,7 @@ namespace SQL
        enum ErrorCode
        {
                /** No error has occurred. */
-               NO_ERROR,
+               SUCCESS,
 
                /** The database identifier is invalid. */
                BAD_DBID,
@@ -122,6 +122,15 @@ class SQL::Result : public classbase
         * @param result A reference to the vector to store column names in.
         */
        virtual void GetCols(std::vector<std::string>& result) = 0;
+
+       /**
+        * Check if there's a column with the specified name in the result
+        *
+        * @param the column name
+        * @param on success, this is the column index
+        * @returns true, or false if the column is not found
+        */
+       virtual bool HasColumn(const std::string& column, size_t& index) = 0;
 };
 
 /** SQL::Error holds the error state of a request.
@@ -132,7 +141,7 @@ class SQL::Error
 {
  private:
        /** The custom error message if one has been specified. */
-       const char* message;
+       const std::string message;
 
  public:
        /** The code which represents this error. */
@@ -142,8 +151,7 @@ class SQL::Error
         * @param c A code which represents this error.
         */
        Error(ErrorCode c)
-               : message(NULL)
-               , code(c)
+               : code(c)
        {
        }
 
@@ -151,7 +159,7 @@ class SQL::Error
         * @param c A code which represents this error.
         * @param m A custom error message.
         */
-       Error(ErrorCode c, const char* m)
+       Error(ErrorCode c, const std::string m)
                : message(m)
                , code(c)
        {
@@ -160,8 +168,8 @@ class SQL::Error
        /** Retrieves the error message. */
        const char* ToString() const
        {
-               if (message)
-                       return message;
+               if (!message.empty())
+                       return message.c_str();
 
                switch (code)
                {
@@ -252,7 +260,7 @@ inline void SQL::PopulateUserInfo(User* user, ParamMap& userinfo)
        userinfo["nick"] = user->nick;
        userinfo["host"] = user->GetRealHost();
        userinfo["ip"] = user->GetIPString();
-       userinfo["gecos"] = user->fullname;
+       userinfo["real"] = user->fullname;
        userinfo["ident"] = user->ident;
        userinfo["server"] = user->server->GetName();
        userinfo["uuid"] = user->uuid;