enum ErrorCode
{
/** No error has occurred. */
- NO_ERROR,
+ SUCCESS,
/** The database identifier is invalid. */
BAD_DBID,
* @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.
{
private:
/** The custom error message if one has been specified. */
- const char* message;
+ const std::string message;
public:
/** The code which represents this error. */
* @param c A code which represents this error.
*/
Error(ErrorCode c)
- : message(NULL)
- , code(c)
+ : code(c)
{
}
* @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)
{
/** Retrieves the error message. */
const char* ToString() const
{
- if (message)
- return message;
+ if (!message.empty())
+ return message.c_str();
switch (code)
{
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;