aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-01 23:34:50 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-01 23:34:50 -0700
commit4c662109404c79440a62888ae8babff81ce1b71e (patch)
treeb94fb6d602c0160a74465d110e0b67b953500138
parentb9fed2eae03f6fb67c0497e486b2bbfec8b27a44 (diff)
Add NormalizeCaseInsensitiveString function
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/NormalizeCaseInsensitiveString.cpp24
-rw-r--r--src/NormalizeCaseInsensitiveString.hpp30
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 */