diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2018-07-01 16:08:20 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2018-07-01 16:08:20 -0700 |
commit | cdc3f449812d0d45a3ea271636d669eb05ba3751 (patch) | |
tree | 1f46bea16d444b84a84843aed8bc9a0ebcadced5 /src/IsCharacterInSet.cpp | |
parent | 0a991ade05f2e98b412301cb47cb6112a374ee8c (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.cpp | 35 |
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; + } + +} |