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