3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
16 #include "support/docstring.h"
18 #include <boost/lexical_cast.hpp>
24 using boost::lexical_cast;
30 string convert<string>(bool b)
32 return (b ? "true" : "false");
37 string convert<string>(char c)
44 string convert<string>(short unsigned int sui)
46 return lexical_cast<string>(sui);
51 string convert<string>(int i)
53 return lexical_cast<string>(i);
57 docstring convert<docstring>(int i)
59 return lyx::from_ascii(lexical_cast<string>(i));
63 string convert<string>(unsigned int ui)
65 return lexical_cast<string>(ui);
70 string convert<string>(unsigned long ul)
72 return lexical_cast<string>(ul);
77 string convert<string>(long l)
79 return lexical_cast<string>(l);
84 string convert<string>(float f)
86 return lexical_cast<string>(f);
91 string convert<string>(double d)
93 return lexical_cast<string>(d);
98 int convert<int>(string const s)
100 return strtol(s.c_str(), 0, 10);
105 unsigned int convert<unsigned int>(string const s)
107 return strtoul(s.c_str(), 0, 10);
112 double convert<double>(string const s)
114 return strtod(s.c_str(), 0);
119 int convert<int>(char const * cptr)
121 return strtol(cptr, 0, 10);
126 double convert<double>(char const * cptr)
128 return strtod(cptr, 0);