X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/624064042aa82cbdb6d83b0f73bba7ba61048bbc..9b1ec3c5445076d8f5827f850a9a5e9ea4853696:/src/cxx/InvalidArgumentException.cxx diff --git a/src/cxx/InvalidArgumentException.cxx b/src/cxx/InvalidArgumentException.cxx new file mode 100644 index 0000000000..ffc120830a --- /dev/null +++ b/src/cxx/InvalidArgumentException.cxx @@ -0,0 +1,62 @@ +#include "InvalidArgumentException.hpp" + +#include +#include +#include + +using namespace std; + +namespace SimGrid +{ + namespace Msg + { + + InvalidArgumentException::InvalidArgumentException() + { + this->reason = (char*) calloc(strlen("Invalid argument : unknown") + 1, sizeof(char)); + strcpy(this->reason, "Invalid argument : unknown"); + } + + + InvalidArgumentException::InvalidArgumentException(const InvalidArgumentException& rInvalidArgumentException) + { + const char* reason = rInvalidArgumentException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + strcpy(this->reason, reason); + + } + + + InvalidArgumentException::InvalidArgumentException(const char* name) + { + this->reason = (char*) calloc(strlen("Invalid argument : ") + strlen(name) + 1, sizeof(char)); + sprintf(this->reason, "Invalid argument : %s", name); + } + + + InvalidArgumentException::~InvalidArgumentException() + { + if(this->reason) + free(this->reason); + } + + const char* InvalidArgumentException::toString(void) const + { + return (const char*)(this->reason); + } + + + const InvalidArgumentException& InvalidArgumentException::operator = (const InvalidArgumentException& rInvalidArgumentException) + { + const char* reason = rInvalidArgumentException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + + return *this; + } + + } // namespace Msg + +}// namespace SimGrid + + +