]> git.lyx.org Git - lyx.git/blobdiff - src/support/convert.C
MacOSX compile fix.
[lyx.git] / src / support / convert.C
index d785c3fe2037743e744575e7487618457306dbff..a3014fe41864d7d77def4d9b56fd8ed00cfbcec9 100644 (file)
 
 #include "convert.h"
 
+#include "support/docstring.h"
+
 #include <boost/lexical_cast.hpp>
 
 #include <string>
 
+using lyx::docstring;
+
 using boost::lexical_cast;
 
 using std::string;
@@ -50,6 +54,13 @@ string convert<string>(int i)
 }
 
 
+template<>
+docstring convert<docstring>(int i)
+{
+       return lyx::from_ascii(lexical_cast<string>(i));
+}
+
+
 template<>
 string convert<string>(unsigned int ui)
 {
@@ -57,6 +68,13 @@ string convert<string>(unsigned int ui)
 }
 
 
+template<>
+docstring convert<docstring>(unsigned int ui)
+{
+       return lyx::from_ascii(lexical_cast<string>(ui));
+}
+
+
 template<>
 string convert<string>(unsigned long ul)
 {
@@ -64,6 +82,27 @@ string convert<string>(unsigned long ul)
 }
 
 
+template<>
+docstring convert<docstring>(unsigned long ul)
+{
+       return lyx::from_ascii(lexical_cast<string>(ul));
+}
+
+
+template<>
+string convert<string>(long l)
+{
+       return lexical_cast<string>(l);
+}
+
+
+template<>
+docstring convert<docstring>(long l)
+{
+       return lyx::from_ascii(lexical_cast<string>(l));
+}
+
+
 template<>
 string convert<string>(float f)
 {
@@ -76,3 +115,38 @@ string convert<string>(double d)
 {
        return lexical_cast<string>(d);
 }
+
+
+template<>
+int convert<int>(string const s)
+{
+       return strtol(s.c_str(), 0, 10);
+}
+
+
+template<>
+unsigned int convert<unsigned int>(string const s)
+{
+       return strtoul(s.c_str(), 0, 10);
+}
+
+
+template<>
+double convert<double>(string const s)
+{
+       return strtod(s.c_str(), 0);
+}
+
+
+template<>
+int convert<int>(char const * cptr)
+{
+       return strtol(cptr, 0, 10);
+}
+
+
+template<>
+double convert<double>(char const * cptr)
+{
+       return strtod(cptr, 0);
+}