-rw-r--r-- | kabc/vcard/AgentParam.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/kabc/vcard/AgentParam.cpp b/kabc/vcard/AgentParam.cpp new file mode 100644 index 0000000..5625e00 --- a/dev/null +++ b/kabc/vcard/AgentParam.cpp | |||
@@ -0,0 +1,103 @@ | |||
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 <VCardAgentParam.h> | ||
25 | |||
26 | #include <VCardParam.h> | ||
27 | |||
28 | using namespace VCARD; | ||
29 | |||
30 | AgentParam::AgentParam() | ||
31 | :Param() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | AgentParam::AgentParam(const AgentParam & x) | ||
36 | :Param(x), | ||
37 | refer_(x.refer_), | ||
38 | uri_(x.uri_) | ||
39 | { | ||
40 | } | ||
41 | |||
42 | AgentParam::AgentParam(const QCString & s) | ||
43 | :Param(s) | ||
44 | { | ||
45 | } | ||
46 | |||
47 | AgentParam & | ||
48 | AgentParam::operator = (AgentParam & x) | ||
49 | { | ||
50 | if (*this == x) return *this; | ||
51 | |||
52 | refer_= x.refer_; | ||
53 | uri_= x.uri_; | ||
54 | |||
55 | Param::operator = (x); | ||
56 | return *this; | ||
57 | } | ||
58 | |||
59 | AgentParam & | ||
60 | AgentParam::operator = (const QCString & s) | ||
61 | { | ||
62 | Param::operator = (s); | ||
63 | return *this; | ||
64 | } | ||
65 | |||
66 | bool | ||
67 | AgentParam::operator == (AgentParam & x) | ||
68 | { | ||
69 | parse(); | ||
70 | |||
71 | if (refer_) | ||
72 | return (x.refer() && uri_ == x.uri_); | ||
73 | |||
74 | return !x.refer(); | ||
75 | } | ||
76 | |||
77 | AgentParam::~AgentParam() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | void | ||
82 | AgentParam::_parse() | ||
83 | { | ||
84 | if (strRep_.isEmpty()) { | ||
85 | refer_ = false; | ||
86 | return; | ||
87 | } | ||
88 | |||
89 | refer_= true; | ||
90 | uri_= strRep_; | ||
91 | } | ||
92 | |||
93 | void | ||
94 | AgentParam::_assemble() | ||
95 | { | ||
96 | if (!refer_) { | ||
97 | strRep_.truncate(0); | ||
98 | return; | ||
99 | } | ||
100 | |||
101 | strRep_ = uri_.asString(); | ||
102 | return; | ||
103 | } | ||