X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e133a950865071b1c006387e915d39989a53c8cd..2371d0c1060589bd7b8757f47974ceaa906e0dba:/src/cxx/NullPointerException.cxx diff --git a/src/cxx/NullPointerException.cxx b/src/cxx/NullPointerException.cxx new file mode 100644 index 0000000000..e672c66914 --- /dev/null +++ b/src/cxx/NullPointerException.cxx @@ -0,0 +1,60 @@ +#include + +#include +#include +#include + +namespace SimGrid +{ + namespace Msg + { + + NullPointerException::NullPointerException() + { + this->reason = (char*) calloc(strlen("Null pointer : unknown") + 1, sizeof(char)); + strcpy(this->reason, "Null pointer : unknown"); + } + + + NullPointerException::NullPointerException(const NullPointerException& rNullPointerException) + { + const char* reason = rNullPointerException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + strcpy(this->reason, reason); + + } + + + NullPointerException::NullPointerException(const char* name) + { + this->reason = (char*) calloc(strlen("Null pointer : ") + strlen(name) + 1, sizeof(char)); + sprintf(this->reason, "Null pointer : %s", name); + } + + + NullPointerException::~NullPointerException() + { + if(this->reason) + free(this->reason); + } + + const char* NullPointerException::toString(void) const + { + return (const char*)(this->reason); + } + + + const NullPointerException& NullPointerException::operator = (const NullPointerException& rNullPointerException) + { + const char* reason = rNullPointerException.toString(); + this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char)); + + return *this; + } + + } // namespace Msg + +}// namespace SimGrid + + +