diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/NormalizeCaseInsensitiveString.cpp | 24 | ||||
-rw-r--r-- | src/NormalizeCaseInsensitiveString.hpp | 30 |
3 files changed, 56 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ab5ca79..9172e4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,11 +8,13 @@ set(This Uri) set(Headers include/Uri/Uri.hpp src/IsCharacterInSet.hpp + src/NormalizeCaseInsensitiveString.hpp src/PercentEncodedCharacterDecoder.hpp ) set(Sources src/IsCharacterInSet.cpp + src/NormalizeCaseInsensitiveString.cpp src/PercentEncodedCharacterDecoder.cpp src/Uri.cpp ) diff --git a/src/NormalizeCaseInsensitiveString.cpp b/src/NormalizeCaseInsensitiveString.cpp new file mode 100644 index 0000000..761c72a --- /dev/null +++ b/src/NormalizeCaseInsensitiveString.cpp @@ -0,0 +1,24 @@ +/** + * @file NormalizeCaseInsensitiveString.cpp + * + * This module contains the implementation of the + * Uri::NormalizeCaseInsensitiveString function. + * + * © 2018 by Richard Walters + */ + +#include "NormalizeCaseInsensitiveString.hpp" + +#include <ctype.h> + +namespace Uri { + + std::string NormalizeCaseInsensitiveString(const std::string& inString) { + std::string outString; + for (char c: inString) { + outString.push_back(tolower(c)); + } + return outString; + } + +} diff --git a/src/NormalizeCaseInsensitiveString.hpp b/src/NormalizeCaseInsensitiveString.hpp new file mode 100644 index 0000000..014dd74 --- /dev/null +++ b/src/NormalizeCaseInsensitiveString.hpp @@ -0,0 +1,30 @@ +#ifndef URI_NORMALIZE_CASE_INSENSITIVE_STRING_HPP +#define URI_NORMALIZE_CASE_INSENSITIVE_STRING_HPP + +/** + * @file NormalizeCaseInsensitiveString.hpp + * + * This module declares the Uri::NormalizeCaseInsensitiveString function. + * + * © 2018 by Richard Walters + */ + +#include <string> + +namespace Uri { + + /** + * This function takes a string and swaps all upper-case characters + * with their lower-case equivalents, returning the result. + * + * @param[in] inString + * This is the string to be normalized. + * + * @return + * The normalized string is returned. All upper-case characters + * are replaced with their lower-case equivalents. + */ + std::string NormalizeCaseInsensitiveString(const std::string& inString); +} + +#endif /* URI_NORMALIZE_CASE_INSENSITIVE_STRING_HPP */ |