/** * \file convert.cpp * 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 #include "support/convert.h" #include "support/docstring.h" #include #include #include using namespace std; namespace lyx { using boost::lexical_cast; template<> string convert(bool b) { return (b ? "true" : "false"); } template<> string convert(char c) { return string(1, c); } template<> string convert(short unsigned int sui) { return lexical_cast(sui); } template<> string convert(int i) { return lexical_cast(i); } template<> docstring convert(int i) { return from_ascii(lexical_cast(i)); } template<> string convert(unsigned int ui) { return lexical_cast(ui); } template<> docstring convert(unsigned int ui) { return from_ascii(lexical_cast(ui)); } template<> string convert(unsigned long ul) { return lexical_cast(ul); } template<> docstring convert(unsigned long ul) { return from_ascii(lexical_cast(ul)); } template<> string convert(long l) { return lexical_cast(l); } template<> docstring convert(long l) { return from_ascii(lexical_cast(l)); } template<> string convert(float f) { return lexical_cast(f); } template<> string convert(double d) { return lexical_cast(d); } template<> int convert(string const s) { return strtol(s.c_str(), 0, 10); } template<> int convert(docstring const s) { return strtol(to_ascii(s).c_str(), 0, 10); } template<> unsigned int convert(string const s) { return strtoul(s.c_str(), 0, 10); } template<> unsigned long convert(string const s) { return strtoul(s.c_str(), 0, 10); } template<> double convert(string const s) { return strtod(s.c_str(), 0); } template<> int convert(char const * cptr) { return strtol(cptr, 0, 10); } template<> double convert(char const * cptr) { return strtod(cptr, 0); } } // namespace lyx