diff options
author | Martin Fischer <martin@push-f.com> | 2021-12-05 01:44:45 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-12-05 01:53:28 +0100 |
commit | 799f2d02bea9bb16780bce01d4f3d831954bf9f0 (patch) | |
tree | a9c2d425aee007cf0f16cd2172f5f1a88f31d18b /src/PercentEncodedCharacterDecoder.cpp | |
parent | c3255c4473dd3976361ac52899c504c7f70c4be9 (diff) |
remove C++ implementation
Diffstat (limited to 'src/PercentEncodedCharacterDecoder.cpp')
-rw-r--r-- | src/PercentEncodedCharacterDecoder.cpp | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/PercentEncodedCharacterDecoder.cpp b/src/PercentEncodedCharacterDecoder.cpp deleted file mode 100644 index 442befe..0000000 --- a/src/PercentEncodedCharacterDecoder.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file PercentEncodedCharacterDecoder.cpp - * - * This module contains the implementation of the - * Uri::PercentEncodedCharacterDecoder class. - * - * © 2018 by Richard Walters - */ - -#include "CharacterSet.hpp" -#include "PercentEncodedCharacterDecoder.hpp" - -namespace { - - /** - * This is the character set containing just numbers. - */ - const Uri::CharacterSet DIGIT('0', '9'); - - /** - * This is the character set containing just the upper-case - * letters 'A' through 'F', used in upper-case hexadecimal. - */ - const Uri::CharacterSet HEX_UPPER('A', 'F'); - - /** - * This is the character set containing just the lower-case - * letters 'a' through 'f', used in lower-case hexadecimal. - */ - const Uri::CharacterSet HEX_LOWER('a', 'f'); - -} - -namespace Uri { - - struct PercentEncodedCharacterDecoder::Impl { - // Properties - - /** - * This is the decoded character. - */ - int decodedCharacter = 0; - - /** - * This is the number of digits that we still need to shift in - * to decode the character. - */ - size_t digitsLeft = 2; - - // Methods - - /** - * This method shifts in the given hex digit as part of - * building the decoded character. - * - * @param[in] c - * This is the hex digit to shift into the decoded character. - * - * @return - * An indication of whether or not the given hex digit - * was valid is returned. - */ - bool ShiftInHexDigit(char c) { - decodedCharacter <<= 4; - if (DIGIT.Contains(c)) { - decodedCharacter += (int)(c - '0'); - } else if (HEX_UPPER.Contains(c)) { - decodedCharacter += (int)(c - 'A') + 10; - } else if (HEX_LOWER.Contains(c)) { - decodedCharacter += (int)(c - 'a') + 10; - } else { - return false; - } - return true; - } - }; - - PercentEncodedCharacterDecoder::~PercentEncodedCharacterDecoder() noexcept = default; - PercentEncodedCharacterDecoder::PercentEncodedCharacterDecoder(PercentEncodedCharacterDecoder&&) noexcept = default; - PercentEncodedCharacterDecoder& PercentEncodedCharacterDecoder::operator=(PercentEncodedCharacterDecoder&&) noexcept = default; - - PercentEncodedCharacterDecoder::PercentEncodedCharacterDecoder() - : impl_(new Impl) - { - } - - bool PercentEncodedCharacterDecoder::NextEncodedCharacter(char c) { - if (!impl_->ShiftInHexDigit(c)) { - return false; - } - --impl_->digitsLeft; - return true; - } - - bool PercentEncodedCharacterDecoder::Done() const { - return (impl_->digitsLeft == 0); - } - - char PercentEncodedCharacterDecoder::GetDecodedCharacter() const { - return (char)impl_->decodedCharacter; - } - -} |