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