diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /libkmime/kmime_charfreq.h | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkmime/kmime_charfreq.h')
-rw-r--r-- | libkmime/kmime_charfreq.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/libkmime/kmime_charfreq.h b/libkmime/kmime_charfreq.h new file mode 100644 index 000000000..12d2035cf --- /dev/null +++ b/libkmime/kmime_charfreq.h @@ -0,0 +1,68 @@ +/* -*- c++ -*- + kmime_charfreq.h + + KMime, the KDE internet mail/usenet news message library. + Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US +*/ +#ifndef __KMIME_CHARFREQ_H__ +#define __KMIME_CHARFREQ_H__ + +#include <qcstring.h> +#include <kdepimmacros.h> +#undef None + +namespace KMime { + +class KDE_EXPORT CharFreq { +public: + CharFreq( const QByteArray & buf ); + CharFreq( const char * buf, size_t len ); + + enum Type { None = 0, EightBitData, Binary = EightBitData, + SevenBitData, EightBitText, SevenBitText }; + + Type type() const; + bool isEightBitData() const; + bool isEightBitText() const; + bool isSevenBitData() const; + bool isSevenBitText() const; + /** Returns true if buf has trailing whitespace, i.e. if any line ends + with space (' ') or tab ('\t'). */ + bool hasTrailingWhitespace() const; + /** Returns true if buf contains a line that starts with "From ". */ + bool hasLeadingFrom() const; + /** Returns the percentage of printable characters: printable/total. + If total == 0, the result is undefined. */ + float printableRatio() const; + /** Returns the percentage of control code (CTLs): CTL/total. + If total == 0, the result is undefined. */ + float controlCodesRatio() const; + +protected: + uint NUL; // count of NUL chars + uint CTL; // count of CTLs (incl. DEL, excl. CR, LF, HT) + uint CR, LF; // count of CRs and LFs + uint CRLF; // count of LFs, preceded by CRs + uint printable; // count of printable US-ASCII chars (SPC..~) + uint eightBit; // count of other latin1 chars (those with 8th bit set) + uint total; + uint lineMin; + uint lineMax; + bool mTrailingWS; // does the buffer contain trailing whitespace? + bool mLeadingFrom; // does the buffer contain lines starting with "From "? + +private: + void count( const char * buf, size_t len ); +}; + +} // namespace KMime + +#endif /* __KMIME_CHARFREQ_H__ */ |