General Utility Library for C++14  2.11
case_ascii.h
Go to the documentation of this file.
1 
24 #ifndef GUL14_CASE_ASCII_H_
25 #define GUL14_CASE_ASCII_H_
26 
27 #include <string>
28 
29 #include "gul14/internal.h"
30 #include "gul14/string_view.h"
31 
32 namespace gul14 {
33 
48 constexpr char lowercase_ascii(char c) noexcept
49 {
50  if (c >= 'A' && c <= 'Z')
51  c = static_cast<char>(c + ('a' - 'A'));
52  return c;
53 }
54 
63 GUL_EXPORT
64 std::string lowercase_ascii(gul14::string_view str);
65 
76 GUL_EXPORT
77 std::string& lowercase_ascii_inplace(std::string& str) noexcept;
78 
87 constexpr char uppercase_ascii(char c) noexcept
88 {
89  if (c >= 'a' && c <= 'z')
90  c = static_cast<char>(c - ('a' - 'A'));
91  return c;
92 }
93 
102 GUL_EXPORT
103 std::string uppercase_ascii(gul14::string_view str);
104 
115 GUL_EXPORT
116 std::string& uppercase_ascii_inplace(std::string& str) noexcept;
117 
119 
120 } // namespace gul14
121 
122 #endif
123 
124 /* vim:set expandtab softtabstop=4 tabstop=4 shiftwidth=4 textwidth=90 cindent: */
GUL_EXPORT std::string & lowercase_ascii_inplace(std::string &str) noexcept
Replace all ASCII characters in a string by their lowercase equivalents.
Definition: case_ascii.cc:40
constexpr char lowercase_ascii(char c) noexcept
Return the ASCII lowercase equivalent of the given character (or the unchanged character,...
Definition: case_ascii.h:48
constexpr char uppercase_ascii(char c) noexcept
Return the ASCII uppercase equivalent of the given character (or the unchanged character,...
Definition: case_ascii.h:87
GUL_EXPORT std::string & uppercase_ascii_inplace(std::string &str) noexcept
Replace all ASCII characters in a string by their uppercase equivalents.
Definition: case_ascii.cc:59
Definition of macros used internally by GUL.
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26
Provides a gul14::string_view that is fully compatible with C++17's std::string_view.