]> git.lyx.org Git - lyx.git/blobdiff - src/support/convert.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / support / convert.cpp
index 7f2451e01743931331494089a4277bb5b62ce0d0..58a56479a3abe377761d8a1afae8da3ace6ff322 100644 (file)
@@ -1,34 +1,32 @@
 /**
- * \file tostr.C
+ * \file convert.cpp
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
- * \author Lars Gullik Bjønnes
+ * \author André Pönitz
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
-#include "convert.h"
-
+#include "support/convert.h"
 #include "support/docstring.h"
 
 #include <boost/lexical_cast.hpp>
 
 #include <string>
+#include <sstream>
+//needed for Mac OSX 10.5.2 Leopard
+#include <cstdlib>
 
+using namespace std;
 
 namespace lyx {
 
-using lyx::docstring;
-
 using boost::lexical_cast;
 
-using std::string;
-
-
 template<>
 string convert<string>(bool b)
 {
@@ -60,7 +58,7 @@ string convert<string>(int i)
 template<>
 docstring convert<docstring>(int i)
 {
-       return lyx::from_ascii(lexical_cast<string>(i));
+       return from_ascii(lexical_cast<string>(i));
 }
 
 
@@ -74,7 +72,7 @@ string convert<string>(unsigned int ui)
 template<>
 docstring convert<docstring>(unsigned int ui)
 {
-       return lyx::from_ascii(lexical_cast<string>(ui));
+       return from_ascii(lexical_cast<string>(ui));
 }
 
 
@@ -88,8 +86,24 @@ string convert<string>(unsigned long ul)
 template<>
 docstring convert<docstring>(unsigned long ul)
 {
-       return lyx::from_ascii(lexical_cast<string>(ul));
+       return from_ascii(lexical_cast<string>(ul));
+}
+
+
+#ifdef LYX_USE_LONG_LONG
+template<>
+string convert<string>(unsigned long long ull)
+{
+       return lexical_cast<string>(ull);
+}
+
+
+template<>
+docstring convert<docstring>(unsigned long long ull)
+{
+       return from_ascii(lexical_cast<string>(ull));
 }
+#endif
 
 
 template<>
@@ -102,21 +116,41 @@ string convert<string>(long l)
 template<>
 docstring convert<docstring>(long l)
 {
-       return lyx::from_ascii(lexical_cast<string>(l));
+       return from_ascii(lexical_cast<string>(l));
+}
+
+
+#ifdef LYX_USE_LONG_LONG
+template<>
+string convert<string>(long long ll)
+{
+       return lexical_cast<string>(ll);
+}
+
+
+template<>
+docstring convert<docstring>(long long ll)
+{
+       return from_ascii(lexical_cast<string>(ll));
 }
+#endif
 
 
 template<>
 string convert<string>(float f)
 {
-       return lexical_cast<string>(f);
+       std::ostringstream val;
+       val << f;
+       return val.str();
 }
 
 
 template<>
 string convert<string>(double d)
 {
-       return lexical_cast<string>(d);
+       std::ostringstream val;
+       val << d;
+       return val.str();
 }
 
 
@@ -130,7 +164,7 @@ int convert<int>(string const s)
 template<>
 int convert<int>(docstring const s)
 {
-       return strtol(lyx::to_ascii(s).c_str(), 0, 10);
+       return strtol(to_ascii(s).c_str(), 0, 10);
 }