Skip to content

Commit c756506

Browse files
New to_uppercase utils function (#47)
Signed-off-by: Juan López Fernández <juanlopez@eprosima.com>
1 parent 39febed commit c756506

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

cpp_utils/include/cpp_utils/utils.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ CPP_UTILS_DllAPI bool match_pattern(
7777
CPP_UTILS_DllAPI void to_lowercase(
7878
std::string& st) noexcept;
7979

80+
/**
81+
* @brief Convert every alphabetic char in string to upper case
82+
*
83+
* @attention This function modifies the object given
84+
*
85+
* @param [in,out] st : string to modify
86+
*/
87+
CPP_UTILS_DllAPI void to_uppercase(
88+
std::string& st) noexcept;
89+
8090
template <typename T, bool Ptr = false>
8191
std::ostream& element_to_stream(
8292
std::ostream& os,

cpp_utils/src/cpp/utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ void to_lowercase(
8989
});
9090
}
9191

92+
void to_uppercase(
93+
std::string& st) noexcept
94+
{
95+
std::transform(st.begin(), st.end(), st.begin(),
96+
[](unsigned char c)
97+
{
98+
return std::toupper(c);
99+
});
100+
}
101+
92102
void tsnh(
93103
const Formatter& formatter)
94104
{

0 commit comments

Comments
 (0)