aboutsummaryrefslogtreecommitdiff
path: root/src/IsCharacterInSet.cpp
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-01 16:08:20 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-01 16:08:20 -0700
commitcdc3f449812d0d45a3ea271636d669eb05ba3751 (patch)
tree1f46bea16d444b84a84843aed8bc9a0ebcadced5 /src/IsCharacterInSet.cpp
parent0a991ade05f2e98b412301cb47cb6112a374ee8c (diff)
Refactoring
* Extract IsCharacterInSet to its own module. * Extract PercentEncodedCharacterDecoder to its own module.
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;
+ }
+
+}