kabc Library API Documentation

FloatValue.cpp

00001 /*
00002         libvcard - vCard parsing library for vCard version 3.0
00003 
00004         Copyright (C) 1998 Rik Hemsley rik@kde.org
00005         
00006   Permission is hereby granted, free of charge, to any person obtaining a copy
00007   of this software and associated documentation files (the "Software"), to
00008   deal in the Software without restriction, including without limitation the
00009   rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00010   sell copies of the Software, and to permit persons to whom the Software is
00011   furnished to do so, subject to the following conditions:
00012 
00013   The above copyright notice and this permission notice shall be included in
00014   all copies or substantial portions of the Software.
00015 
00016   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019   AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00020   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00021   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 */
00023 
00024 #include <VCardFloatValue.h>
00025 
00026 #include <VCardValue.h>
00027 
00028 using namespace VCARD;
00029 
00030 FloatValue::FloatValue()
00031         :       Value()
00032 {
00033 }
00034 
00035 FloatValue::FloatValue(float f)
00036         :       Value   (),
00037                 value_  (f)
00038 {
00039         parsed_ = true;
00040 }
00041 
00042 FloatValue::FloatValue(const FloatValue & x)
00043         :       Value(x)
00044 {
00045         value_ = x.value_;
00046 }
00047 
00048 FloatValue::FloatValue(const QCString & s)
00049         :       Value(s)
00050 {
00051 }
00052 
00053         FloatValue &
00054 FloatValue::operator = (FloatValue & x)
00055 {
00056         if (*this == x) return *this;
00057         
00058         x.parse();
00059         value_ = x.value_;
00060 
00061         Value::operator = (x);
00062         return *this;
00063 }
00064 
00065         FloatValue &
00066 FloatValue::operator = (const QCString & s)
00067 {
00068         Value::operator = (s);
00069         return *this;
00070 }
00071 
00072         bool
00073 FloatValue::operator == (FloatValue & x)
00074 {
00075         x.parse();
00076         return (value_ == x.value_);
00077 }
00078 
00079 FloatValue::~FloatValue()
00080 {
00081 }
00082 
00083         void
00084 FloatValue::_parse()
00085 {
00086         bool negative(false);
00087         
00088         if (strRep_[0] == '-' || strRep_[1] == '+') {
00089                 
00090                 if (strRep_[0] == '-')
00091                         negative = true;
00092                 
00093                 strRep_.remove(0, 1);
00094         }
00095         
00096         value_ = strRep_.toFloat();
00097         if (negative)
00098                 value_ = -value_;
00099 }
00100 
00101         void
00102 FloatValue::_assemble()
00103 {
00104         strRep_ = QCString().setNum(value_);
00105 }
00106 
00107         float
00108 FloatValue::value()
00109 {
00110         parse();
00111         return value_;
00112 }
00113 
00114         void
00115 FloatValue::setValue(float f)
00116 {
00117         parsed_ = true;
00118         value_ = f;
00119 }
00120 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:29:20 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001