-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.h
More file actions
73 lines (56 loc) · 2.09 KB
/
Utils.h
File metadata and controls
73 lines (56 loc) · 2.09 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
/*
* Utils.h
*
* Created on: 27 Jan 2012
* Author: Max Foster
*/
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <sstream>
#include <vector>
class QString;
class QDateTime;
class QDate;
struct Date
{
unsigned seconds, minute, hour, day, month, year;
Date(time_t seconds);
Date(unsigned minute, unsigned hour, unsigned day, unsigned month, unsigned year);
Date(const QDateTime &qDateTime);
Date(const QDate &qDate);
operator std::string() const;
operator QString() const;
operator QDateTime() const;
operator QDate() const;
operator time_t() const;
QString toQStringWithoutTime() const;
};
std::ostream & operator <<(std::ostream &stream, const Date &date);
std::string lowerCase(const std::string &str);
void replaceChars(std::string &str, char searchChar, char newChar);
const char * limitLength(const char *str, unsigned maxLength);
void showInfoDialog(const char *message);
void showErrorDialog(const char *message);
void showErrorDialog(const std::vector<std::string> &errors);
void showFatalDialog(const char *message);
bool showYesNoDialog(const char *question);
void showPendingDialog(const char *message, int (*percentCompleteCheckFunction)(void));
bool showDatePickerDialog(QDate &dateToModify);
const char * createFullName(const char *forename, const char *surname);
void addError(std::vector<std::string> &errors, std::string error);
bool validateLengthOf(const char *value, int min, int max, const std::string &valueName, std::string &errorMessage);
bool validateLengthOf(const char *value, int max, const std::string &valueName, std::string &errorMessage);
void copyFile(const char *sourceFilename, const char *destinationFilename);
void moveFile(const char *sourceFilename, const char *destinationFilename);
void moveDirectory(const char *sourceDirectoryPath, const char *destinationDirectoryPath);
QString to2Dp(const QString &str);
double doubleTo2Dp(const double number);
template <typename type>
std::string toString(const type &variable)
{
std::stringstream stream;
stream << variable;
return stream.str();
}
#endif // UTILS_H