X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/21722d01338d0cf9a704fdb226507d1be787871a..dec242c057a35631bad2c2464580873b0c1200f3:/src/cxx/LogicException.cxx diff --git a/src/cxx/LogicException.cxx b/src/cxx/LogicException.cxx new file mode 100644 index 0000000000..a7adcf2fd5 --- /dev/null +++ b/src/cxx/LogicException.cxx @@ -0,0 +1,62 @@ +#include "LogicException.hpp" + +#include +#include +#include + +using namespace std; + +namespace SimGrid +{ + namespace Msg + { + + LogicException::LogicException() + { + this->reason = (char*) calloc(strlen("Logic exception : no detail") + 1, sizeof(char)); + strcpy(this->reason, "Logic exception : no detail"); + } + + + LogicException::LogicException(const LogicException& rLogicException) + { + const char* reason = rLogicException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + strcpy(this->reason, reason); + + } + + + LogicException::LogicException(const char* detail) + { + this->reason = (char*) calloc(strlen("Logic exception : ") + strlen(detail) + 1, sizeof(char)); + sprintf(this->reason, "Logic exception : %s", detail); + } + + + LogicException::~LogicException() + { + if(this->reason) + free(this->reason); + } + + const char* LogicException::toString(void) const + { + return (const char*)(this->reason); + } + + + const LogicException& LogicException::operator = (const LogicException& rLogicException) + { + const char* reason = rLogicException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + + return *this; + } + + } // namespace Msg + +}// namespace SimGrid + + +