summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/SourceParam.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/SourceParam.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/SourceParam.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/kabc/vcard/SourceParam.cpp b/kabc/vcard/SourceParam.cpp
new file mode 100644
index 0000000..cd51cbd
--- a/dev/null
+++ b/kabc/vcard/SourceParam.cpp
@@ -0,0 +1,112 @@
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 <VCardSourceParam.h>
25
26#include <VCardParam.h>
27
28using namespace VCARD;
29
30SourceParam::SourceParam()
31 :Param(),
32 type_(SourceParam::TypeUnknown)
33{
34}
35
36SourceParam::SourceParam(const SourceParam & x)
37 :Param(x),
38 type_(x.type_),
39 par_(x.par_),
40 val_(x.val_)
41{
42}
43
44SourceParam::SourceParam(const QCString & s)
45 :Param(s),
46 type_(SourceParam::TypeUnknown)
47{
48}
49
50 SourceParam &
51SourceParam::operator = (SourceParam & x)
52{
53 if (*this == x) return *this;
54 type_= x.type();
55 par_= x.par();
56 val_= x.val();
57
58 Param::operator = (x);
59 return *this;
60}
61
62 SourceParam &
63SourceParam::operator = (const QCString & s)
64{
65 Param::operator = (s);
66 return *this;
67}
68
69 bool
70SourceParam::operator == (SourceParam & x)
71{
72 x.parse();
73 return false;
74}
75
76SourceParam::~SourceParam()
77{
78}
79
80 void
81SourceParam::_parse()
82{
83 int i = strRep_.find('=');
84 if (i == -1) // Invalid
85 return;
86
87 par_ = strRep_.left(i);
88 val_ = strRep_.right(strRep_.length() - i - 1);
89
90 if (qstricmp(par_, "VALUE") == 0 && qstricmp(val_, "uri") == 0)
91 type_ = TypeValue;
92 else if (qstricmp(par_, "CONTEXT") == 0 && qstricmp(val_, "word") == 0)
93 type_ = TypeContext;
94 else if (qstrnicmp(par_, "X-", 2) == 0) {
95 type_ = TypeX;
96 }
97 else type_ = TypeUnknown;
98
99}
100
101 void
102SourceParam::_assemble()
103{
104 if (type_ == TypeValue)
105 strRep_ = "VALUE=uri";
106 else if (type_ == TypeContext)
107 strRep_ = "CONTEXT=word";
108 else if (type_ == TypeX)
109 strRep_ = par_ + "=" + val_;
110 else strRep_ = "";
111}
112