X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdbms%2FResultCode.cpp;fp=source%2Fdbms%2FResultCode.cpp;h=0000000000000000000000000000000000000000;hb=a3b95648bd76140ef55e0b5941d423eee6c3856f;hp=453f78bb1759e950b79e91655cd9d4653cc0995e;hpb=94fc4366adedbf26ca6ef3104f88d41fa85f5a72;p=anna.git diff --git a/source/dbms/ResultCode.cpp b/source/dbms/ResultCode.cpp deleted file mode 100644 index 453f78b..0000000 --- a/source/dbms/ResultCode.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// ANNA - Anna is Not Nothingness Anymore // -// // -// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // -// // -// See project site at http://redmine.teslayout.com/projects/anna-suite // -// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // - - -#include - -#include - -using namespace std; -using namespace anna::dbms; - -bool ResultCode::notFound() const -throw(anna::RuntimeException) { - if(a_errorDecoder == NULL) { - string msg(asString()); - msg += " | Has no decoder for associated error"; - throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); - } - - return a_errorDecoder->notFound(a_errorCode); -} - -bool ResultCode::successful() const -throw(anna::RuntimeException) { - if(a_errorDecoder == NULL) { - string msg(asString()); - msg += " | Has no decoder for associated error"; - throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); - } - - return a_errorDecoder->successful(a_errorCode); -} - -bool ResultCode::locked() const -throw(anna::RuntimeException) { - if(a_errorDecoder == NULL) { - string msg(asString()); - msg += " | Has no decoder for associated error"; - throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); - } - - return a_errorDecoder->locked(a_errorCode); -} - -bool ResultCode::lostConnection() const -throw(anna::RuntimeException) { - if(a_errorDecoder == NULL) { - string msg(asString()); - msg += " | Has no decoder for associated error"; - throw anna::RuntimeException(msg, ANNA_FILE_LOCATION); - } - - return a_errorDecoder->lostConnection(a_errorCode); -} - -// -// No usamos la std::string porque la gran mayoría de las veces la ejecución de las sentencias SQL será -// correcta => no hará falta reservar ninguna memoria. -// -void ResultCode::copy(const char* text) -throw() { - if(text == NULL) { - if(a_errorText != NULL) { - free(a_errorText); - a_errorText = NULL; - } - } else { - char* aux; - - if((aux = anna_strchr((char*) text, '\n')) != NULL) - * aux = 0; - - const int textLen = anna_strlen(text); - - if(a_errorText == NULL) - a_errorText = strdup(text); - else if(anna_strlen(a_errorText) >= textLen) - anna_strcpy(a_errorText, text); - else { - free(a_errorText); - a_errorText = strdup(text); - } - } -} - -std::string ResultCode::asString() const -throw() { - std::string result("dbms::ResultCode { Error: "); - result += functions::asString(a_errorCode); - result += " | Error: "; - result += (a_errorText == NULL) ? "(null)" : a_errorText; - result += " | Correct: "; - - if(a_errorDecoder != NULL) - result += functions::asString(successful()); - else - result += ""; - - return result += " }"; -}