2003-05-13 14:36:24 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/**
|
|
|
|
|
* \file tostr.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2005-01-06 15:40:49 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2003-05-13 14:36:24 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-05-13 14:36:24 +00:00
|
|
|
|
*
|
|
|
|
|
* A collection of string helper functions that works with string.
|
|
|
|
|
* Some of these would certainly benefit from a rewrite/optimization.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef TOSTR_H
|
|
|
|
|
#define TOSTR_H
|
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
#include <boost/static_assert.hpp>
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
2003-05-13 14:36:24 +00:00
|
|
|
|
|
2005-01-06 15:40:49 +00:00
|
|
|
|
template <class Target, class Source>
|
|
|
|
|
Target convert(Source arg)
|
|
|
|
|
{
|
|
|
|
|
// We use a static assert here since we want all instances of
|
|
|
|
|
// this template to be specializations.
|
|
|
|
|
BOOST_STATIC_ASSERT(sizeof(bool) == 0);
|
|
|
|
|
return Target();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(bool);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(char);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(unsigned short);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(int);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(unsigned int);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(float);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(double);
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
std::string convert<std::string>(std::string);
|
2003-05-13 14:36:24 +00:00
|
|
|
|
|
|
|
|
|
#endif
|