kabc Library API Documentation

VCardEntity.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 <qregexp.h>
00025 
00026 #include <VCardDefines.h>
00027 #include <VCardVCardEntity.h>
00028 
00029 using namespace VCARD;
00030 
00031 VCardEntity::VCardEntity()
00032     :   Entity()
00033 {
00034 }
00035 
00036 VCardEntity::VCardEntity(const VCardEntity & x)
00037     :   Entity(x)
00038 {
00039 }
00040 
00041 VCardEntity::VCardEntity(const QCString & s)
00042     :   Entity(s)
00043 {
00044 }
00045 
00046     VCardEntity &
00047 VCardEntity::operator = (VCardEntity & x)
00048 {
00049     if (*this == x) return *this;
00050 
00051     Entity::operator = (x);
00052     return *this;
00053 }
00054 
00055     VCardEntity &
00056 VCardEntity::operator = (const QCString & s)
00057 {
00058     Entity::operator = (s);
00059     return *this;
00060 }
00061 
00062     bool
00063 VCardEntity::operator == (VCardEntity & x)
00064 {
00065     x.parse();
00066     return false;
00067 }
00068 
00069 VCardEntity::~VCardEntity()
00070 {
00071 }
00072 
00073     void
00074 VCardEntity::_parse()
00075 {
00076     vDebug("parse");
00077     QCString s(strRep_);
00078     
00079     int i = s.find(QRegExp("BEGIN:VCARD", false));
00080     
00081     while (i != -1) {
00082         
00083         i = s.find(QRegExp("BEGIN:VCARD", false), 11);
00084         
00085         QCString cardStr(s.left(i));
00086         
00087         VCard * v = new VCard(cardStr);
00088         
00089         cardList_.append(v);
00090         
00091         v->parse();
00092         
00093         s.remove(0, i);
00094     }
00095 }
00096 
00097     void
00098 VCardEntity::_assemble()
00099 {
00100     VCardListIterator it(cardList_);
00101     
00102     for (; it.current(); ++it)
00103         strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
00104 }
00105 
00106     VCardList &
00107 VCardEntity::cardList()
00108 {
00109     parse();
00110     return cardList_;
00111 }
00112 
00113     void
00114 VCardEntity::setCardList(const VCardList & l)
00115 {
00116     parse();
00117     cardList_ = l;
00118 }
00119 
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:08 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001