cleanCppProject  0.2.0
main.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <stdio.h>
3 #include <string>
4 #include <vector>
5 
6 #include "SomeClass.h"
7 #include "version.h"
8 
9 
10 using namespace std;
11 
12 void printHelp()
13 {
14  cout << "Help for cleanCppApplication " << endl;
15  cout << "Version: " << Version::getVersionLong() << endl;
16  cout << "Author: " << endl;
17  cout << "URL: " << endl;
18  /// @todo Do stuff in here also
19 }
20 
21 /**
22  * Example UML diagram:
23  *
24  * \startuml
25  *
26  * [-> main : start program
27  *
28  * activate main
29  *
30  * main -> main : process parameters
31  *
32  * main -> Version : get version
33  *
34  * activate Version
35  * Version -> Version : loads version
36  * Version -> main
37  * deactivate Version
38  *
39  * main -> main : prints version
40  *
41  * main -> SomeClass : create instance
42  * activate SomeClass
43  * SomeClass -> BaseClass : call constructor
44  * activate BaseClass
45  *
46  * main -> SomeClass : do stuff
47  * activate SomeClass
48  * SomeClass -> main : return stuff
49  * deactivate SomeClass
50  *
51  * BaseClass -> SomeClass
52  * deactivate BaseClass
53  * SomeClass -> main
54  * deactivate SomeClass
55  *
56  * deactivate main
57  *
58  * \enduml
59 */
60 int main(int argc, char const *argv[])
61 {
62  // Print help if no arguments are given
63  if (argc == 1)
64  printHelp();
65 
66  // process parameters
67  int argIt;
68  for (argIt = 1; argIt < argc; ++argIt)
69  {
70  string tmp = argv[argIt];
71 
72  if (tmp == "--help" || tmp == "-h")
73  printHelp();
74  else if (tmp == "--version")
75  cout << "v" << Version::getVersionShort() << endl;
76  else
77  break;
78  }
79  // process rest of the free arguments. EG. file list, word list
80  for (; argIt < argc; ++argIt)
81  cout << argv[argIt] << endl;
82 
83  /// @todo Do more stuff.
84  {
85  BaseClass c;
86  if (argc == 1)
87  c.freePtr();
88  /// @todo fix another leak
89  }
90 
91  SomeClass o;
92  o.set(5);
93  cout << o.get() << endl;
94 
95  // possible memory leak here, run with `make analyze`
96  int *a = new int(5);
97  cout << *a << endl;
98 
99  if (argc == 3)
100  return 1;
101 
102 
103  delete a;
104  cout << *a << endl;
105 
106 
107  return 0;
108 }
std::string getVersionLong()
Returns Version + Date + Build machine.
SomeClass description.
Definition: SomeClass.h:51
STL namespace.
int main(int argc, char const *argv[])
Example UML diagram:
Definition: main.cpp:60
void printHelp()
Definition: main.cpp:12
Empty BaseClass, just to show how it looks in doxygen.
Definition: SomeClass.h:19
std::string getVersionShort()
Returns version string with version in format:
int get()
get the value
Definition: SomeClass.cpp:18
void freePtr()
Definition: SomeClass.h:28
void set(int x)
Sets the value.
Definition: SomeClass.cpp:13