aboutsummaryrefslogtreecommitdiff
path: root/src/IsCharacterInSet.cpp
blob: 82625e9665b6aa66adbb12048f36011971cce027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
    }

}