summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/AdrValue.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/AdrValue.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/AdrValue.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/kabc/vcard/AdrValue.cpp b/kabc/vcard/AdrValue.cpp
new file mode 100644
index 0000000..7ecef33
--- a/dev/null
+++ b/kabc/vcard/AdrValue.cpp
@@ -0,0 +1,140 @@
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 <VCardRToken.h>
25#include <VCardAdrValue.h>
26#include <VCardValue.h>
27#include <VCardDefines.h>
28
29using namespace VCARD;
30
31AdrValue::AdrValue()
32 :Value()
33{
34}
35
36AdrValue::AdrValue(const AdrValue & x)
37 :Value(x),
38 poBox_ (x.poBox_),
39 extAddress_(x.extAddress_),
40 street_ (x.street_),
41 locality_(x.locality_),
42 region_ (x.region_),
43 postCode_(x.postCode_),
44 countryName_(x.countryName_)
45{
46}
47
48AdrValue::AdrValue(const QCString & s)
49 :Value(s)
50{
51}
52
53 AdrValue &
54AdrValue::operator = (AdrValue & x)
55{
56 if (*this == x) return *this;
57
58 poBox_ = x.poBox_;
59 extAddress_= x.extAddress_;
60 street_ = x.street_;
61 locality_= x.locality_;
62 region_ = x.region_;
63 postCode_= x.postCode_;
64 countryName_= x.countryName_;
65
66 Value::operator = (x);
67 return *this;
68}
69
70 AdrValue &
71AdrValue::operator = (const QCString & s)
72{
73 Value::operator = (s);
74 return *this;
75}
76
77 bool
78AdrValue::operator == (AdrValue & x)
79{
80 parse();
81 x.parse();
82
83 return (
84 poBox_ == x.poBox_ &&
85 extAddress_ == x.extAddress_&&
86 street_ == x.street_ &&
87 locality_ == x.locality_ &&
88 region_ == x.region_ &&
89 postCode_ == x.postCode_ &&
90 countryName_== x.countryName_);
91}
92
93AdrValue::~AdrValue()
94{
95}
96
97 AdrValue *
98AdrValue::clone()
99{
100 return new AdrValue( *this );
101}
102
103 void
104AdrValue::_parse()
105{
106 vDebug("AdrValue::_parse()");
107
108 QStrList l;
109 RTokenise(strRep_, ";", l);
110
111 for (unsigned int i = 0; i < l.count(); i++) {
112
113 switch (i) {
114
115 case 0: poBox_ = l.at(0);break;
116 case 1: extAddress_ = l.at(1);break;
117 case 2: street_ = l.at(2);break;
118 case 3: locality_ = l.at(3);break;
119 case 4: region_ = l.at(4);break;
120 case 5: postCode_ = l.at(5);break;
121 case 6: countryName_ = l.at(6);break;
122 default: break;
123 }
124 }
125}
126
127 void
128AdrValue::_assemble()
129{
130 vDebug("AdrValue::_assemble");
131
132 strRep_ = poBox_;
133 strRep_ += ";" +extAddress_;
134 strRep_ += ";" +street_;
135 strRep_ += ";" +locality_;
136 strRep_ += ";" +region_;
137 strRep_ += ";" +postCode_;
138 strRep_ += ";" +countryName_;
139}
140