-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·73 lines (66 loc) · 1.7 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//------------------------------------------------------------------------------
/// Filename: main.cpp
/// Description: Main Function
/// Authors:
/// Robin Ankele(0931951)
/// Tutor: Manuel Weber
/// Group: 24
/// Created: 08.09.2011
/// Last change: 08.09.2011
//------------------------------------------------------------------------------
#include <string>
#include "SVGHandler.h"
#include "Error.h"
#include "ErrorCodes.h"
//------------------------------------------------------------------------------
/// Main Function
/// @return returns an errorcode
/// @param argc number of parameters
/// @param argv parameters
int main(unsigned int argc, char *argv[])
{
signed int errorcode = SUCCESS;
SVGHandler *svghandler = NULL;
Error *error = NULL;
std::string filename;
try
{
error = new Error();
svghandler = new SVGHandler(argc, argv);
errorcode = svghandler->getErrors();
if(errorcode != USAGE_CONFIG_FILE)
filename.assign(svghandler->getDB()->getFilename());
delete svghandler;
}
catch(std::bad_alloc& exception)
{
if(error)
{
errorcode = OUT_OF_MEMORY;
delete error;
}
if(svghandler)
delete svghandler;
}
switch(errorcode)
{
case SUCCESS:
break;
case USAGE_CONFIG_FILE:
error->usageConfigFile();
break;
case OUT_OF_MEMORY:
error->outOfMemory();
break;
case CANNOT_READ_CONFIG_FILE:
error->cannotReadConfigFile(filename);
break;
case CONFIG_FILE_CORRUPT:
error->configFileCorrupt(filename);
break;
default:
break;
}
delete error;
return errorcode;
}