kabc Library API Documentation

SourceParam.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 <VCardSourceParam.h> 00025 00026 #include <VCardParam.h> 00027 00028 using namespace VCARD; 00029 00030 SourceParam::SourceParam() 00031 : Param(), 00032 type_(SourceParam::TypeUnknown) 00033 { 00034 } 00035 00036 SourceParam::SourceParam(const SourceParam & x) 00037 : Param(x), 00038 type_ (x.type_), 00039 par_ (x.par_), 00040 val_ (x.val_) 00041 { 00042 } 00043 00044 SourceParam::SourceParam(const QCString & s) 00045 : Param(s), 00046 type_(SourceParam::TypeUnknown) 00047 { 00048 } 00049 00050 SourceParam & 00051 SourceParam::operator = (SourceParam & x) 00052 { 00053 if (*this == x) return *this; 00054 type_ = x.type(); 00055 par_ = x.par(); 00056 val_ = x.val(); 00057 00058 Param::operator = (x); 00059 return *this; 00060 } 00061 00062 SourceParam & 00063 SourceParam::operator = (const QCString & s) 00064 { 00065 Param::operator = (s); 00066 return *this; 00067 } 00068 00069 bool 00070 SourceParam::operator == (SourceParam & x) 00071 { 00072 x.parse(); 00073 return false; 00074 } 00075 00076 SourceParam::~SourceParam() 00077 { 00078 } 00079 00080 void 00081 SourceParam::_parse() 00082 { 00083 int i = strRep_.find('='); 00084 if (i == -1) // Invalid 00085 return; 00086 00087 par_ = strRep_.left(i); 00088 val_ = strRep_.right(strRep_.length() - i - 1); 00089 00090 if (qstricmp(par_, "VALUE") == 0 && qstricmp(val_, "uri") == 0) 00091 type_ = TypeValue; 00092 else if (qstricmp(par_, "CONTEXT") == 0 && qstricmp(val_, "word") == 0) 00093 type_ = TypeContext; 00094 else if (qstrnicmp(par_, "X-", 2) == 0) { 00095 type_ = TypeX; 00096 } 00097 else type_ = TypeUnknown; 00098 00099 } 00100 00101 void 00102 SourceParam::_assemble() 00103 { 00104 if (type_ == TypeValue) 00105 strRep_ = "VALUE=uri"; 00106 else if (type_ == TypeContext) 00107 strRep_ = "CONTEXT=word"; 00108 else if (type_ == TypeX) 00109 strRep_ = par_ + "=" + val_; 00110 else strRep_ = ""; 00111 } 00112
KDE Logo
This file is part of the documentation for kabc Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 8 11:15:48 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003