* To<float/double> will no longer cause exceptions 4.x-dev

Sun, 15 Mar 2020 11:12:38 +0200

author
cemkalyoncu
date
Sun, 15 Mar 2020 11:12:38 +0200
branch
4.x-dev
changeset 1380
8ea1cd4f856e
parent 1379
0c9e6ca3674b
child 1381
4f68e1114e7d

* To<float/double> will no longer cause exceptions
* X11 numpad key 9 now works

Source/Gorgon/String.h file | annotate | diff | comparison | revisions
Source/Gorgon/WindowManager/X11/Input.cpp file | annotate | diff | comparison | revisions
Testing/Source/Manual/UI_Generate.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/String.h	Sat Mar 14 15:37:32 2020 +0200
+++ b/Source/Gorgon/String.h	Sun Mar 15 11:12:38 2020 +0200
@@ -191,21 +191,21 @@
         inline float To<float>(const std::string &value) {
             if(value=="") return 0;
             
-            return (float)std::stof(value);
+            return (float)std::strtof(value.c_str(), nullptr);
         }
 
         template <>
         inline double To<double>(const std::string &value) {
             if(value=="") return 0;
             
-            return std::stod(value);
+            return std::strtod(value.c_str(), nullptr);
         }
 
         template <>
         inline long double To<long double>(const std::string &value) {
             if(value=="") return 0;
             
-            return std::stold(value);
+            return std::strtold(value.c_str(), nullptr);
         }
         
         template <>
@@ -218,62 +218,52 @@
         
         template <>
         inline char To<char>(const char *value) {
-            char *n;
-            return (char)std::strtol(value, &n, 10);
+            return (char)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline unsigned char To<unsigned char>(const char *value) {
-            char *n;
-            return (unsigned char)std::strtol(value, &n, 10);
+            return (unsigned char)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline short To<short>(const char *value) {
-            char *n;
-            return (short)std::strtol(value, &n, 10);
+            return (short)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline unsigned short To<unsigned short>(const char *value) {
-            char *n;
-            return (unsigned short)std::strtol(value, &n, 10);
+            return (unsigned short)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline int To<int>(const char *value) {
-            char *n;
-            return (int)std::strtol(value, &n, 10);
+            return (int)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline unsigned To<unsigned>(const char *value) {
-            char *n;
-            return (unsigned)std::strtol(value, &n, 10);
+            return (unsigned)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline long To<long>(const char *value) {
-            char *n;
-            return (long)std::strtol(value, &n, 10);
+            return (long)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline unsigned long To<unsigned long>(const char *value) {
-            char *n;
-            return (unsigned long)std::strtol(value, &n, 10);
+            return (unsigned long)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline long long To<long long>(const char *value) {
-            char *n;
-            return (long long)std::strtol(value, &n, 10);
+            return (long long)std::strtol(value, nullptr, 10);
         }
 
         template <>
         inline unsigned long long To<unsigned long long>(const char *value) {
-            char *n;
-            return (unsigned long long)std::strtol(value, &n, 10);
+            return (unsigned long long)std::strtol(value, nullptr, 10);
         }
 
         template <>
@@ -297,7 +287,8 @@
         }
 
         /// Converts a hexadecimal number stored in the string to a given
-        /// integer type.
+        /// integer type. If given string is not a valid number this function
+        /// throws
         template <class T_>
         T_ HexTo(const std::string &value);
 
--- a/Source/Gorgon/WindowManager/X11/Input.cpp	Sat Mar 14 15:37:32 2020 +0200
+++ b/Source/Gorgon/WindowManager/X11/Input.cpp	Sun Mar 15 11:12:38 2020 +0200
@@ -22,7 +22,7 @@
         return keysym & 0x00ffffff;
     
     /* checkfor numpad */
-    if (keysym > 0xff80 && keysym < 0xffb9)
+    if (keysym > 0xff80 && keysym <= 0xffb9)
         return keysym - 0xff80;
 
     /* binary search in table */
--- a/Testing/Source/Manual/UI_Generate.cpp	Sat Mar 14 15:37:32 2020 +0200
+++ b/Testing/Source/Manual/UI_Generate.cpp	Sun Mar 15 11:12:38 2020 +0200
@@ -167,7 +167,7 @@
     inp.ChangedEvent.Register([](Geometry::Point val) {
         std::cout << val << std::endl;
     });
-    inp.Readonly = true;
+    //inp.Readonly = true;
 
     pnl.Add(chk);
     pnl.Add(lbl);

mercurial