summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/FloatValue.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/FloatValue.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/FloatValue.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/kabc/vcard/FloatValue.cpp b/kabc/vcard/FloatValue.cpp
index 15bb664..7065081 100644
--- a/kabc/vcard/FloatValue.cpp
+++ b/kabc/vcard/FloatValue.cpp
@@ -3,118 +3,120 @@
3 3
4 Copyright (C) 1998 Rik Hemsley rik@kde.org 4 Copyright (C) 1998 Rik Hemsley rik@kde.org
5 5
6 Permission is hereby granted, free of charge, to any person obtaining a copy 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 7 of this software and associated documentation files (the "Software"), to
8 deal in the Software without restriction, including without limitation the 8 deal in the Software without restriction, including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 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 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: 11 furnished to do so, subject to the following conditions:
12 12
13 The above copyright notice and this permission notice shall be included in 13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software. 14 all copies or substantial portions of the Software.
15 15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 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, 17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 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 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 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. 21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*/ 22*/
23 23
24#include <VCardFloatValue.h> 24#include <VCardFloatValue.h>
25 25
26#include <VCardValue.h> 26#include <VCardValue.h>
27//Added by qt3to4:
28#include <Q3CString>
27 29
28using namespace VCARD; 30using namespace VCARD;
29 31
30FloatValue::FloatValue() 32FloatValue::FloatValue()
31 :Value() 33 :Value()
32{ 34{
33} 35}
34 36
35FloatValue::FloatValue(float f) 37FloatValue::FloatValue(float f)
36 : Value(), 38 : Value(),
37 value_(f) 39 value_(f)
38{ 40{
39 parsed_ = true; 41 parsed_ = true;
40} 42}
41 43
42FloatValue::FloatValue(const FloatValue & x) 44FloatValue::FloatValue(const FloatValue & x)
43 :Value(x) 45 :Value(x)
44{ 46{
45 value_ = x.value_; 47 value_ = x.value_;
46} 48}
47 49
48FloatValue::FloatValue(const QCString & s) 50FloatValue::FloatValue(const Q3CString & s)
49 :Value(s) 51 :Value(s)
50{ 52{
51} 53}
52 54
53 FloatValue & 55 FloatValue &
54FloatValue::operator = (FloatValue & x) 56FloatValue::operator = (FloatValue & x)
55{ 57{
56 if (*this == x) return *this; 58 if (*this == x) return *this;
57 59
58 x.parse(); 60 x.parse();
59 value_ = x.value_; 61 value_ = x.value_;
60 62
61 Value::operator = (x); 63 Value::operator = (x);
62 return *this; 64 return *this;
63} 65}
64 66
65 FloatValue & 67 FloatValue &
66FloatValue::operator = (const QCString & s) 68FloatValue::operator = (const Q3CString & s)
67{ 69{
68 Value::operator = (s); 70 Value::operator = (s);
69 return *this; 71 return *this;
70} 72}
71 73
72 bool 74 bool
73FloatValue::operator == (FloatValue & x) 75FloatValue::operator == (FloatValue & x)
74{ 76{
75 x.parse(); 77 x.parse();
76 return (value_ == x.value_); 78 return (value_ == x.value_);
77} 79}
78 80
79FloatValue::~FloatValue() 81FloatValue::~FloatValue()
80{ 82{
81} 83}
82 84
83 void 85 void
84FloatValue::_parse() 86FloatValue::_parse()
85{ 87{
86 bool negative(false); 88 bool negative(false);
87 89
88 if (strRep_[0] == '-' || strRep_[1] == '+') { 90 if (strRep_[0] == '-' || strRep_[1] == '+') {
89 91
90 if (strRep_[0] == '-') 92 if (strRep_[0] == '-')
91 negative = true; 93 negative = true;
92 94
93 strRep_.remove(0, 1); 95 strRep_.remove(0, 1);
94 } 96 }
95 97
96 value_ = strRep_.toFloat(); 98 value_ = strRep_.toFloat();
97 if (negative) 99 if (negative)
98 value_ = -value_; 100 value_ = -value_;
99} 101}
100 102
101 void 103 void
102FloatValue::_assemble() 104FloatValue::_assemble()
103{ 105{
104 strRep_ = QCString().setNum(value_); 106 strRep_ = Q3CString().setNum(value_);
105} 107}
106 108
107 float 109 float
108FloatValue::value() 110FloatValue::value()
109{ 111{
110 parse(); 112 parse();
111 return value_; 113 return value_;
112} 114}
113 115
114 void 116 void
115FloatValue::setValue(float f) 117FloatValue::setValue(float f)
116{ 118{
117 parsed_ = true; 119 parsed_ = true;
118 value_ = f; 120 value_ = f;
119} 121}
120 122