| 1 | // | 
|---|
| 2 | // HexBinaryDecoder.h | 
|---|
| 3 | // | 
|---|
| 4 | // Library: Foundation | 
|---|
| 5 | // Package: Streams | 
|---|
| 6 | // Module:  HexBinary | 
|---|
| 7 | // | 
|---|
| 8 | // Definition of the HexBinaryDecoder class. | 
|---|
| 9 | // | 
|---|
| 10 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. | 
|---|
| 11 | // and Contributors. | 
|---|
| 12 | // | 
|---|
| 13 | // SPDX-License-Identifier:	BSL-1.0 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | #ifndef Foundation_HexBinaryDecoder_INCLUDED | 
|---|
| 18 | #define Foundation_HexBinaryDecoder_INCLUDED | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | #include "Poco/Foundation.h" | 
|---|
| 22 | #include "Poco/UnbufferedStreamBuf.h" | 
|---|
| 23 | #include <istream> | 
|---|
| 24 |  | 
|---|
| 25 |  | 
|---|
| 26 | namespace Poco { | 
|---|
| 27 |  | 
|---|
| 28 |  | 
|---|
| 29 | class Foundation_API HexBinaryDecoderBuf: public UnbufferedStreamBuf | 
|---|
| 30 | /// This streambuf decodes all hexBinary-encoded data read | 
|---|
| 31 | /// from the istream connected to it. | 
|---|
| 32 | /// In hexBinary encoding, each binary octet is encoded as a character tuple, | 
|---|
| 33 | /// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code. | 
|---|
| 34 | /// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/), | 
|---|
| 35 | /// section 3.2.15. | 
|---|
| 36 | /// | 
|---|
| 37 | /// Note: For performance reasons, the characters | 
|---|
| 38 | /// are read directly from the given istream's | 
|---|
| 39 | /// underlying streambuf, so the state | 
|---|
| 40 | /// of the istream will not reflect that of | 
|---|
| 41 | /// its streambuf. | 
|---|
| 42 | { | 
|---|
| 43 | public: | 
|---|
| 44 | HexBinaryDecoderBuf(std::istream& istr); | 
|---|
| 45 | ~HexBinaryDecoderBuf(); | 
|---|
| 46 |  | 
|---|
| 47 | private: | 
|---|
| 48 | int readFromDevice(); | 
|---|
| 49 | int readOne(); | 
|---|
| 50 |  | 
|---|
| 51 | std::streambuf& _buf; | 
|---|
| 52 | }; | 
|---|
| 53 |  | 
|---|
| 54 |  | 
|---|
| 55 | class Foundation_API HexBinaryDecoderIOS: public virtual std::ios | 
|---|
| 56 | /// The base class for HexBinaryDecoder. | 
|---|
| 57 | /// | 
|---|
| 58 | /// This class is needed to ensure the correct initialization | 
|---|
| 59 | /// order of the stream buffer and base classes. | 
|---|
| 60 | { | 
|---|
| 61 | public: | 
|---|
| 62 | HexBinaryDecoderIOS(std::istream& istr); | 
|---|
| 63 | ~HexBinaryDecoderIOS(); | 
|---|
| 64 | HexBinaryDecoderBuf* rdbuf(); | 
|---|
| 65 |  | 
|---|
| 66 | protected: | 
|---|
| 67 | HexBinaryDecoderBuf _buf; | 
|---|
| 68 | }; | 
|---|
| 69 |  | 
|---|
| 70 |  | 
|---|
| 71 | class Foundation_API HexBinaryDecoder: public HexBinaryDecoderIOS, public std::istream | 
|---|
| 72 | /// This istream decodes all hexBinary-encoded data read | 
|---|
| 73 | /// from the istream connected to it. | 
|---|
| 74 | /// In hexBinary encoding, each binary octet is encoded as a character tuple, | 
|---|
| 75 | /// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code. | 
|---|
| 76 | /// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/), | 
|---|
| 77 | /// section 3.2.15. | 
|---|
| 78 | /// | 
|---|
| 79 | /// Note: For performance reasons, the characters | 
|---|
| 80 | /// are read directly from the given istream's | 
|---|
| 81 | /// underlying streambuf, so the state | 
|---|
| 82 | /// of the istream will not reflect that of | 
|---|
| 83 | /// its streambuf. | 
|---|
| 84 | { | 
|---|
| 85 | public: | 
|---|
| 86 | HexBinaryDecoder(std::istream& istr); | 
|---|
| 87 | ~HexBinaryDecoder(); | 
|---|
| 88 | }; | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|
| 91 | } // namespace Poco | 
|---|
| 92 |  | 
|---|
| 93 |  | 
|---|
| 94 | #endif // Foundation_HexBinaryDecoder_INCLUDED | 
|---|
| 95 |  | 
|---|