• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

ksycocaentry.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
00003  *
00004  *  This library is free software; you can redistribute it and/or
00005  *  modify it under the terms of the GNU Library General Public
00006  *  License version 2 as published by the Free Software Foundation;
00007  *
00008  *  This library is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  *  Library General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU Library General Public License
00014  *  along with this library; see the file COPYING.LIB.  If not, write to
00015  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016  *  Boston, MA 02110-1301, USA.
00017  **/
00018 
00019 #include "ksycocaentry.h"
00020 #include "ksycocaentry_p.h"
00021 
00022 #include <ksycoca.h>
00023 
00024 KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
00025     : offset(iOffset), deleted(false)
00026 {
00027     KSycocaEntry::read( _str, path );
00028 }
00029 
00030 KSycocaEntry::KSycocaEntry()
00031     : d_ptr(0)
00032 {
00033 }
00034 
00035 KSycocaEntry::KSycocaEntry(KSycocaEntryPrivate &d)
00036     : d_ptr(&d)
00037 {
00038 }
00039 
00040 KSycocaEntry::~KSycocaEntry()
00041 {
00042     delete d_ptr;
00043 }
00044 
00045 void KSycocaEntry::read( QDataStream &s, QString &str )
00046 {
00047   quint32 bytes;
00048   s >> bytes;                          // read size of string
00049   if ( bytes > 8192 ) {                // null string or too big
00050       if (bytes != 0xffffffff)
00051          KSycoca::flagError();
00052       str.clear();
00053   }
00054   else if ( bytes > 0 ) {              // not empty
00055       int bt = bytes/2;
00056       str.resize( bt );
00057       QChar* ch = (QChar *) str.unicode();
00058       char t[8192];
00059       char *b = t;
00060       s.readRawData( b, bytes );
00061       while ( bt-- ) {
00062           *ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1];
00063           b += 2;
00064       }
00065   } else {
00066       str = "";
00067   }
00068 }
00069 
00070 void KSycocaEntry::read( QDataStream &s, QStringList &list )
00071 {
00072   list.clear();
00073   quint32 count;
00074   s >> count;                          // read size of list
00075   if (count >= 1024)
00076   {
00077      KSycoca::flagError();
00078      return;
00079   }
00080   for(quint32 i = 0; i < count; i++)
00081   {
00082      QString str;
00083      read(s, str);
00084      list.append( str );
00085      if (s.atEnd())
00086      {
00087         KSycoca::flagError();
00088         return;
00089      }
00090   }
00091 }
00092 
00093 bool KSycocaEntry::isType(KSycocaType t) const
00094 {
00095     return d_ptr->isType(t);
00096 }
00097 
00098 KSycocaType KSycocaEntry::sycocaType() const
00099 {
00100     return d_ptr->sycocaType();
00101 }
00102 
00103 QString KSycocaEntry::entryPath() const
00104 {
00105     Q_D(const KSycocaEntry);
00106     return d->path;
00107 }
00108 
00109 bool KSycocaEntry::isDeleted() const
00110 {
00111     Q_D(const KSycocaEntry);
00112     return d->deleted;
00113 }
00114 
00115 void KSycocaEntry::setDeleted( bool deleted )
00116 {
00117     Q_D(KSycocaEntry);
00118     d->deleted = deleted;
00119 }
00120 
00121 bool KSycocaEntry::isSeparator() const
00122 {
00123     return d_ptr == 0 || isType(KST_KServiceSeparator);
00124 }
00125 
00126 int KSycocaEntry::offset() const
00127 {
00128     Q_D(const KSycocaEntry);
00129     return d->offset;
00130 }
00131 
00132 void KSycocaEntryPrivate::save(QDataStream &s)
00133 {
00134     offset = s.device()->pos(); // store position in member variable
00135     s << qint32(sycocaType()) << path;
00136 }
00137 
00138 void KSycocaEntry::save(QDataStream &s)
00139 {
00140     Q_D(KSycocaEntry);
00141     d->save(s);
00142 }
00143 
00144 bool KSycocaEntry::isValid() const
00145 {
00146     Q_D(const KSycocaEntry);
00147     return d && d->isValid();
00148 }
00149 
00150 QString KSycocaEntry::name() const
00151 {
00152     Q_D(const KSycocaEntry);
00153     return d->name();
00154 }
00155 
00156 QStringList KSycocaEntry::propertyNames() const
00157 {
00158     Q_D(const KSycocaEntry);
00159     return d->propertyNames();
00160 }
00161 
00162 QVariant KSycocaEntry::property(const QString &name) const
00163 {
00164     Q_D(const KSycocaEntry);
00165     return d->property(name);
00166 }
00167 
00168 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal