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/PercentEncodedCharacterDecoder.hpp | |
parent | 0a991ade05f2e98b412301cb47cb6112a374ee8c (diff) |
Refactoring
* Extract IsCharacterInSet to its own module.
* Extract PercentEncodedCharacterDecoder to its own module.
Diffstat (limited to 'src/PercentEncodedCharacterDecoder.hpp')
-rw-r--r-- | src/PercentEncodedCharacterDecoder.hpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/PercentEncodedCharacterDecoder.hpp b/src/PercentEncodedCharacterDecoder.hpp new file mode 100644 index 0000000..b3e207d --- /dev/null +++ b/src/PercentEncodedCharacterDecoder.hpp @@ -0,0 +1,85 @@ +#ifndef URI_PERCENT_ENCODED_CHARACTER_DECODER_HPP +#define URI_PERCENT_ENCODED_CHARACTER_DECODER_HPP + +/** + * @file PercentEncodedCharacterDecoder.hpp + * + * This module declares the Uri::PercentEncodedCharacterDecoder class. + * + * © 2018 by Richard Walters + */ + +#include <memory> +#include <stddef.h> + +namespace Uri { + + /** + * This class can take in a percent-encoded character, + * decode it, and also detect if there are any problems in the encoding. + */ + class PercentEncodedCharacterDecoder { + // Lifecycle management + public: + ~PercentEncodedCharacterDecoder(); + PercentEncodedCharacterDecoder(const PercentEncodedCharacterDecoder&) = delete; + PercentEncodedCharacterDecoder(PercentEncodedCharacterDecoder&&); + PercentEncodedCharacterDecoder& operator=(const PercentEncodedCharacterDecoder&) = delete; + PercentEncodedCharacterDecoder& operator=(PercentEncodedCharacterDecoder&&); + + // Methods + public: + /** + * This is the default constructor. + */ + PercentEncodedCharacterDecoder(); + + /** + * This method inputs the next encoded character. + * + * @param[in] c + * This is the next encoded character to give to the decoder. + * + * @return + * An indication of whether or not the encoded character + * was accepted is returned. + */ + bool NextEncodedCharacter(char c); + + /** + * This method checks to see if the decoder is done + * and has decoded the encoded character. + * + * @return + * An indication of whether or not the decoder is done + * and has decoded the encoded character is returned. + */ + bool Done() const; + + /** + * This method returns the decoded character, once + * the decoder is done. + * + * @return + * The decoded character is returned. + */ + char GetDecodedCharacter() const; + + // Properties + private: + /** + * This is the type of structure that contains the private + * properties of the instance. It is defined in the implementation + * and declared here to ensure that it is scoped inside the class. + */ + struct Impl; + + /** + * This contains the private properties of the instance. + */ + std::unique_ptr< struct Impl > impl_; + }; + +} + +#endif /* URI_PERCENT_ENCODED_CHARACTER_DECODER_HPP */ |