]> git.lyx.org Git - lyx.git/blobdiff - src/support/tostr.C
tostr -> convert and some bformat work
[lyx.git] / src / support / tostr.C
index 2442699f57d105019ee757710204e73130da4ee2..c137dbb6279c16ab976e9a47976d3251a82e2e16 100644 (file)
@@ -1,41 +1,69 @@
+/**
+ * \file tostr.C
+ * 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
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #include <config.h>
-#include "Lsstream.h"
-#include "LString.h"
 
+#include "tostr.h"
+
+#include <boost/lexical_cast.hpp>
+
+using boost::lexical_cast;
+
+using std::string;
 
-string const tostr(bool b)
+
+template<>
+string convert<string>(bool b)
 {
        return (b ? "true" : "false");
 }
 
 
-string const tostr(unsigned int i)
+template<>
+string convert<string>(char c)
+{
+       return string(1, c);
+}
+
+
+template<>
+string convert<string>(short unsigned int sui)
+{
+       return lexical_cast<string>(sui);
+}
+
+
+template<>
+string convert<string>(int i)
 {
-       ostringstream os;
-       os << i;
-       return STRCONV(os.str());
+       return lexical_cast<string>(i);
 }
 
 
-string const tostr(double d)
+template<>
+string convert<string>(unsigned int ui)
 {
-       ostringstream os;
-       os << d;
-       return STRCONV(os.str());
+       return lexical_cast<string>(ui);
 }
 
 
-string const tostr(int i)
+template<>
+string convert<string>(float f)
 {
-       ostringstream os;
-       os << i;
-       return STRCONV(os.str());
+       return lexical_cast<string>(f);
 }
 
 
-string const tostr(string const & s)
+template<>
+string convert<string>(double d)
 {
-       return s;
+       return lexical_cast<string>(d);
 }