diff options
Diffstat (limited to 'library/globalFunctions.cpp')
-rw-r--r-- | library/globalFunctions.cpp | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/library/globalFunctions.cpp b/library/globalFunctions.cpp index 70a5abaf..d0aad7a4 100644 --- a/library/globalFunctions.cpp +++ b/library/globalFunctions.cpp @@ -1,98 +1,86 @@ #include "globalFunctions.h" -#include <wx/intl.h> - -#ifdef FFS_WIN -const wxChar FileNameSeparator = '\\'; -#endif // FFS_WIN - -#ifdef FFS_LINUX -const wxChar FileNameSeparator = '/'; -#endif // FFS_LINUX - -const wxChar* FloatingPointSeparator = _("."); -const wxChar* NumberSeparator = _(","); - +#include "../ui/resources.h" inline -int GlobalFunctions::round(const double d) +int globalFunctions::round(const double d) { return static_cast<int>(d<0?d-.5:d+.5); } inline -int GlobalFunctions::abs(const int d) +int globalFunctions::abs(const int d) { return(d<0?-d:d); } inline -unsigned int GlobalFunctions::abs(const unsigned int d) +unsigned int globalFunctions::abs(const unsigned int d) { return(d<0?-d:d); } inline -float GlobalFunctions::abs(const float d) +float globalFunctions::abs(const float d) { return(d<0?-d:d); }; inline -double GlobalFunctions::abs(const double d) +double globalFunctions::abs(const double d) { return(d<0?-d:d); } -string GlobalFunctions::numberToString(const unsigned int number) +string globalFunctions::numberToString(const unsigned int number) { char result[100]; sprintf( result, "%u", number); return string(result); } -string GlobalFunctions::numberToString(const int number) +string globalFunctions::numberToString(const int number) { char result[100]; sprintf( result, "%d", number); return string(result); } -string GlobalFunctions::numberToString(const float number) +string globalFunctions::numberToString(const float number) { char result[100]; sprintf( result, "%f", number); return string(result); } -wxString GlobalFunctions::numberToWxString(const unsigned int number) +wxString globalFunctions::numberToWxString(const unsigned int number) { return wxString::Format(wxT("%u"), number); } -wxString GlobalFunctions::numberToWxString(const int number) +wxString globalFunctions::numberToWxString(const int number) { return wxString::Format(wxT("%i"), number); } -wxString GlobalFunctions::numberToWxString(const float number) +wxString globalFunctions::numberToWxString(const float number) { return wxString::Format(wxT("%f"), number); } inline -int GlobalFunctions::stringToInt(const string& number) +int globalFunctions::stringToInt(const string& number) { return atoi(number.c_str()); } inline -double GlobalFunctions::stringToDouble(const string& number) +double globalFunctions::stringToDouble(const string& number) { return atof(number.c_str()); } inline -int GlobalFunctions::wxStringToInt(const wxString& number) +int globalFunctions::wxStringToInt(const wxString& number) { long result = 0; if (number.ToLong(&result)) @@ -102,7 +90,7 @@ int GlobalFunctions::wxStringToInt(const wxString& number) } inline -double GlobalFunctions::wxStringToDouble(const wxString& number) +double globalFunctions::wxStringToDouble(const wxString& number) { double result = 0; if (number.ToDouble(&result)) @@ -111,9 +99,9 @@ double GlobalFunctions::wxStringToDouble(const wxString& number) throw std::runtime_error("Error when converting number to double"); } -wxString& GlobalFunctions::includeNumberSeparator(wxString& number) +wxString& globalFunctions::includeNumberSeparator(wxString& number) { for (int i = number.size() - 3; i > 0; i-= 3) - number.insert(i, NumberSeparator); + number.insert(i, GlobalResources::numberSeparator); return number; } |