diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2018-08-05 15:23:56 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2018-08-05 15:23:56 -0700 |
commit | 54881d9f90acfb1676b3eebb0feb17811d1cc4bf (patch) | |
tree | 4bbadb21100a85dc7d95e4fd844e3e3839645860 /src | |
parent | a09abace8d4ec0d2fc9bb65493dfae7b7ce8e0fe (diff) |
Use SystemAbstractions::ToLower instead of doing it ourselves
Diffstat (limited to 'src')
-rw-r--r-- | src/NormalizeCaseInsensitiveString.cpp | 24 | ||||
-rw-r--r-- | src/NormalizeCaseInsensitiveString.hpp | 30 | ||||
-rw-r--r-- | src/Uri.cpp | 8 |
3 files changed, 4 insertions, 58 deletions
diff --git a/src/NormalizeCaseInsensitiveString.cpp b/src/NormalizeCaseInsensitiveString.cpp deleted file mode 100644 index 761c72a..0000000 --- a/src/NormalizeCaseInsensitiveString.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @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 deleted file mode 100644 index 014dd74..0000000 --- a/src/NormalizeCaseInsensitiveString.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#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 */ diff --git a/src/Uri.cpp b/src/Uri.cpp index cb44c1e..4d08e38 100644 --- a/src/Uri.cpp +++ b/src/Uri.cpp @@ -7,7 +7,6 @@ */ #include "CharacterSet.hpp" -#include "NormalizeCaseInsensitiveString.hpp" #include "PercentEncodedCharacterDecoder.hpp" #include <algorithm> @@ -16,6 +15,7 @@ #include <memory> #include <sstream> #include <string> +#include <SystemAbstractions/StringExtensions.hpp> #include <Uri/Uri.hpp> #include <vector> @@ -869,7 +869,7 @@ namespace Uri { return false; } if (hostIsRegName) { - host = NormalizeCaseInsensitiveString(host); + host = SystemAbstractions::ToLower(host); } if (portString.empty()) { hasPort = false; @@ -926,7 +926,7 @@ namespace Uri { ) { return false; } - scheme = NormalizeCaseInsensitiveString(scheme); + scheme = SystemAbstractions::ToLower(scheme); rest = uriString.substr(schemeEnd + 1); } return true; @@ -1439,7 +1439,7 @@ namespace Uri { } if (!impl_->host.empty()) { if (ValidateIpv6Address(impl_->host)) { - buffer << '[' << NormalizeCaseInsensitiveString(impl_->host) << ']'; + buffer << '[' << SystemAbstractions::ToLower(impl_->host) << ']'; } else { buffer << EncodeElement(impl_->host, REG_NAME_NOT_PCT_ENCODED); } |