2 * OutOfBoundsException.cxx
\r
4 * Copyright 2006,2007 Martin Quinson, Malek Cherier
\r
5 * All right reserved.
\r
7 * This program is free software; you can redistribute
\r
8 * it and/or modify it under the terms of the license
\r
9 *(GNU LGPL) which comes with this package.
\r
13 /* OutOfBoundsException member functions implementation.
\r
16 #include <OutOfBoundsException.hpp>
\r
28 OutOfBoundsException::OutOfBoundsException()
\r
30 this->reason = (char*) calloc(strlen("Out of bounds") + 1, sizeof(char));
\r
31 strcpy(this->reason, "Out of bounds");
\r
35 OutOfBoundsException::OutOfBoundsException(const OutOfBoundsException& rOutOfBoundsException)
\r
37 const char* reason = rOutOfBoundsException.toString();
\r
38 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
\r
39 strcpy(this->reason, reason);
\r
43 OutOfBoundsException::OutOfBoundsException(int pos)
\r
45 this->reason = (char*) calloc(strlen("Out of bounds ") + 21 + 1, sizeof(char));
\r
46 sprintf(this->reason, "Out of bounds %d", pos);
\r
49 OutOfBoundsException::OutOfBoundsException(int pos1, int pos2)
\r
51 this->reason = (char*) calloc(strlen("Out of bounds ") + (2*21) + 1, sizeof(char));
\r
52 sprintf(this->reason, "Out of bounds %d : %d", pos1, pos2);
\r
56 OutOfBoundsException::~OutOfBoundsException()
\r
62 const char* OutOfBoundsException::toString(void) const
\r
64 return (const char*)(this->reason);
\r
68 const OutOfBoundsException& OutOfBoundsException::operator = (const OutOfBoundsException& rOutOfBoundsException)
\r
70 const char* reason = rOutOfBoundsException.toString();
\r
71 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
\r
78 }// namespace SimGrid
\r