28#include <QtCore/QString>
29#include <QtCore/QHash>
30#include <QtCore/QList>
36class KIO::UDSEntryPrivate :
public QSharedData
41 inline Field() : m_long(0) { }
45 typedef QHash<uint, Field> FieldHash;
48 static void save(QDataStream &,
const UDSEntry &);
49 static void load(QDataStream &, UDSEntry &);
75 return d->fields.value(field).m_str;
80 UDSEntryPrivate::FieldHash::ConstIterator it = d->fields.find(field);
81 return it != d->fields.constEnd() ? it->m_long :
defaultValue;
96 UDSEntryPrivate::Field
f;
98 d->fields.insert(field,
f);
103 UDSEntryPrivate::Field
f;
105 d->fields.insert(field,
f);
110 return d->fields.keys();
115 return d->fields.count();
120 return d->fields.contains(field);
125 return d->fields.remove(field) > 0;
135 UDSEntryPrivate::save(s, a);
141 UDSEntryPrivate::load(s, a);
145void UDSEntryPrivate::save(QDataStream &s,
const UDSEntry &a)
147 const FieldHash &e = a.d->fields;
150 FieldHash::ConstIterator it = e.begin();
151 const FieldHash::ConstIterator
end = e.end();
152 for( ; it !=
end; ++it)
154 const quint32 uds = it.key();
161 Q_ASSERT_X(
false,
"KIO::UDSEntry",
"Found a field with an invalid type");
165void UDSEntryPrivate::load(QDataStream &s,
UDSEntry &a)
167 FieldHash &e = a.d->fields;
176 static QVector<QString> cachedStrings;
177 if (cachedStrings.size() < size) {
178 cachedStrings.resize(size);
181 for(quint32 i = 0; i < size; ++i)
192 if (buffer != cachedStrings.at(i)) {
193 cachedStrings[i] = buffer;
197 f.m_str = cachedStrings.at(i);
204 Q_ASSERT_X(
false,
"KIO::UDSEntry",
"Found a field with an invalid type");
Universal Directory Service.
QString stringValue(uint field) const
long long numberValue(uint field, long long defaultValue=0) const
friend class UDSEntryPrivate
@ UDS_LINK_DEST
Name of the file where the link points to Allows to check for a symlink (don't use S_ISLNK !...
@ UDS_FILE_TYPE
File type, part of the mode returned by stat (for a link, this returns the file type of the pointed i...
@ UDS_STRING
Indicates that the field is a QString.
@ UDS_NUMBER
Indicates that the field is a number (long long).
bool contains(uint field) const
check existence of a field
void insert(uint field, const QString &value)
insert field with numeric value
void clear()
remove all fields
bool remove(uint field)
remove a field with a certain numeric id
UDSEntry & operator=(const UDSEntry &other)
QList< uint > listFields() const
lists all fields
int count() const
count fields
static quint32 f(DES_KEY *key, quint32 r, char *subkey)
QString defaultValue(const QString &t)
A namespace for KIO globals.
QDataStream & operator<<(QDataStream &s, const AuthInfo &a)
QDataStream & operator>>(QDataStream &s, AuthInfo &a)
Q_DECLARE_TYPEINFO(KIO::UDSEntryPrivate::Field, Q_MOVABLE_TYPE)