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);
58 docstring convert<docstring>(int i)
60 return lyx::from_ascii(lexical_cast<string>(i));
65 string convert<string>(unsigned int ui)
67 return lexical_cast<string>(ui);
72 docstring convert<docstring>(unsigned int ui)
74 return lyx::from_ascii(lexical_cast<string>(ui));
79 string convert<string>(unsigned long ul)
81 return lexical_cast<string>(ul);
86 docstring convert<docstring>(unsigned long ul)
88 return lyx::from_ascii(lexical_cast<string>(ul));
93 string convert<string>(long l)
95 return lexical_cast<string>(l);
100 docstring convert<docstring>(long l)
102 return lyx::from_ascii(lexical_cast<string>(l));
107 string convert<string>(float f)
109 return lexical_cast<string>(f);
114 string convert<string>(double d)
116 return lexical_cast<string>(d);
121 int convert<int>(string const s)
123 return strtol(s.c_str(), 0, 10);
128 unsigned int convert<unsigned int>(string const s)
130 return strtoul(s.c_str(), 0, 10);
135 double convert<double>(string const s)
137 return strtod(s.c_str(), 0);
142 int convert<int>(char const * cptr)
144 return strtol(cptr, 0, 10);
149 double convert<double>(char const * cptr)
151 return strtod(cptr, 0);