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

KDECore

  • 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
25KSycocaEntryPrivate::KSycocaEntryPrivate(QDataStream &_str, int iOffset)
26 : offset(iOffset), deleted(false)
27{
28 KSycocaEntry::read( _str, path );
29}
30
31KSycocaEntry::KSycocaEntry()
32 : d_ptr(0)
33{
34}
35
36KSycocaEntry::KSycocaEntry(KSycocaEntryPrivate &d)
37 : d_ptr(&d)
38{
39}
40
41KSycocaEntry::~KSycocaEntry()
42{
43 delete d_ptr;
44}
45
46void 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
71void 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
94bool KSycocaEntry::isType(KSycocaType t) const
95{
96 return d_ptr->isType(t);
97}
98
99KSycocaType KSycocaEntry::sycocaType() const
100{
101 return d_ptr->sycocaType();
102}
103
104QString KSycocaEntry::entryPath() const
105{
106 Q_D(const KSycocaEntry);
107 return d->path;
108}
109
110QString KSycocaEntry::storageId() const
111{
112 Q_D(const KSycocaEntry);
113 return d->storageId();
114}
115
116bool KSycocaEntry::isDeleted() const
117{
118 Q_D(const KSycocaEntry);
119 return d->deleted;
120}
121
122void KSycocaEntry::setDeleted( bool deleted )
123{
124 Q_D(KSycocaEntry);
125 d->deleted = deleted;
126}
127
128bool KSycocaEntry::isSeparator() const
129{
130 return d_ptr == 0 || isType(KST_KServiceSeparator);
131}
132
133int KSycocaEntry::offset() const
134{
135 Q_D(const KSycocaEntry);
136 return d->offset;
137}
138
139void KSycocaEntryPrivate::save(QDataStream &s)
140{
141 offset = s.device()->pos(); // store position in member variable
142 s << qint32(sycocaType()) << path;
143}
144
145void KSycocaEntry::save(QDataStream &s)
146{
147 Q_D(KSycocaEntry);
148 d->save(s);
149}
150
151bool KSycocaEntry::isValid() const
152{
153 Q_D(const KSycocaEntry);
154 return d && d->isValid();
155}
156
157QString KSycocaEntry::name() const
158{
159 Q_D(const KSycocaEntry);
160 return d->name();
161}
162
163QStringList KSycocaEntry::propertyNames() const
164{
165 Q_D(const KSycocaEntry);
166 return d->propertyNames();
167}
168
169QVariant KSycocaEntry::property(const QString &name) const
170{
171 Q_D(const KSycocaEntry);
172 return d->property(name);
173}
KSycocaEntryPrivate
Definition: ksycocaentry_p.h:30
KSycocaEntryPrivate::path
QString path
Definition: ksycocaentry_p.h:77
KSycocaEntryPrivate::offset
int offset
Definition: ksycocaentry_p.h:75
KSycocaEntryPrivate::save
virtual void save(QDataStream &s)
Definition: ksycocaentry.cpp:139
KSycocaEntryPrivate::KSycocaEntryPrivate
KSycocaEntryPrivate(const QString &path_)
Definition: ksycocaentry_p.h:32
KSycocaEntryPrivate::sycocaType
virtual KSycocaType sycocaType() const
Definition: ksycocaentry_p.h:50
KSycocaEntryPrivate::isType
virtual bool isType(KSycocaType t) const
Definition: ksycocaentry_p.h:45
KSycocaEntry
Base class for all Sycoca entries.
Definition: ksycocaentry.h:42
KSycocaEntry::d_ptr
KSycocaEntryPrivate * d_ptr
Definition: ksycocaentry.h:149
KSycocaEntry::save
void save(QDataStream &s)
Definition: ksycocaentry.cpp:145
KSycocaEntry::offset
int offset() const
Definition: ksycocaentry.cpp:133
KSycocaEntry::storageId
QString storageId() const
Definition: ksycocaentry.cpp:110
KSycocaEntry::isValid
bool isValid() const
Definition: ksycocaentry.cpp:151
KSycocaEntry::name
QString name() const
Definition: ksycocaentry.cpp:157
KSycocaEntry::isDeleted
bool isDeleted() const
Definition: ksycocaentry.cpp:116
KSycocaEntry::isSeparator
bool isSeparator() const
Definition: ksycocaentry.cpp:128
KSycocaEntry::isType
bool isType(KSycocaType t) const
internal
Definition: ksycocaentry.cpp:94
KSycocaEntry::KSycocaType
KSycocaType
A KSycocaType is a code (out of the KSycocaType enum) assigned to each class type derived from KSycoc...
Definition: ksycocatype.h:31
KSycocaEntry::entryPath
QString entryPath() const
Definition: ksycocaentry.cpp:104
KSycocaEntry::~KSycocaEntry
virtual ~KSycocaEntry()
Definition: ksycocaentry.cpp:41
KSycocaEntry::KSycocaEntry
KSycocaEntry()
Definition: ksycocaentry.cpp:31
KSycocaEntry::setDeleted
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition: ksycocaentry.cpp:122
KSycocaEntry::sycocaType
KSycocaType sycocaType() const
internal
Definition: ksycocaentry.cpp:99
KSycocaEntry::read
static void read(QDataStream &s, QString &str)
Default constructor.
Definition: ksycocaentry.cpp:46
KSycocaEntry::property
QVariant property(const QString &name) const
Returns the requested property.
Definition: ksycocaentry.cpp:169
KSycocaEntry::propertyNames
QStringList propertyNames() const
Returns the list of all properties that this service can have.
Definition: ksycocaentry.cpp:163
KSycoca::flagError
static void flagError()
A read error occurs.
Definition: ksycoca.cpp:559
QStringList
QString
QVariant
qint32
quint32
kdebug.h
ksycoca.h
ksycocaentry.h
ksycocaentry_p.h
KST_KServiceSeparator
@ KST_KServiceSeparator
Definition: ksycocatype.h:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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