"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xbmc/utils/StringUtils.h" between
xbmc-18.7.1-Leia.tar.gz and xbmc-18.8-Leia.tar.gz

About: XBMC is a software media player and entertainment hub for digital media that plays almost all popular audio and video formats around (new name "Kodi").

StringUtils.h  (xbmc-18.7.1-Leia):StringUtils.h  (xbmc-18.8-Leia)
skipping to change at line 54 skipping to change at line 54
#define foo 4 #define foo 4
DEF_TO_STR_NAME(foo) // outputs "foo" DEF_TO_STR_NAME(foo) // outputs "foo"
DEF_TO_STR_VALUE(foo) // outputs "4" DEF_TO_STR_VALUE(foo) // outputs "4"
*/ */
#define DEF_TO_STR_NAME(x) #x #define DEF_TO_STR_NAME(x) #x
#define DEF_TO_STR_VALUE(x) DEF_TO_STR_NAME(x) #define DEF_TO_STR_VALUE(x) DEF_TO_STR_NAME(x)
template< bool B, class T = void >
using enable_if_t = typename std::enable_if<B,T>::type;
template< class T > struct remove_rvalue_reference {typedef T type;};
template< class T > struct remove_rvalue_reference<T&> {typedef T& type;};
template< class T > struct remove_rvalue_reference<T*> {typedef T* type;};
template< class T > struct remove_rvalue_reference<T&&> {typedef T type;};
template<typename T, enable_if_t<!std::is_enum<T>::value, int> = 0>
constexpr auto EnumToInt(T&& arg) noexcept -> typename remove_rvalue_reference<d
ecltype(arg)>::type
{
return arg;
}
template<typename T, enable_if_t<std::is_enum<T>::value, int> = 0>
constexpr auto EnumToInt(T&& arg) noexcept -> int
{
return static_cast<int>(arg);
}
class StringUtils class StringUtils
{ {
public: public:
/*! \brief Get a formatted string similar to sprintf /*! \brief Get a formatted string similar to sprintf
Beware that this does not support directly passing in Beware that this does not support directly passing in
std::string objects. You need to call c_str() to pass std::string objects. You need to call c_str() to pass
the const char* buffer representing the value of the the const char* buffer representing the value of the
std::string object. std::string object.
\param fmt Format of the resulting string \param fmt Format of the resulting string
\param ... variable number of value type arguments \param ... variable number of value type arguments
\return Formatted string \return Formatted string
*/ */
template<typename... Args> template<typename... Args>
static std::string Format(const std::string& fmt, Args&&... args) static std::string Format(const std::string& fmt, Args&&... args)
{ {
// coverity[fun_call_w_exception : FALSE] // coverity[fun_call_w_exception : FALSE]
auto result = ::fmt::format(fmt, std::forward<Args>(args)...); auto result = ::fmt::format(fmt, EnumToInt(std::forward<Args>(args))...);
if (result == fmt) if (result == fmt)
result = ::fmt::sprintf(fmt, std::forward<Args>(args)...); result = ::fmt::sprintf(fmt, EnumToInt(std::forward<Args>(args))...);
return result; return result;
} }
template<typename... Args> template<typename... Args>
static std::wstring Format(const std::wstring& fmt, Args&&... args) static std::wstring Format(const std::wstring& fmt, Args&&... args)
{ {
// coverity[fun_call_w_exception : FALSE] // coverity[fun_call_w_exception : FALSE]
auto result = ::fmt::format(fmt, std::forward<Args>(args)...); auto result = ::fmt::format(fmt, EnumToInt(std::forward<Args>(args))...);
if (result == fmt) if (result == fmt)
result = ::fmt::sprintf(fmt, std::forward<Args>(args)...); result = ::fmt::sprintf(fmt, EnumToInt(std::forward<Args>(args))...);
return result; return result;
} }
static std::string FormatV(PRINTF_FORMAT_STRING const char *fmt, va_list args) ; static std::string FormatV(PRINTF_FORMAT_STRING const char *fmt, va_list args) ;
static std::wstring FormatV(PRINTF_FORMAT_STRING const wchar_t *fmt, va_list a rgs); static std::wstring FormatV(PRINTF_FORMAT_STRING const wchar_t *fmt, va_list a rgs);
static void ToUpper(std::string &str); static void ToUpper(std::string &str);
static void ToUpper(std::wstring &str); static void ToUpper(std::wstring &str);
static void ToLower(std::string &str); static void ToLower(std::string &str);
static void ToLower(std::wstring &str); static void ToLower(std::wstring &str);
 End of changes. 5 change blocks. 
4 lines changed or deleted 24 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)