X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules%2Fsql.h;h=15e8260b6ec57e3e75326e3c19fc23f669a9572d;hb=79892a727e323dcc4bce7e9c0cf3c99c5fe61706;hp=dd33fc6761201bf84c93837fd075e2048a2b3096;hpb=b6f57c0f06f4905b04de6ec2069522d2263626c4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules/sql.h b/include/modules/sql.h index dd33fc676..15e8260b6 100644 --- a/include/modules/sql.h +++ b/include/modules/sql.h @@ -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& 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->GetRealName(); userinfo["ident"] = user->ident; userinfo["server"] = user->server->GetName(); userinfo["uuid"] = user->uuid;