author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kabc/vcard/testread.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | kabc/vcard/testread.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/kabc/vcard/testread.cpp b/kabc/vcard/testread.cpp index 919c661..4d66aaf 100644 --- a/kabc/vcard/testread.cpp +++ b/kabc/vcard/testread.cpp | |||
@@ -1,129 +1,131 @@ | |||
1 | #include <iostream> | 1 | #include <iostream> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <assert.h> | 3 | #include <assert.h> |
4 | 4 | ||
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <q3textstream.h> |
7 | //Added by qt3to4: | ||
8 | #include <Q3CString> | ||
7 | 9 | ||
8 | #include <VCard.h> | 10 | #include <VCard.h> |
9 | 11 | ||
10 | using namespace std; | 12 | using namespace std; |
11 | 13 | ||
12 | int main(int argc, char * argv[]) | 14 | int main(int argc, char * argv[]) |
13 | { | 15 | { |
14 | if (argc != 2) { | 16 | if (argc != 2) { |
15 | cerr << "Usage: " << argv[0] << " <filename>" << endl; | 17 | cerr << "Usage: " << argv[0] << " <filename>" << endl; |
16 | exit(1); | 18 | exit(1); |
17 | } | 19 | } |
18 | 20 | ||
19 | QFile f(argv[1]); | 21 | QFile f(argv[1]); |
20 | 22 | ||
21 | QCString str; | 23 | Q3CString str; |
22 | 24 | ||
23 | if (!f.open(IO_ReadOnly)) { | 25 | if (!f.open(QIODevice::ReadOnly)) { |
24 | cerr << "Couldn't open file \"" << argv[1] << endl; | 26 | cerr << "Couldn't open file \"" << argv[1] << endl; |
25 | exit(1); | 27 | exit(1); |
26 | } | 28 | } |
27 | 29 | ||
28 | QTextStream t(&f); | 30 | Q3TextStream t(&f); |
29 | 31 | ||
30 | while (!t.eof()) | 32 | while (!t.eof()) |
31 | str += t.readLine().utf8() + '\n'; | 33 | str += t.readLine().utf8() + '\n'; |
32 | 34 | ||
33 | using namespace VCARD; | 35 | using namespace VCARD; |
34 | 36 | ||
35 | // Iterate through all vCards in the file. | 37 | // Iterate through all vCards in the file. |
36 | 38 | ||
37 | cout << "--------- begin ----------" << endl; | 39 | cout << "--------- begin ----------" << endl; |
38 | cout << str.data(); | 40 | cout << str.data(); |
39 | cout << "--------- end ----------" << endl; | 41 | cout << "--------- end ----------" << endl; |
40 | 42 | ||
41 | VCardEntity e(str); | 43 | VCardEntity e(str); |
42 | 44 | ||
43 | VCardListIterator it(e.cardList()); | 45 | VCardListIterator it(e.cardList()); |
44 | 46 | ||
45 | for (; it.current(); ++it) { | 47 | for (; it.current(); ++it) { |
46 | 48 | ||
47 | cerr << "****************** VCARD ********************" << endl; | 49 | cerr << "****************** VCARD ********************" << endl; |
48 | 50 | ||
49 | // Create a vcard using the string representation. | 51 | // Create a vcard using the string representation. |
50 | VCard & v (*it.current()); | 52 | VCard & v (*it.current()); |
51 | 53 | ||
52 | if (v.has(EntityEmail)) { | 54 | if (v.has(EntityEmail)) { |
53 | cerr << "Email parameter found" << endl; | 55 | cerr << "Email parameter found" << endl; |
54 | 56 | ||
55 | QCString s = v.contentLine(EntityEmail)->value()->asString(); | 57 | Q3CString s = v.contentLine(EntityEmail)->value()->asString(); |
56 | 58 | ||
57 | cerr << "Email value == " << s << endl; | 59 | cerr << "Email value == " << s << endl; |
58 | } | 60 | } |
59 | 61 | ||
60 | if (v.has(EntityNickname)) { | 62 | if (v.has(EntityNickname)) { |
61 | cerr << "Nickname parameter found" << endl; | 63 | cerr << "Nickname parameter found" << endl; |
62 | 64 | ||
63 | cerr << "Nickname value == " << | 65 | cerr << "Nickname value == " << |
64 | v.contentLine(EntityNickname)->value()->asString() << | 66 | v.contentLine(EntityNickname)->value()->asString() << |
65 | endl; | 67 | endl; |
66 | } | 68 | } |
67 | 69 | ||
68 | if (v.has(EntityRevision)) { | 70 | if (v.has(EntityRevision)) { |
69 | 71 | ||
70 | cerr << "Revision parameter found" << endl; | 72 | cerr << "Revision parameter found" << endl; |
71 | 73 | ||
72 | DateValue * d = | 74 | DateValue * d = |
73 | (DateValue *) | 75 | (DateValue *) |
74 | v.contentLine(EntityRevision)->value(); | 76 | v.contentLine(EntityRevision)->value(); |
75 | 77 | ||
76 | assert(d != 0); | 78 | assert(d != 0); |
77 | 79 | ||
78 | cerr << "Revision date: " << endl; | 80 | cerr << "Revision date: " << endl; |
79 | cerr << "Day : " << d->day() << endl; | 81 | cerr << "Day : " << d->day() << endl; |
80 | cerr << "Month : " << d->month()<< endl; | 82 | cerr << "Month : " << d->month()<< endl; |
81 | cerr << "Year : " << d->year() << endl; | 83 | cerr << "Year : " << d->year() << endl; |
82 | 84 | ||
83 | if (d->hasTime()) { | 85 | if (d->hasTime()) { |
84 | cerr << "Revision date has a time component" << endl; | 86 | cerr << "Revision date has a time component" << endl; |
85 | cerr << "Revision time: " << endl; | 87 | cerr << "Revision time: " << endl; |
86 | cerr << "Hour : " << d->hour()<< endl; | 88 | cerr << "Hour : " << d->hour()<< endl; |
87 | cerr << "Minute : " << d->minute()<< endl; | 89 | cerr << "Minute : " << d->minute()<< endl; |
88 | cerr << "Second : " << d->second()<< endl; | 90 | cerr << "Second : " << d->second()<< endl; |
89 | 91 | ||
90 | } | 92 | } |
91 | else cerr << "Revision date does NOT have a time component" << endl; | 93 | else cerr << "Revision date does NOT have a time component" << endl; |
92 | } | 94 | } |
93 | 95 | ||
94 | if (v.has(EntityURL)) { | 96 | if (v.has(EntityURL)) { |
95 | cerr << "URL Parameter found" << endl; | 97 | cerr << "URL Parameter found" << endl; |
96 | 98 | ||
97 | cerr << "URL Value == " << | 99 | cerr << "URL Value == " << |
98 | v.contentLine(EntityURL)->value()->asString() << | 100 | v.contentLine(EntityURL)->value()->asString() << |
99 | endl; | 101 | endl; |
100 | 102 | ||
101 | URIValue * urlVal = | 103 | URIValue * urlVal = |
102 | (URIValue *)v.contentLine(EntityURL)->value(); | 104 | (URIValue *)v.contentLine(EntityURL)->value(); |
103 | 105 | ||
104 | assert(urlVal != 0); | 106 | assert(urlVal != 0); |
105 | 107 | ||
106 | cerr << "URL scheme == " << | 108 | cerr << "URL scheme == " << |
107 | urlVal->scheme() << endl; | 109 | urlVal->scheme() << endl; |
108 | 110 | ||
109 | cerr << "URL scheme specific part == " << | 111 | cerr << "URL scheme specific part == " << |
110 | urlVal->schemeSpecificPart() << endl; | 112 | urlVal->schemeSpecificPart() << endl; |
111 | } | 113 | } |
112 | 114 | ||
113 | if (v.has(EntityN)) { | 115 | if (v.has(EntityN)) { |
114 | cerr << "N Parameter found" << endl; | 116 | cerr << "N Parameter found" << endl; |
115 | 117 | ||
116 | NValue * n = | 118 | NValue * n = |
117 | (NValue *)(v.contentLine(EntityN)->value()); | 119 | (NValue *)(v.contentLine(EntityN)->value()); |
118 | 120 | ||
119 | cerr << "Family name == " << n->family()<< endl; | 121 | cerr << "Family name == " << n->family()<< endl; |
120 | cerr << "Given name == " << n->given()<< endl; | 122 | cerr << "Given name == " << n->given()<< endl; |
121 | cerr << "Middle name == " << n->middle()<< endl; | 123 | cerr << "Middle name == " << n->middle()<< endl; |
122 | cerr << "Prefix == " << n->prefix()<< endl; | 124 | cerr << "Prefix == " << n->prefix()<< endl; |
123 | cerr << "Suffix == " << n->suffix()<< endl; | 125 | cerr << "Suffix == " << n->suffix()<< endl; |
124 | } | 126 | } |
125 | 127 | ||
126 | cerr << "***************** END VCARD ******************" << endl; | 128 | cerr << "***************** END VCARD ******************" << endl; |
127 | } | 129 | } |
128 | } | 130 | } |
129 | 131 | ||