aboutsummaryrefslogtreecommitdiff
path: root/src/IsCharacterInSet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/IsCharacterInSet.cpp')
-rw-r--r--src/IsCharacterInSet.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/IsCharacterInSet.cpp b/src/IsCharacterInSet.cpp
new file mode 100644
index 0000000..82625e9
--- /dev/null
+++ b/src/IsCharacterInSet.cpp
@@ -0,0 +1,35 @@
+/**
+ * @file IsCharacterInSet.cpp
+ *
+ * This module contains the implementation of the
+ * Uri::IsCharacterInSet function.
+ *
+ * © 2018 by Richard Walters
+ */
+
+#include "IsCharacterInSet.hpp"
+
+namespace Uri {
+
+ bool IsCharacterInSet(
+ char c,
+ std::initializer_list< char > characterSet
+ ) {
+ for (
+ auto charInSet = characterSet.begin();
+ charInSet != characterSet.end();
+ ++charInSet
+ ) {
+ const auto first = *charInSet++;
+ const auto last = *charInSet;
+ if (
+ (c >= first)
+ && (c <= last)
+ ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}