kabc Library API Documentation

NValue.cpp

00001 /*
00002     libvcard - vCard parsing library for vCard version 3.0
00003 
00004     Copyright (C) 1999 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 <qstrlist.h>
00025 
00026 #include <VCardRToken.h>
00027 #include <VCardNValue.h>
00028 #include <VCardValue.h>
00029 #include <VCardDefines.h>
00030 
00031 using namespace VCARD;
00032 
00033 NValue::NValue()
00034     :   Value()
00035 {
00036     vDebug("ctor");
00037 }
00038 
00039 NValue::NValue(const NValue & x)
00040     :   Value(x),
00041         family_ (x.family_),
00042         given_  (x.given_),
00043         middle_ (x.middle_),
00044         prefix_ (x.prefix_),
00045         suffix_ (x.suffix_)
00046 {
00047 }
00048 
00049 NValue::NValue(const QCString & s)
00050     :   Value(s)
00051 {
00052     vDebug("ctor");
00053 }
00054 
00055     NValue &
00056 NValue::operator = (NValue & x)
00057 {
00058     if (*this == x) return *this;
00059     
00060     family_ = x.family_;
00061     given_  = x.given_;
00062     middle_ = x.middle_;
00063     prefix_ = x.prefix_;
00064     suffix_ = x.suffix_;
00065 
00066     Value::operator = (x);
00067     return *this;
00068 }
00069 
00070     NValue &
00071 NValue::operator = (const QCString & s)
00072 {
00073     Value::operator = (s);
00074     return *this;
00075 }
00076 
00077     bool
00078 NValue::operator == (NValue & x)
00079 {
00080     x.parse();
00081 
00082     return (
00083         family_ == x.family_    &&
00084         given_  == x.given_ &&
00085         middle_ == x.middle_    &&
00086         prefix_ == x.prefix_    &&
00087         suffix_ == x.suffix_);
00088 }
00089 
00090 NValue::~NValue()
00091 {
00092 }
00093 
00094     NValue *
00095 NValue::clone()
00096 {
00097     return new NValue( *this );
00098 }
00099 
00100     void
00101 NValue::_parse()
00102 {
00103     QStrList l;
00104     RTokenise(strRep_, ";", l);
00105     
00106     for (unsigned int i = 0; i < l.count(); i++) {
00107 
00108         switch (i) {
00109             case 0: family_ = l.at(0);  break;
00110             case 1: given_  = l.at(1);  break;
00111             case 2: middle_ = l.at(2);  break;
00112             case 3: prefix_ = l.at(3);  break;
00113             case 4: suffix_ = l.at(4);  break;
00114             default:            break;
00115         }
00116     }
00117 }
00118 
00119     void
00120 NValue::_assemble()
00121 {
00122     strRep_ =       family_;
00123     strRep_ += ";" +    given_;
00124     strRep_ += ";" +    middle_;
00125     strRep_ += ";" +    prefix_;
00126     strRep_ += ";" +    suffix_;
00127 }
00128 
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:16:07 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001