KCodecs

kcodecsuuencode.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  SPDX-FileCopyrightText: 2002 Marc Mutz <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
21 #ifndef KCODECS_UUENCODE_H
22 #define KCODECS_UUENCODE_H
23 
24 #include "kcodecs.h"
25 
26 namespace KCodecs
27 {
28 
33 class UUCodec : public Codec
34 {
35 public:
40  : Codec()
41  {}
42 
46  ~UUCodec() override {}
47 
52  const char *name() const override
53  {
54  return "x-uuencode";
55  }
56 
61  int maxEncodedSizeFor(int insize, NewlineType newline = Codec::NewlineLF) const override
62  {
63  Q_UNUSED(newline);
64  return insize; // we have no encoder!
65  }
66 
71  int maxDecodedSizeFor(int insize, NewlineType newline = Codec::NewlineLF) const override
72  {
73  // assuming all characters are part of the uuencode stream (which
74  // does almost never hold due to required linebreaking; but
75  // additional non-uu chars don't affect the output size), each
76  // 4-tupel of them becomes a 3-tupel in the decoded octet
77  // stream. So:
78  int result = ((insize + 3) / 4) * 3;
79  // but all of them may be \n, so
80  if (newline == Codec::NewlineCRLF) {
81  result *= 2; // :-o
82  }
83  return result;
84  }
85 
90  Encoder *makeEncoder(NewlineType newline = Codec::NewlineLF) const override;
91 
96  Decoder *makeDecoder(NewlineType newline = Codec::NewlineLF) const override;
97 };
98 
99 } // namespace KCodecs
100 
101 #endif // KCODECS_UUENCODE_H
An abstract base class of codecs for common mail transfer encodings.
Definition: kcodecs.h:373
int maxDecodedSizeFor(int insize, NewlineType newline=Codec::NewlineLF) const override
int maxEncodedSizeFor(int insize, NewlineType newline=Codec::NewlineLF) const override
Decoder * makeDecoder(NewlineType newline=Codec::NewlineLF) const override
A class representing the UUEncode codec.
A wrapper class for the most commonly used encoding and decoding algorithms.
Definition: kcodecs.cpp:49
const char * name() const override
Encoder * makeEncoder(NewlineType newline=Codec::NewlineLF) const override
Stateful encoder class.
Definition: kcodecs.h:695
UUCodec()
Constructs a UUEncode codec.
Stateful CTE decoder class.
Definition: kcodecs.h:638
~UUCodec() override
Destroys the codec.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 22:45:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.