On Wednesday 8 July 2009 09:11:10 Ozan Çağlayan wrote: > Kevin Ottens wrote On 08-07-2009 03:23: > > It exactly acts like an OR operator, but the binary one so foo.bar == > > 'X|Y' means that foo.bar should have both X and Y. > > So looking at k3b's one which checks for a blank medium: > > [[StorageVolume.ignored == false AND OpticalDisc.blank == true ] AND > OpticalDisc.discType == 'CdRecordable|CdRewritable'] > > It expects both CdRecordable and CdRewritable for the discType property, > right? But a recordable cd has only the first one and a rewriteable has > the second. So it seems like a misusage of that operator?
Indeed looks like a mistake, I'd expect something like this instead: OpticalDisc.discType & 'CdRecordable|CdRewritable' > Or another example: > > $ solid-hardware details /org/freedesktop/Hal/devices/acpi_CPU0 > udi = '/org/freedesktop/Hal/devices/acpi_CPU0' > parent = '/org/freedesktop/Hal/devices/computer' (string) > vendor = '' (string) > product = 'AMD Athlon(tm) 64 X2 Dual Core Processor 4800+' (string) > Processor.number = 0 (0x0) (int) > Processor.maxSpeed = '0' (string) > Processor.canChangeFrequency = false (bool) > Processor.instructionSets = 'IntelMmx|IntelSse|IntelSse2|Amd3DNow' > (0x27) (flag) > > Say that I'm trying to filter processors having only IntelMmx > instruction set. According to your reply, using & makes sense: > > $ solid-hardware query "Processor.instructionSets & 'IntelMmx'" > udi = '/org/freedesktop/Hal/devices/acpi_CPU0' > udi = '/org/freedesktop/Hal/devices/acpi_CPU1' > > Seems working but try a stupid one: > > $ solid-hardware query "Processor.instructionSets & 'foobar'" > udi = '/org/freedesktop/Hal/devices/acpi_CPU0' > udi = '/org/freedesktop/Hal/devices/acpi_CPU1' > > It matches too! This one definitely looks like a bug, it should be rejected. Somehow doesn't seem to behave like this for me though. > And now with the '|' : > > $ solid-hardware query "Processor.instructionSets == 'IntelMmx|IntelSse'" > $ solid-hardware query "Processor.instructionSets == > 'IntelMmx|IntelSse|IntelSse2'" > $ solid-hardware query "Processor.instructionSets == > 'IntelMmx|IntelSse|IntelSse2|Amd3DNow'" > udi = '/org/freedesktop/Hal/devices/acpi_CPU0' > udi = '/org/freedesktop/Hal/devices/acpi_CPU1' > > It only matches if I check again the whole flag set. So what's the point > in here? Well, it does what you ask and match only if it's equals. If you want to check if there's at least one of those use the & operator. > It really behaves like I'm checking the instructionSets > property against a string which contains "X|Y|Z|W" having | characters > in it. No? Nope, it behaves like any flag set comparison in C++ (well, except for the bug you spotted earlier). Regards. -- Kévin 'ervin' Ottens, http://ervin.ipsquad.net "Ni le maître sans disciple, Ni le disciple sans maître, Ne font reculer l'ignorance."
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-hardware-devel mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-hardware-devel
