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