1 | /* -*- c++ -*- |
2 | kmime_codec_uuencode.h |
3 | |
4 | KMime, the KDE Internet mail/usenet news message library. |
5 | Copyright (c) 2002 Marc Mutz <mutz@kde.org> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | /** |
23 | @file |
24 | This file is part of the API for handling @ref MIME data and |
25 | defines a @ref uuencode @ref Codec class. |
26 | |
27 | @brief |
28 | Defines the UUCodec class. |
29 | |
30 | @authors Marc Mutz \<mutz@kde.org\> |
31 | |
32 | @glossary @anchor UUEncode @anchor uuencode @b uuencode: |
33 | a binary to text encoding scheme. For more information, see the |
34 | <a href="http://en.wikipedia.org/wiki/Uuencode"> Wikipedia Uuencode page</a>. |
35 | */ |
36 | |
37 | #ifndef __KMIME_CODEC_UUENCODE_H__ |
38 | #define __KMIME_CODEC_UUENCODE_H__ |
39 | |
40 | #include "kmime_codecs.h" |
41 | |
42 | namespace KMime { |
43 | |
44 | /** |
45 | @brief |
46 | A class representing the @ref UUEncode @ref codec. |
47 | */ |
48 | class KMIME_EXPORT UUCodec : public Codec |
49 | { |
50 | protected: |
51 | friend class Codec; |
52 | /** |
53 | Constructs a UUEncode codec. |
54 | */ |
55 | UUCodec() : Codec() {} |
56 | |
57 | public: |
58 | /** |
59 | Destroys the codec. |
60 | */ |
61 | virtual ~UUCodec() {} |
62 | |
63 | /** |
64 | @copydoc |
65 | Codec::name() |
66 | */ |
67 | const char *name() const |
68 | { return "x-uuencode" ; } |
69 | |
70 | /** |
71 | @copydoc |
72 | Codec::maxEncodedSizeFor() |
73 | */ |
74 | int maxEncodedSizeFor( int insize, bool withCRLF=false ) const |
75 | { |
76 | (void)withCRLF; |
77 | return insize; // we have no encoder! |
78 | } |
79 | |
80 | /** |
81 | @copydoc |
82 | Codec::maxDecodedSizeFor() |
83 | */ |
84 | int maxDecodedSizeFor( int insize, bool withCRLF=false ) const |
85 | { |
86 | // assuming all characters are part of the uuencode stream (which |
87 | // does almost never hold due to required linebreaking; but |
88 | // additional non-uu chars don't affect the output size), each |
89 | // 4-tupel of them becomes a 3-tupel in the decoded octet |
90 | // stream. So: |
91 | int result = ( ( insize + 3 ) / 4 ) * 3; |
92 | // but all of them may be \n, so |
93 | if ( withCRLF ) { |
94 | result *= 2; // :-o |
95 | } |
96 | return result; |
97 | } |
98 | |
99 | /** |
100 | @copydoc |
101 | Codec::makeEncoder() |
102 | */ |
103 | Encoder *makeEncoder( bool withCRLF=false ) const; |
104 | |
105 | /** |
106 | @copydoc |
107 | Codec::makeEncoder() |
108 | */ |
109 | Decoder *makeDecoder( bool withCRLF=false ) const; |
110 | }; |
111 | |
112 | } // namespace KMime |
113 | |
114 | #endif // __KMIME_CODEC_UUENCODE_H__ |
115 | |