Skip to content
Snippets Groups Projects
Commit 05343bdf authored by Steven Murray's avatar Steven Murray
Browse files

Forgot to add the new helper class catalogue::Sqlite

parent 72d4c81f
No related branches found
No related tags found
No related merge requests found
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "catalogue/Sqlite.hpp"
#include <sstream>
//------------------------------------------------------------------------------
// rcToStr
//------------------------------------------------------------------------------
std::string cta::catalogue::Sqlite::rcToStr(const int rc) {
switch(rc) {
case SQLITE_ABORT:
return "Abort requested";
case SQLITE_AUTH:
return "Authorization denied";
case SQLITE_BUSY:
return "Failed to take locks";
case SQLITE_CANTOPEN:
return "Cannot open database file";
case SQLITE_CONSTRAINT:
return "Constraint violation";
case SQLITE_CORRUPT:
return "Database file corrupted";
case SQLITE_DONE:
return "Statement finished executing successfully";
case SQLITE_EMPTY:
return "Database file empty";
case SQLITE_FORMAT:
return "Database format error";
case SQLITE_FULL:
return "Database full";
case SQLITE_INTERNAL:
return "Internal SQLite library error";
case SQLITE_INTERRUPT:
return "Interrupted";
case SQLITE_IOERR:
return "I/O error";
case SQLITE_LOCKED:
return "A table is locked";
case SQLITE_MISMATCH:
return "Datatype mismatch";
case SQLITE_MISUSE:
return "Misuse";
case SQLITE_NOLFS:
return "OS does not provide large file support";
case SQLITE_NOMEM:
return "Memory allocation error";
case SQLITE_NOTADB:
return "Not a database file";
case SQLITE_OK:
return "Operation successful";
case SQLITE_PERM:
return "Permnission denied";
case SQLITE_RANGE:
return "Invalid bind parameter index";
case SQLITE_READONLY:
return "Failed to write to read-only database";
case SQLITE_ROW:
return "A new row of data is ready for reading";
case SQLITE_SCHEMA:
return "Database schema changed";
case SQLITE_TOOBIG:
return "TEXT or BLOCK too big";
case SQLITE_ERROR:
return "Generic error";
default:
{
std::ostringstream oss;
oss << "Unknown SQLite return code " << rc;
return oss.str();
}
}
}
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <sqlite3.h>
#include <string>
namespace cta {
namespace catalogue {
/**
* A helper class for working with SQLite.
*/
class Sqlite {
public:
/**
* Returns the string representation of the specified SQLite return code.
*
* @param rc The SQLite return code.
* @return The string representation of the SQLite return code.
*/
static std::string rcToStr(const int rc);
}; // class SqlLiteStmt
} // namespace catalogue
} // namespace cta
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment