summaryrefslogtreecommitdiff
path: root/library/globalFunctions.h
blob: 55e37c6194e68a455d2bf26e076a4b16f19487bc (plain)
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
#ifndef GLOBALFUNCTIONS_H_INCLUDED
#define GLOBALFUNCTIONS_H_INCLUDED

#include <string>
#include <algorithm>
#include <wx/string.h>

using namespace std;

namespace globalFunctions
{
    int round(double d); //little rounding function

    template <class T>
    T abs(const T& d)    //absolute value
    {
        return(d<0?-d:d);
    }

    string numberToString(const unsigned int number); //Convert number to string
    string numberToString(const int number);          //Convert number to string
    string numberToString(const float number);        //Convert number to string

    wxString numberToWxString(const unsigned int number); //Convert number to wxString
    wxString numberToWxString(const int number);          //Convert number to wxString
    wxString numberToWxString(const float number);        //Convert number to wxString

    int    stringToInt(   const string& number); //Convert String to number
    double stringToDouble(const string& number); //Convert String to number

    int    wxStringToInt(   const wxString& number); //Convert wxString to number
    double wxStringToDouble(const wxString& number); //Convert wxString to number

    wxString& includeNumberSeparator(wxString& number);
}


class RuntimeException //Exception class used to notify of general runtime exceptions
{
public:
    RuntimeException(const wxString& txt) : errorMessage(txt) {}

    wxString show() const
    {
        return errorMessage;
    }

private:
    wxString errorMessage;
};

#endif // GLOBALFUNCTIONS_H_INCLUDED
bgstack15