summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/textparser.h
authorllornkcor <llornkcor>2003-04-06 17:45:00 (UTC)
committer llornkcor <llornkcor>2003-04-06 17:45:00 (UTC)
commit70b1ff1a3f134d75d1539f269d52b34e6762684d (patch) (unidiff)
tree28c1b3d0c03e8c0188f014dfe094645d1ddfef5f /noncore/unsupported/mailit/textparser.h
parent75e8f29020e267d1013a79839831035073b4eeae (diff)
downloadopie-70b1ff1a3f134d75d1539f269d52b34e6762684d.zip
opie-70b1ff1a3f134d75d1539f269d52b34e6762684d.tar.gz
opie-70b1ff1a3f134d75d1539f269d52b34e6762684d.tar.bz2
move malit to head again, since it is working
Diffstat (limited to 'noncore/unsupported/mailit/textparser.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/textparser.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/noncore/unsupported/mailit/textparser.h b/noncore/unsupported/mailit/textparser.h
new file mode 100644
index 0000000..016effb
--- a/dev/null
+++ b/noncore/unsupported/mailit/textparser.h
@@ -0,0 +1,85 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qt Palmtop Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qobject.h>
21#include <qstring.h>
22
23#ifndef TEXTPARSER_H
24#define TEXTPARSER_H
25
26enum t_strType { Word, Number};
27enum t_lineType {NewLine, LastLine};
28
29 const uint MAX_ELEMENTS = 200; //Should be dynamic
30 const uint MAX_LINES = 500; //Should be dynamic
31
32struct t_splitElm
33{
34 QChar separator;
35 int strType;
36 QString str;
37};
38
39struct t_splitLine
40{
41 t_lineType lineType;
42 QString str; //a bit redundant...
43 t_splitElm elm[MAX_ELEMENTS];
44 int elmCount;
45};
46
47class TextParser: public QObject
48{
49 Q_OBJECT
50
51public:
52 TextParser(QString in, QString lineBreak);
53 TextParser(QString in, QString lineBreak, QString sep);
54 int find(QString target, QChar sep, int pos, bool upperCase);
55 int elmCount();
56 QChar separatorAt(int pos);
57 QChar nextSeparator();
58 bool hasNextSeparator();
59 QString wordAt(int pos);
60 QString nextWord();
61 bool hasNextWord();
62 QString getString(int *pos, QChar stop, bool lineEnd = false);
63 QString getNextLine();
64 bool hasNextLine();
65 int endLinePos(int pos);
66
67private:
68 void init();
69 void createSeparators();
70 t_splitLine nextLine();
71 void split();
72 t_splitLine splitLine(t_splitLine line);
73 bool isSeparator(QChar chr);
74 t_splitLine splitDone[MAX_LINES];
75 int getLineReference(int pos, int *line, int *inLinePos);
76
77 int lineCount, linePos, totalElmCount;
78 int separatorPos, wordPos;
79 QString data, separators, lineSep;
80 int sepAtLine, sepAtPosElm;
81 int wordAtLine, wordAtPosElm;
82 int atLine, atPosElm;
83};
84
85#endif