From 1c7f229eb8f1f7929dd4d9f385ef24fdd7db80b1 Mon Sep 17 00:00:00 2001 From: Felix Schindler <felix.schindler@wwu.de> Date: Tue, 21 Mar 2017 16:33:47 +0100 Subject: [PATCH] [string] add to_upper --- dune/xt/common/string.cc | 8 ++++++++ dune/xt/common/string.hh | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/dune/xt/common/string.cc b/dune/xt/common/string.cc index ddae4e45b..c4d2b1453 100644 --- a/dune/xt/common/string.cc +++ b/dune/xt/common/string.cc @@ -29,6 +29,14 @@ std::string to_lower(const std::string& ss) } +std::string to_upper(const std::string& ss) +{ + std::string out(ss); + std::transform(out.begin(), out.end(), out.begin(), ::toupper); + return out; +} + + } // namespace Common } // namespace XT } // namespace Dune diff --git a/dune/xt/common/string.hh b/dune/xt/common/string.hh index 8ce2dbdf3..570a22dee 100644 --- a/dune/xt/common/string.hh +++ b/dune/xt/common/string.hh @@ -119,6 +119,15 @@ static inline std::string to_string(const T& ss, const size_t precision = defaul std::string to_lower(const std::string& ss); +/** + * \brief Converts each character of a string to upper case using std::toupper. + * \note This might not do what you expect, given your locale. + * \sa http://en.cppreference.com/w/cpp/string/byte/tolower + * /sa ::toupper + */ +std::string to_upper(const std::string& ss); + + /** \brief Returns a string of lengths t' whitespace (or whitespace chars). \param[in] t defines the length of the return string (after conversion to string) -- GitLab