string: extend strupr
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
02c531e2a8
commit
a888731c39
@ -16,6 +16,7 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <xlocale.h>
|
#include <xlocale.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -1368,12 +1369,26 @@ namespace stdex
|
|||||||
/// \param[in] count Code unit limit
|
/// \param[in] count Code unit limit
|
||||||
///
|
///
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void strupr
|
inline void strupr(_Inout_updates_z_(count) T* str, _In_ size_t count, _In_ const std::locale& locale)
|
||||||
(_Inout_updates_z_(count) T* str, _In_ size_t count, _In_ const std::locale& locale)
|
|
||||||
{
|
{
|
||||||
assert(str || !count);
|
assert(str || !count);
|
||||||
const auto& ctype = std::use_facet<std::ctype<T>>(locale);
|
const auto& ctype = std::use_facet<std::ctype<T>>(locale);
|
||||||
for (size_t i = 0; i < count && str[i]; ++i)
|
for (size_t i = 0; i < count && str[i]; ++i)
|
||||||
str[i] = ctype.toupper(str[i]);
|
str[i] = ctype.toupper(str[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Convert string to upper-case character-by-character
|
||||||
|
///
|
||||||
|
/// \note For legacy code support only.
|
||||||
|
///
|
||||||
|
/// \param[in,out] str String
|
||||||
|
///
|
||||||
|
template<class _Elem, class _Traits = std::char_traits<_Elem>, class _Ax = std::allocator<_Elem>>
|
||||||
|
inline void strupr(_Inout_ std::basic_string<_Elem, _Traits, _Ax>& str, _In_ const std::locale& locale)
|
||||||
|
{
|
||||||
|
const auto& ctype = std::use_facet<std::ctype<_Elem>>(locale);
|
||||||
|
for (size_t i = 0; i < str.size(); ++i)
|
||||||
|
str[i] = ctype.toupper(str[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user