remove UDSEntry from the public KIO API?

nf2 nf2 at scheinwelt.at
Sat Jul 21 17:14:24 BST 2007


Thiago Macieira wrote:
> nf2 wrote:
>   
>> class KIO_EXPORT UDSEntry
>> {
>> public:
>>   virtual QString stringValue( uint field );
>>
>>   virtual long long numberValue( uint field, long long defaultValue = 0
>> );
>>
>>   // Convenience methods.
>>   // Let's not add one method per field, only methods that have some
>> more logic
>>   // than just calling stringValue(field) or numberValue(field).
>>
>>   /// @return true if this entry is a directory (or a link to a
>> directory) virtual bool isDir();
>>   /// @return true if this entry is a link
>>   virtual bool isLink();
>>  
>>   virtual void set(UDSFieldTypes t, QString string);
>>  
>>   virtual void set(UDSFieldTypes t, long long l);
>>  
>> private:
>>    UDSEntryPrivate* const d;
>>
>> };
>>     
>
> That's a good idea, but no virtuals please. There's no need to do that. 
> The private should be QSharedDataPointer<UDSEntryPrivate> d;
>
> If the new class mimics QHash, most code won't notice the changes. 
> (insert, erase, remove, operator[]). I don't know if there's code using 
> iterators over UDSEntry.
>
> And the UDS types should be an enum inside UDSEntry, probably 
> called "KnownTypes" or "KnownFields".
>   
Ok, i'll try to create a patch. Should i move the code to udsentry.h / 
udsentry.cpp?

Regarding the operator[] i'm not sure - i would prefer a method which 
returns an array of ints (a QList<uint> getListOfFieldIds())
because there might be QList<QString> getListOfFieldNames() in the future...

I reckon i also need those (for serializing UDSEntries over the KIO 
slave protocol):

KIO_EXPORT QDataStream & operator<< ( QDataStream & s, const UDSEntry & a );
KIO_EXPORT QDataStream & operator>> ( QDataStream & s, UDSEntry & a );

Norbert







More information about the kde-core-devel mailing list