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

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • sycoca
ksycocaentry.cpp
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  * Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License version 2 as published by the Free Software Foundation;
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public License
14  * along with this library; see the file COPYING.LIB. If not, write to
15  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301, USA.
17  **/
18 
19 #include "ksycocaentry.h"
20 #include "ksycocaentry_p.h"
21 #include <kdebug.h>
22 
23 #include <ksycoca.h>
24 
25 KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
26  : offset(iOffset), deleted(false)
27 {
28  KSycocaEntry::read( _str, path );
29 }
30 
31 KSycocaEntry::KSycocaEntry()
32  : d_ptr(0)
33 {
34 }
35 
36 KSycocaEntry::KSycocaEntry(KSycocaEntryPrivate &d)
37  : d_ptr(&d)
38 {
39 }
40 
41 KSycocaEntry::~KSycocaEntry()
42 {
43  delete d_ptr;
44 }
45 
46 void KSycocaEntry::read( QDataStream &s, QString &str )
47 {
48  quint32 bytes;
49  s >> bytes; // read size of string
50  if ( bytes > 8192 ) { // null string or too big
51  if (bytes != 0xffffffff)
52  KSycoca::flagError();
53  str.clear();
54  }
55  else if ( bytes > 0 ) { // not empty
56  int bt = bytes/2;
57  str.resize( bt );
58  QChar* ch = (QChar *) str.unicode();
59  char t[8192];
60  char *b = t;
61  s.readRawData( b, bytes );
62  while ( bt-- ) {
63  *ch++ = (ushort) (((ushort)b[0])<<8) | (uchar)b[1];
64  b += 2;
65  }
66  } else {
67  str.clear();
68  }
69 }
70 
71 void KSycocaEntry::read( QDataStream &s, QStringList &list )
72 {
73  list.clear();
74  quint32 count;
75  s >> count; // read size of list
76  if (count >= 1024)
77  {
78  KSycoca::flagError();
79  return;
80  }
81  for(quint32 i = 0; i < count; i++)
82  {
83  QString str;
84  read(s, str);
85  list.append( str );
86  if (s.atEnd())
87  {
88  KSycoca::flagError();
89  return;
90  }
91  }
92 }
93 
94 bool KSycocaEntry::isType(KSycocaType t) const
95 {
96  return d_ptr->isType(t);
97 }
98 
99 KSycocaType KSycocaEntry::sycocaType() const
100 {
101  return d_ptr->sycocaType();
102 }
103 
104 QString KSycocaEntry::entryPath() const
105 {
106  Q_D(const KSycocaEntry);
107  return d->path;
108 }
109 
110 QString KSycocaEntry::storageId() const
111 {
112  Q_D(const KSycocaEntry);
113  return d->storageId();
114 }
115 
116 bool KSycocaEntry::isDeleted() const
117 {
118  Q_D(const KSycocaEntry);
119  return d->deleted;
120 }
121 
122 void KSycocaEntry::setDeleted( bool deleted )
123 {
124  Q_D(KSycocaEntry);
125  d->deleted = deleted;
126 }
127 
128 bool KSycocaEntry::isSeparator() const
129 {
130  return d_ptr == 0 || isType(KST_KServiceSeparator);
131 }
132 
133 int KSycocaEntry::offset() const
134 {
135  Q_D(const KSycocaEntry);
136  return d->offset;
137 }
138 
139 void KSycocaEntryPrivate::save(QDataStream &s)
140 {
141  offset = s.device()->pos(); // store position in member variable
142  s << qint32(sycocaType()) << path;
143 }
144 
145 void KSycocaEntry::save(QDataStream &s)
146 {
147  Q_D(KSycocaEntry);
148  d->save(s);
149 }
150 
151 bool KSycocaEntry::isValid() const
152 {
153  Q_D(const KSycocaEntry);
154  return d && d->isValid();
155 }
156 
157 QString KSycocaEntry::name() const
158 {
159  Q_D(const KSycocaEntry);
160  return d->name();
161 }
162 
163 QStringList KSycocaEntry::propertyNames() const
164 {
165  Q_D(const KSycocaEntry);
166  return d->propertyNames();
167 }
168 
169 QVariant KSycocaEntry::property(const QString &name) const
170 {
171  Q_D(const KSycocaEntry);
172  return d->property(name);
173 }
QList::clear
void clear()
KSycocaEntry::isType
bool isType(KSycocaType t) const
internal
Definition: ksycocaentry.cpp:94
kdebug.h
KSycocaEntry::isSeparator
bool isSeparator() const
Definition: ksycocaentry.cpp:128
QDataStream
KSycocaEntry::~KSycocaEntry
virtual ~KSycocaEntry()
Definition: ksycocaentry.cpp:41
QChar
KSycocaEntry::sycocaType
KSycocaType sycocaType() const
internal
Definition: ksycocaentry.cpp:99
KSycocaEntry::d_ptr
KSycocaEntryPrivate * d_ptr
Definition: ksycocaentry.h:149
quint32
KSycocaEntryPrivate::path
QString path
Definition: ksycocaentry_p.h:77
QDataStream::readRawData
int readRawData(char *s, int len)
QIODevice::pos
virtual qint64 pos() const
KSycocaEntry::propertyNames
QStringList propertyNames() const
Returns the list of all properties that this service can have.
Definition: ksycocaentry.cpp:163
KSycocaEntry::isValid
bool isValid() const
Definition: ksycocaentry.cpp:151
QString::clear
void clear()
KSycocaEntryPrivate::save
virtual void save(QDataStream &s)
Definition: ksycocaentry.cpp:139
KSycocaEntry::save
void save(QDataStream &s)
Definition: ksycocaentry.cpp:145
QString::resize
void resize(int size)
KSycocaEntry::KSycocaType
KSycocaType
Definition: ksycocatype.h:31
QList::append
void append(const T &value)
KSycocaEntryPrivate::isType
virtual bool isType(KSycocaType t) const
Definition: ksycocaentry_p.h:45
KSycocaEntry::entryPath
QString entryPath() const
Definition: ksycocaentry.cpp:104
KSycocaEntryPrivate::KSycocaEntryPrivate
KSycocaEntryPrivate(const QString &path_)
Definition: ksycocaentry_p.h:32
KSycocaEntry
Base class for all Sycoca entries.
Definition: ksycocaentry.h:41
KSycocaEntryPrivate::offset
int offset
Definition: ksycocaentry_p.h:75
ksycocaentry_p.h
QString
KSycoca::flagError
static void flagError()
A read error occurs.
Definition: ksycoca.cpp:559
KSycocaEntryPrivate::sycocaType
virtual KSycocaType sycocaType() const
Definition: ksycocaentry_p.h:50
QDataStream::atEnd
bool atEnd() const
KSycocaEntry::setDeleted
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition: ksycocaentry.cpp:122
QStringList
ksycocaentry.h
KSycocaEntry::KSycocaEntry
KSycocaEntry()
Definition: ksycocaentry.cpp:31
KSycocaEntry::read
static void read(QDataStream &s, QString &str)
Default constructor.
Definition: ksycocaentry.cpp:46
KSycocaEntry::storageId
QString storageId() const
Definition: ksycocaentry.cpp:110
KST_KServiceSeparator
Definition: ksycocatype.h:34
ksycoca.h
QString::unicode
const QChar * unicode() const
KSycocaEntry::offset
int offset() const
Definition: ksycocaentry.cpp:133
KSycocaEntry::isDeleted
bool isDeleted() const
Definition: ksycocaentry.cpp:116
KSycocaEntryPrivate
Definition: ksycocaentry_p.h:29
qint32
QDataStream::device
QIODevice * device() const
KSycocaEntry::property
QVariant property(const QString &name) const
Returns the requested property.
Definition: ksycocaentry.cpp:169
KSycocaEntry::name
QString name() const
Definition: ksycocaentry.cpp:157
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal