forked from ebu/MXFTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenericFeatures.hpp
206 lines (184 loc) · 5.78 KB
/
genericFeatures.hpp
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#ifndef CPP_GENERICFEATURES_CLASS_H
#define CPP_GENERICFEATURES_CLASS_H
/*!
* \project_name EBU Player
* \file genericFeatures.hpp
* \brief the generic features specifications
* \details This class is used to define several generic functions useful to the media player or any of projet classes without instantiate the class. Basically, all public functions are declared as static to avoid the class instanciation
* \authors Marco Dos Santos Oliveira
* \version 0.1
* \date 20 august 2012
* \copyright GNU GPLv3
*
*/
#include <string>
#include <vector>
#include <iostream>
#include <string.h>
#include <iterator>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cmath>
#include <chrono>
#include <dirent.h>
#ifndef WIN32
#include <sys/types.h>
#endif
/*! \class genericFeatures
* \brief this class is used to define generic functions
*
* This class implements all generic functions which can be usefull to the media player or any component of the media player
*/
class genericFeatures {
public:
/////////////////////////////////
////// //////
////// public variables //////
////// //////
/////////////////////////////////
/////////////////////////////////
////// //////
////// public functions //////
////// //////
/////////////////////////////////
/**
* @fn static std::string removePrefix(std::string str, std::string prefix)
* @brief Returns the portion of the string after the first string prefix
* @brief
* @note needs more documentation
* @param[in] std::string filename : The filename to modify
* @param[in] std::string prefix : a prefix to remove
* @return std::string if all is right or an error at compilation time.
*/
static std::string removePrefix
(
std::string filename,
std::string prefix
);
/**
* @fn static std::string removeSuffix(std::string str, std::string suffix)
* @brief Returns the portion of the string after the first string suffix
* @brief
* @note needs more documentation
* @param[in] std::string filename : The filename to modify
* @param[in] std::string suffix : a suffix to remove
* @return std::string if all is right or an error at compilation time.
*/
static std::string removeSuffix
(
std::string filename,
std::string suffix
);
/**
* @fn static std::string int2str(int futurestring)
* @brief Convert an int to a std::string
* @brief
* @note needs more documentation
* @param[in] int futurestring : int to convert
* @return std::string if all is right or an error at compilation time.
*/
static std::string int2str
(
int futurestring
);
/**
* @fn static std::size_t getTime(void)
* @brief Return the current timestamp with milliseconds and microseconds
* @brief Can be used like a unique id.
* @note needs more documentation
* @param[in] void : no arg
* @return std::size_t if all is right or an error at compilation time.
*/
static std::size_t getTime
(
void
);
/**
* @fn static bool hasExtension(std::string filename)
* @brief This function will test if the input file has an extension.
* @brief
* @note needs more documentation
* @param[in] std::string filename : The filename to test
* @return std::string if all is right or an error at compilation time.
*/
static bool hasExtension
(
std::string filename
);
/**
* @fn static bool isExtension(std::string filename, std::string extension)
* @brief This function will test if the input string ends by the extension. The extension should come after a dot.
* @brief
* @note needs more documentation
* @param[in] std::string filename : The filename to test
* @param[in] std::string extension : Extension file to test
* @return std::string if all is right or an error at compilation time.
*/
static bool isExtension
(
std::string filename,
std::string extension
);
/**
* @fn static bool fileExists(std::string filename)
* @brief This function will test if the input file exists.
* @brief
* @note needs more documentation
* @param[in] std::string filename : Path to the file to test
* @return std::string if all is right or an error at compilation time.
*/
static bool fileExists
(
std::string filename
);
/**
* @fn static unsigned long int getFileSize(std::string filename)
* @brief This function will compute the file size in bytes.
* @brief
* @note needs more documentation
* @param[in] std::string filename : Path to the file to test
* @return unsigned long int if all is right or an error at compilation time.
*/
static unsigned long int getFileSize
(
std::string filename
);
/**
* @fn static std::string getSizeUnit(unsigned long int bytes)
* @brief This function will identify the most appropriate unit prefix to filesize
* @brief
* @note needs more documentation
* @param[in] unsigned long int bytes : Filesize in bytes
* @return std::string if all is right or an error at compilation time.
*/
static std::string getSizeUnit
(
unsigned long int bytes
);
/**
* @fn static std::vector<std::string> listFiles(std::string path)
* @brief This function will generate a vector with the path to each files into the folder as a standard string.
* @brief
* @note needs more documentation
* @param[in] std::string path : Path to the folder
* @return unsigned long int if all is right or an error at compilation time.
*/
static std::vector<std::string> listFiles
(
std::string path
);
protected:
/////////////////////////////////
////// //////
////// protected variables //////
////// //////
/////////////////////////////////
/////////////////////////////////
////// //////
////// protected functions //////
////// //////
/////////////////////////////////
};
#endif