• Skip to content
  • Skip to link menu
Brand

API Documentation

  1. KDE API Reference
  2. KDE PIM
  3. KMime
  • KDE Home
  • Contact Us

Quick Links

Skip menu "KMime"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • File List
  • Dependencies
  • Related Pages

Class Picker

About

The KMime Library

Maintainer
Volker Krause
Supported platforms
Android, FreeBSD, iOS, Linux, MacOSX, Windows
Community
IRC: #kontact on Freenode
Mailing list: kde-pim
Use with CMake
find_package(KF5Mime)
target_link_libraries(yourapp KF5::Mime)
Use with QMake
QT += KMime 
Clone
git clone git://anongit.kde.org/kmime.git
Browse source
KMime on cgit.kde.org

KMime

  • kde
  • pim
  • kmime
  • src
kmime_charfreq.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  kmime_charfreq.h
3 
4  KMime, the KDE Internet mail/usenet news message library.
5  Copyright (c) 2001-2002 Marc Mutz <[email protected]>
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 */
57 #ifndef __KMIME_CHARFREQ_H__
58 #define __KMIME_CHARFREQ_H__
59 
60 #include <QByteArray>
61 #undef None
62 
63 namespace KMime
64 {
65 
78 class CharFreq
79 {
80 public:
87  explicit CharFreq(const QByteArray &buf);
88 
96  CharFreq(const char *buf, size_t len);
97 
101  enum Type {
102  None = 0,
103  EightBitData,
104  Binary = EightBitData,
105  SevenBitData,
106  EightBitText,
107  SevenBitText
108  };
109 
113  Q_REQUIRED_RESULT Type type() const;
114 
118  Q_REQUIRED_RESULT bool isEightBitData() const;
119 
123  Q_REQUIRED_RESULT bool isEightBitText() const;
124 
128  Q_REQUIRED_RESULT bool isSevenBitData() const;
129 
133  Q_REQUIRED_RESULT bool isSevenBitText() const;
134 
139  Q_REQUIRED_RESULT bool hasTrailingWhitespace() const;
140 
144  Q_REQUIRED_RESULT bool hasLeadingFrom() const;
145 
150  Q_REQUIRED_RESULT float printableRatio() const;
151 
156  Q_REQUIRED_RESULT float controlCodesRatio() const;
157 
158 private:
159  //@cond PRIVATE
160  uint mNUL; // count of NUL chars
161  uint mCTL; // count of CTLs (incl. DEL, excl. CR, LF, HT)
162  uint mCR; // count of CR chars
163  uint mLF; // count of LF chars
164  uint mCRLF; // count of LFs, preceded by CRs
165  uint mPrintable; // count of printable US-ASCII chars (SPC..~)
166  uint mEightBit; // count of other latin1 chars (those with 8th bit set)
167  uint mTotal; // count of all chars
168  uint mLineMin; // minimum line length
169  uint mLineMax; // maximum line length
170  bool mTrailingWS; // does the buffer contain trailing whitespace?
171  bool mLeadingFrom; // does the buffer contain lines starting with "From "?
172  //@endcond
173 
180  void count(const char *buf, size_t len);
181 };
182 
183 } // namespace KMime
184 
185 #endif /* __KMIME_CHARFREQ_H__ */
KMime::CharFreq::EightBitData
8bit binary
Definition: kmime_charfreq.h:103
KMime::CharFreq::SevenBitData
7bit binary
Definition: kmime_charfreq.h:105
KMime::CharFreq::EightBitText
8bit text
Definition: kmime_charfreq.h:106
KMime::CharFreq::isEightBitText
bool isEightBitText() const
Returns true if the data Type is EightBitText; false otherwise.
Definition: kmime_charfreq.cpp:169
QByteArray
KMime::CharFreq::Binary
8bit binary
Definition: kmime_charfreq.h:104
KMime::CharFreq::isEightBitData
bool isEightBitData() const
Returns true if the data Type is EightBitData; false otherwise.
Definition: kmime_charfreq.cpp:164
KMime
Definition: kmime_charfreq.h:63
KMime::CharFreq::isSevenBitText
bool isSevenBitText() const
Returns true if the data Type is SevenBitText; false otherwise.
Definition: kmime_charfreq.cpp:179
KMime::CharFreq::None
Unknown.
Definition: kmime_charfreq.h:102
KMime::CharFreq::hasTrailingWhitespace
bool hasTrailingWhitespace() const
Returns true if the data contains trailing whitespace.
Definition: kmime_charfreq.cpp:184
KMime::CharFreq::Type
Type
The different types of data.
Definition: kmime_charfreq.h:101
KMime::CharFreq::isSevenBitData
bool isSevenBitData() const
Returns true if the data Type is SevenBitData; false otherwise.
Definition: kmime_charfreq.cpp:174
KMime::CharFreq::printableRatio
float printableRatio() const
Returns the percentage of printable characters in the data.
Definition: kmime_charfreq.cpp:234
KMime::CharFreq::CharFreq
CharFreq(const QByteArray &buf)
Constructs a Character Frequency instance for a buffer buf of QByteArray data.
Definition: kmime_charfreq.cpp:49
KMime::CharFreq::hasLeadingFrom
bool hasLeadingFrom() const
Returns true if the data contains a line that starts with "From ".
Definition: kmime_charfreq.cpp:189
KMime::CharFreq::controlCodesRatio
float controlCodesRatio() const
Returns the percentage of control code characters (CTLs) in the data.
Definition: kmime_charfreq.cpp:243
KMime::CharFreq
A class for performing basic data typing using frequency count heuristics.
Definition: kmime_charfreq.h:78
KMime::CharFreq::type
Type type() const
Returns the data Type as derived from the class heuristics.
Definition: kmime_charfreq.cpp:194
KMime::CharFreq::SevenBitText
7bit text
Definition: kmime_charfreq.h:107
This file is part of the KDE documentation.
Documentation copyright © 1996-2019 The KDE developers.
Generated on Wed Dec 11 2019 07:13:21 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal