/**
- * \file tostr.C
+ * \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
+ * \author André Pönitz
+ * \author Lars Gullik Bjønnes
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
-#include "convert.h"
-
+#include "support/convert.h"
#include "support/docstring.h"
#include <boost/lexical_cast.hpp>
#include <string>
+#include <sstream>
+//needed for Mac OSX 10.5.2 Leopard
+#include <cstdlib>
+using namespace std;
namespace lyx {
-using lyx::docstring;
-
using boost::lexical_cast;
-using std::string;
-
-
template<>
string convert<string>(bool b)
{
template<>
docstring convert<docstring>(int i)
{
- return lyx::from_ascii(lexical_cast<string>(i));
+ return from_ascii(lexical_cast<string>(i));
}
template<>
docstring convert<docstring>(unsigned int ui)
{
- return lyx::from_ascii(lexical_cast<string>(ui));
+ return from_ascii(lexical_cast<string>(ui));
}
template<>
docstring convert<docstring>(unsigned long ul)
{
- return lyx::from_ascii(lexical_cast<string>(ul));
+ return from_ascii(lexical_cast<string>(ul));
}
template<>
docstring convert<docstring>(long l)
{
- return lyx::from_ascii(lexical_cast<string>(l));
+ return from_ascii(lexical_cast<string>(l));
}
template<>
string convert<string>(float f)
{
- return lexical_cast<string>(f);
+ std::ostringstream val;
+ val << f;
+ return val.str();
}
template<>
string convert<string>(double d)
{
- return lexical_cast<string>(d);
+ std::ostringstream val;
+ val << d;
+ return val.str();
}
template<>
int convert<int>(docstring const s)
{
- return strtol(lyx::to_ascii(s).c_str(), 0, 10);
+ return strtol(to_ascii(s).c_str(), 0, 10);
}
}
+template<>
+unsigned long convert<unsigned long>(string const s)
+{
+ return strtoul(s.c_str(), 0, 10);
+}
+
+
template<>
double convert<double>(string const s)
{