root / Community Core Vision / Linux / libs / poco / include / Poco / Base64Decoder.h @ 9
View | Annotate | Download (3.2 KB)
| 1 | 9 | amit | //
|
|---|---|---|---|
| 2 | 9 | amit | // Base64Decoder.h
|
| 3 | 9 | amit | //
|
| 4 | 9 | amit | // $Id: //poco/1.3/Foundation/include/Poco/Base64Decoder.h#2 $
|
| 5 | 9 | amit | //
|
| 6 | 9 | amit | // Library: Foundation
|
| 7 | 9 | amit | // Package: Streams
|
| 8 | 9 | amit | // Module: Base64
|
| 9 | 9 | amit | //
|
| 10 | 9 | amit | // Definition of class Base64Decoder.
|
| 11 | 9 | amit | //
|
| 12 | 9 | amit | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
| 13 | 9 | amit | // and Contributors.
|
| 14 | 9 | amit | //
|
| 15 | 9 | amit | // Permission is hereby granted, free of charge, to any person or organization
|
| 16 | 9 | amit | // obtaining a copy of the software and accompanying documentation covered by
|
| 17 | 9 | amit | // this license (the "Software") to use, reproduce, display, distribute,
|
| 18 | 9 | amit | // execute, and transmit the Software, and to prepare derivative works of the
|
| 19 | 9 | amit | // Software, and to permit third-parties to whom the Software is furnished to
|
| 20 | 9 | amit | // do so, all subject to the following:
|
| 21 | 9 | amit | //
|
| 22 | 9 | amit | // The copyright notices in the Software and this entire statement, including
|
| 23 | 9 | amit | // the above license grant, this restriction and the following disclaimer,
|
| 24 | 9 | amit | // must be included in all copies of the Software, in whole or in part, and
|
| 25 | 9 | amit | // all derivative works of the Software, unless such copies or derivative
|
| 26 | 9 | amit | // works are solely in the form of machine-executable object code generated by
|
| 27 | 9 | amit | // a source language processor.
|
| 28 | 9 | amit | //
|
| 29 | 9 | amit | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 30 | 9 | amit | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 31 | 9 | amit | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
| 32 | 9 | amit | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
| 33 | 9 | amit | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
| 34 | 9 | amit | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
| 35 | 9 | amit | // DEALINGS IN THE SOFTWARE.
|
| 36 | 9 | amit | //
|
| 37 | 9 | amit | |
| 38 | 9 | amit | |
| 39 | 9 | amit | #ifndef Foundation_Base64Decoder_INCLUDED
|
| 40 | 9 | amit | #define Foundation_Base64Decoder_INCLUDED
|
| 41 | 9 | amit | |
| 42 | 9 | amit | |
| 43 | 9 | amit | #include "Poco/Foundation.h" |
| 44 | 9 | amit | #include "Poco/UnbufferedStreamBuf.h" |
| 45 | 9 | amit | #include <istream> |
| 46 | 9 | amit | |
| 47 | 9 | amit | |
| 48 | 9 | amit | namespace Poco {
|
| 49 | 9 | amit | |
| 50 | 9 | amit | |
| 51 | 9 | amit | class Foundation_API Base64DecoderBuf: public UnbufferedStreamBuf
|
| 52 | 9 | amit | /// This streambuf base64-decodes all data read
|
| 53 | 9 | amit | /// from the istream connected to it.
|
| 54 | 9 | amit | {
|
| 55 | 9 | amit | public:
|
| 56 | 9 | amit | Base64DecoderBuf(std::istream& istr); |
| 57 | 9 | amit | ~Base64DecoderBuf(); |
| 58 | 9 | amit | |
| 59 | 9 | amit | private:
|
| 60 | 9 | amit | int readFromDevice();
|
| 61 | 9 | amit | int readOne();
|
| 62 | 9 | amit | |
| 63 | 9 | amit | unsigned char _group[3]; |
| 64 | 9 | amit | int _groupLength;
|
| 65 | 9 | amit | int _groupIndex;
|
| 66 | 9 | amit | std::istream& _istr; |
| 67 | 9 | amit | |
| 68 | 9 | amit | static unsigned char IN_ENCODING[256]; |
| 69 | 9 | amit | static bool IN_ENCODING_INIT; |
| 70 | 9 | amit | |
| 71 | 9 | amit | private:
|
| 72 | 9 | amit | Base64DecoderBuf(const Base64DecoderBuf&);
|
| 73 | 9 | amit | Base64DecoderBuf& operator = (const Base64DecoderBuf&);
|
| 74 | 9 | amit | }; |
| 75 | 9 | amit | |
| 76 | 9 | amit | |
| 77 | 9 | amit | class Foundation_API Base64DecoderIOS: public virtual std::ios
|
| 78 | 9 | amit | /// The base class for Base64Decoder.
|
| 79 | 9 | amit | ///
|
| 80 | 9 | amit | /// This class is needed to ensure the correct initialization
|
| 81 | 9 | amit | /// order of the stream buffer and base classes.
|
| 82 | 9 | amit | {
|
| 83 | 9 | amit | public:
|
| 84 | 9 | amit | Base64DecoderIOS(std::istream& istr); |
| 85 | 9 | amit | ~Base64DecoderIOS(); |
| 86 | 9 | amit | Base64DecoderBuf* rdbuf(); |
| 87 | 9 | amit | |
| 88 | 9 | amit | protected:
|
| 89 | 9 | amit | Base64DecoderBuf _buf; |
| 90 | 9 | amit | |
| 91 | 9 | amit | private:
|
| 92 | 9 | amit | Base64DecoderIOS(const Base64DecoderIOS&);
|
| 93 | 9 | amit | Base64DecoderIOS& operator = (const Base64DecoderIOS&);
|
| 94 | 9 | amit | }; |
| 95 | 9 | amit | |
| 96 | 9 | amit | |
| 97 | 9 | amit | class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
|
| 98 | 9 | amit | /// This istream base64-decodes all data
|
| 99 | 9 | amit | /// read from the istream connected to it.
|
| 100 | 9 | amit | {
|
| 101 | 9 | amit | public:
|
| 102 | 9 | amit | Base64Decoder(std::istream& istr); |
| 103 | 9 | amit | ~Base64Decoder(); |
| 104 | 9 | amit | |
| 105 | 9 | amit | private:
|
| 106 | 9 | amit | Base64Decoder(const Base64Decoder&);
|
| 107 | 9 | amit | Base64Decoder& operator = (const Base64Decoder&);
|
| 108 | 9 | amit | }; |
| 109 | 9 | amit | |
| 110 | 9 | amit | |
| 111 | 9 | amit | } // namespace Poco
|
| 112 | 9 | amit | |
| 113 | 9 | amit | |
| 114 | 9 | amit | #endif // Foundation_Base64Decoder_INCLUDED |
