pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src string_converter.hxx,1.8,1.9


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src string_converter.hxx,1.8,1.9
Date: 30 Nov 2002 17:11:57 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv25073

Modified Files:
        string_converter.hxx 
Log Message:
fixed levelproperty dialog, should now be fully working


Index: string_converter.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/string_converter.hxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- string_converter.hxx        28 Sep 2002 11:52:22 -0000      1.8
+++ string_converter.hxx        30 Nov 2002 17:11:55 -0000      1.9
@@ -49,9 +49,11 @@
   return oss.str();
 }
 
-
+/** Convert the contents in string \a rep to type \a T, if conversion
+    fails false is returned and the value of \a x is unchanged, if
+    true is returned the conversation was successfull. */
 template <class T>
-void from_string(const std::string& rep, T& x)
+bool from_string(const std::string& rep, T& x)
 {
  // this is necessary so that if "x" is not modified if the conversion fails
   T temp;
@@ -61,10 +63,20 @@
   std::istrstream iss(rep.c_str());
 #endif
   iss >> temp;
-  if (iss.fail())
+
+  /*if (iss.fail())
     throw std::invalid_argument
-      ("Exception: 'failed to extract type T from rep' " __FILE__ ": " + rep);
-  x = temp;
+    ("Exception: 'failed to extract type T from rep' " __FILE__ ": " + rep);*/
+
+  if (iss.fail())
+    {
+      return false;
+    }
+  else
+    {
+      x = temp;
+      return true;
+    }
 }
 
 std::string string_upcase (const std::string&);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]