/
jiteman
/
jsd-foreign-libreoffice-cppunit
Обзор
Документация
Войти
/
jiteman
/
jsd-foreign-libreoffice-cppunit
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
include/cppunit/tools/StringHelper.h
54 строки
1 KB
jiteman
initial commit has been done
14 апр 2024, 15:49
14 апр 2024, 15:49
4c53812
Код
Авторство
О чём код?
#ifndef CPPUNIT_TOOLS_STRINGHELPER_H #define CPPUNIT_TOOLS_STRINGHELPER_H #include <cppunit/Portability.h> #include <cppunit/portability/Stream.h> #include <string> #include <type_traits> CPPUNIT_NS_BEGIN /*! \brief Methods for converting values to strings. Replaces CPPUNIT_NS::StringTools::toString */ namespace StringHelper { // work around to handle C++11 enum class correctly. We need an own conversion to std::string // as there is no implicit coversion to int for enum class. template<typename T> typename std::enable_if<!std::is_enum<T>::value, std::string>::type toString(const T& x) { OStringStream ost; ost << x; return ost.str(); } template<typename T> typename std::enable_if<std::is_enum<T>::value, std::string>::type toString(const T& x) { OStringStream ost; ost << static_cast<typename std::underlying_type<T>::type>(x); return ost.str(); } template<> inline std::string toString(const signed char& x) { return toString(static_cast<int>(x)); } template<> inline std::string toString(const unsigned char& x) { return toString(static_cast<unsigned int>(x)); } } CPPUNIT_NS_END #endif // CPPUNIT_TOOLS_STRINGHELPER_H