-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHelperMethods.h
More file actions
142 lines (133 loc) · 4.25 KB
/
HelperMethods.h
File metadata and controls
142 lines (133 loc) · 4.25 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
///////////////////////////////////////////////////////////
// HelperMethods.h
// Implementation of the Class HelperMethods
// Created on: 30-Sau-2014 17:06:18
// Original author: Povilas
///////////////////////////////////////////////////////////
#if !defined(HELPERMETHODS_H)
#define HELPERMETHODS_H
#include <string>
#include <vector>
/** \brief Static class that hold helper methods for data management
*/
class HelperMethods
{
public:
/** \brief Constructor
*/
HelperMethods();
/** \brief Destructor
*/
virtual ~HelperMethods();
/** \brief Function that generates file name with the given preffix
*
* \param std::string preffix brefix to be added to the file name
* \param bool addExtension = true adds .arff extension
* \return std::string with te file name
*
*/
static std::string generateFileName(std::string preffix, bool addExtension = true );
/** \brief Deletes old files from the data directory
* \return int number of deleted files
*
*/
static int deleteOldFiles();
/** \brief Deletes file
*
* \param std::string path path to file that must be deleted
* \return int no of deleted files
*
*/
static int deleteFile(std::string path);
/** \brief Parses CGI variables
* \return char** of the CGI vars
*
*/
static char **getcgivars();
/** \brief Function splits passed string accordint to passed delimeter
*
* \param const std::string& s string to be splitted
* \param char delim split delimeter
* \return std::vector<std::string>
*
*/
static std::vector<std::string> split(const std::string& s, char delim);
/** \brief Function returns random value from the given interval
*
* \param unsigned int upper bound
* \param unsigned int lower bound
* \return int random number
*
*/
static int getRrandomInRange (unsigned int, unsigned int);
/** \brief Function returns mean vector value
*
* \param std::vector<double> vector of doubles
* \return double mean value
*
*/
static double getMean(std::vector<double>);
/** \brief Function returns deviation of vector
*
* \param std::vector<double> vector of doubles
* \return double std devaition value
*
*/
static double getStd(std::vector<double>);
/** \brief Function reads arff file and returns indicated attribute value (satistics file form the calculus)
*
* \param std::string path to file
* \param std::string attribute name
* \return double atribute value
*
*/
static double getAttributeValue(std::string statFile, std::string attName);
/** \brief Function coverts string to double data type
*
* \param std::string value in string format
* \return double value
*
*/
static double strToDouble(std::string cmdParam);
/** \brief Function coverts string to int data type
*
* \param std::string value in string format
* \return int value
*
*/
static int strToInt(std::string cmdParam);
static bool copyFile(const char*, const char*);
private:
static const char* alphanum; /**< Aphanumeric pattern for unique input and output file generation */
/** \brief Convert a two-char hex string into the char it represents.
*
* \param char* in hex to convert
* \return char character
*
*/
static char x2c(char* what);
/** \brief Reduce any %xx escape sequences to the characters they represent.
*
* \param char* of escape sequences
* \return void
*
*/
static void unescape_url(char* url);
/** \brief Helper method that adds temination symbol to the end of the string
*
* \param const char* string to be added
* \return char* resulting string
*
*/
static char *strdup(const char* s);
/** \brief Splits vector into strings
*
* \param const std::string string to be splitted
* \param char split delimeter
* \param std::vector<std::string> accumulative array
* \return std::vector<std::string>
*
*/
static std::vector<std::string> split(const std::string& s, char delim, std::vector<std::string> &elems);
};
#endif //!defined(EHELPERMETHODS_H)