Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c0dac5222962f0adbf9b5f937325ee906b451e09
[simgrid.git] / src / cxx / HostNotFoundException.cxx
1 #include "HostNotFoundException.hpp"\r
2 \r
3 #include <string.h>\r
4 #include <stdlib.h>\r
5 #include <stdio.h>\r
6 \r
7 using namespace std;\r
8 \r
9 namespace SimGrid\r
10 {\r
11         namespace Msg\r
12         {\r
13                 \r
14                         HostNotFoundException::HostNotFoundException()\r
15                         {\r
16                                 this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
17                                 strcpy(this->reason, "Host not found : unknown");\r
18                         }\r
19                 \r
20                 \r
21                         HostNotFoundException::HostNotFoundException(const HostNotFoundException& rHostNotFoundException)\r
22                         {\r
23                                 const char* reason = rHostNotFoundException.toString();\r
24                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
25                                 strcpy(this->reason, reason);\r
26                                 \r
27                         }\r
28                 \r
29                 \r
30                         HostNotFoundException::HostNotFoundException(const char* name)\r
31                         {\r
32                                 this->reason = (char*) calloc(strlen("Host not found : ") + strlen(name) + 1, sizeof(char));\r
33                                 sprintf(this->reason, "Host not found : %s", name);\r
34                         }\r
35                 \r
36                 \r
37                         HostNotFoundException::~HostNotFoundException()\r
38                         {\r
39                                 if(this->reason)\r
40                                         free(this->reason);\r
41                         }\r
42                                 \r
43                         const char* HostNotFoundException::toString(void) const\r
44                         {\r
45                                 return (const char*)(this->reason);     \r
46                         }\r
47                 \r
48                 \r
49                         const HostNotFoundException& HostNotFoundException::operator = (const HostNotFoundException& rHostNotFoundException)\r
50                         {\r
51                                 const char* reason = rHostNotFoundException.toString();\r
52                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
53                                 \r
54                                 return *this;\r
55                         }\r
56                 \r
57         } // namespace Msg      \r
58 \r
59 }// namespace SimGrid\r
60 \r
61 \r
62 \r