summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/VCardEntity.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/VCardEntity.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/VCardEntity.cpp119
1 files changed, 119 insertions, 0 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp
new file mode 100644
index 0000000..0c21e2f
--- a/dev/null
+++ b/kabc/vcard/VCardEntity.cpp
@@ -0,0 +1,119 @@
1/*
2 libvcard - vCard parsing library for vCard version 3.0
3
4 Copyright (C) 1998 Rik Hemsley rik@kde.org
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to
8 deal in the Software without restriction, including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 sell copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*/
23
24#include <qregexp.h>
25
26#include <VCardDefines.h>
27#include <VCardVCardEntity.h>
28
29using namespace VCARD;
30
31VCardEntity::VCardEntity()
32 :Entity()
33{
34}
35
36VCardEntity::VCardEntity(const VCardEntity & x)
37 :Entity(x)
38{
39}
40
41VCardEntity::VCardEntity(const QCString & s)
42 :Entity(s)
43{
44}
45
46 VCardEntity &
47VCardEntity::operator = (VCardEntity & x)
48{
49 if (*this == x) return *this;
50
51 Entity::operator = (x);
52 return *this;
53}
54
55 VCardEntity &
56VCardEntity::operator = (const QCString & s)
57{
58 Entity::operator = (s);
59 return *this;
60}
61
62 bool
63VCardEntity::operator == (VCardEntity & x)
64{
65 x.parse();
66 return false;
67}
68
69VCardEntity::~VCardEntity()
70{
71}
72
73 void
74VCardEntity::_parse()
75{
76 vDebug("parse");
77 QCString s(strRep_);
78
79 int i = s.find(QRegExp("BEGIN:VCARD", false));
80
81 while (i != -1) {
82
83 i = s.find(QRegExp("BEGIN:VCARD", false), 11);
84
85 QCString cardStr(s.left(i));
86
87 VCard * v = new VCard(cardStr);
88
89 cardList_.append(v);
90
91 v->parse();
92
93 s.remove(0, i);
94 }
95}
96
97 void
98VCardEntity::_assemble()
99{
100 VCardListIterator it(cardList_);
101
102 for (; it.current(); ++it)
103 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
104}
105
106 VCardList &
107VCardEntity::cardList()
108{
109 parse();
110 return cardList_;
111}
112
113 void
114VCardEntity::setCardList(const VCardList & l)
115{
116 parse();
117 cardList_ = l;
118}
119