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>
27 using boost::lexical_cast;
33 string convert<string>(bool b)
35 return (b ? "true" : "false");
40 string convert<string>(char c)
47 string convert<string>(short unsigned int sui)
49 return lexical_cast<string>(sui);
54 string convert<string>(int i)
56 return lexical_cast<string>(i);
61 docstring convert<docstring>(int i)
63 return lyx::from_ascii(lexical_cast<string>(i));
68 string convert<string>(unsigned int ui)
70 return lexical_cast<string>(ui);
75 docstring convert<docstring>(unsigned int ui)
77 return lyx::from_ascii(lexical_cast<string>(ui));
82 string convert<string>(unsigned long ul)
84 return lexical_cast<string>(ul);
89 docstring convert<docstring>(unsigned long ul)
91 return lyx::from_ascii(lexical_cast<string>(ul));
96 string convert<string>(long l)
98 return lexical_cast<string>(l);
103 docstring convert<docstring>(long l)
105 return lyx::from_ascii(lexical_cast<string>(l));
110 string convert<string>(float f)
112 return lexical_cast<string>(f);
117 string convert<string>(double d)
119 return lexical_cast<string>(d);
124 int convert<int>(string const s)
126 return strtol(s.c_str(), 0, 10);
131 int convert<int>(docstring const s)
133 return strtol(lyx::to_ascii(s).c_str(), 0, 10);
138 unsigned int convert<unsigned int>(string const s)
140 return strtoul(s.c_str(), 0, 10);
145 double convert<double>(string const s)
147 return strtod(s.c_str(), 0);
152 int convert<int>(char const * cptr)
154 return strtol(cptr, 0, 10);
159 double convert<double>(char const * cptr)
161 return strtod(cptr, 0);