Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a class of exception for file not found and Msg files containing the declarations...
[simgrid.git] / src / cxx / FileNotFoundException.cxx
1 #include <FileNotFoundException.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                         FileNotFoundException::FileNotFoundException()\r
15                         {\r
16                                 this->reason = (char*) calloc(strlen("File not found") + 1, sizeof(char));\r
17                                 strcpy(this->reason, "File not found");\r
18                         }\r
19                 \r
20                 \r
21                         FileNotFoundException::FileNotFoundException(const FileNotFoundException& rFileNotFoundException)\r
22                         {\r
23                                 const char* reason = rFileNotFoundException.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                         FileNotFoundException::FileNotFoundException(const char* file)\r
30                         {\r
31                                 this->reason = (char*) calloc(strlen("File not found ") + strlen(file) + 1, sizeof(char));\r
32                                 sprintf(this->reason, "File not found %s", file);\r
33                         }\r
34                 \r
35                 \r
36                         FileNotFoundException::~FileNotFoundException()\r
37                         {\r
38                                 if(this->reason)\r
39                                         free(this->reason);\r
40                         }\r
41                                 \r
42                         const char* FileNotFoundException::toString(void) const\r
43                         {\r
44                                 return (const char*)(this->reason);     \r
45                         }\r
46                 \r
47                 \r
48                         const FileNotFoundException& FileNotFoundException::operator = (const FileNotFoundException& rFileNotFoundException)\r
49                         {\r
50                                 const char* reason = rFileNotFoundException.toString();\r
51                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
52                                 \r
53                                 return *this;\r
54                         }\r
55                 \r
56         } // namespace Msg      \r
57 \r
58 }// namespace SimGrid\r
59 \r
60 \r
61 \r