kmime_charfreq.h
00001 /* -*- c++ -*- 00002 kmime_charfreq.h 00003 00004 KMime, the KDE internet mail/usenet news message library. 00005 Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 You should have received a copy of the GNU General Public License 00012 along with this program; if not, write to the Free Software Foundation, 00013 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US 00014 */ 00015 #ifndef __KMIME_CHARFRETQ_H__ 00016 #define __KMIME_CHARFRETQ_H__ 00017 00018 #include <tqcstring.h> 00019 #include <kdepimmacros.h> 00020 #undef None 00021 00022 namespace KMime { 00023 00024 class KDE_EXPORT CharFreq { 00025 public: 00026 CharFreq( const TQByteArray & buf ); 00027 CharFreq( const char * buf, size_t len ); 00028 00029 enum Type { None = 0, EightBitData, Binary = EightBitData, 00030 SevenBitData, EightBitText, SevenBitText }; 00031 00032 Type type() const; 00033 bool isEightBitData() const; 00034 bool isEightBitText() const; 00035 bool isSevenBitData() const; 00036 bool isSevenBitText() const; 00039 bool hasTrailingWhitespace() const; 00041 bool hasLeadingFrom() const; 00044 float printableRatio() const; 00047 float controlCodesRatio() const; 00048 00049 protected: 00050 uint NUL; // count of NUL chars 00051 uint CTL; // count of CTLs (incl. DEL, excl. CR, LF, HT) 00052 uint CR, LF; // count of CRs and LFs 00053 uint CRLF; // count of LFs, preceded by CRs 00054 uint printable; // count of printable US-ASCII chars (SPC..~) 00055 uint eightBit; // count of other latin1 chars (those with 8th bit set) 00056 uint total; 00057 uint lineMin; 00058 uint lineMax; 00059 bool mTrailingWS; // does the buffer contain trailing whitespace? 00060 bool mLeadingFrom; // does the buffer contain lines starting with "From "? 00061 00062 private: 00063 void count( const char * buf, size_t len ); 00064 }; 00065 00066 } // namespace KMime 00067 00068 #endif /* __KMIME_CHARFRETQ_H__ */