
Andre Merzky wrote:
Quoting [Mathijs den Burger] (Nov 04 2009):
Hi all, ... 2. Removing SAGA attributes is permanent (AFAIK when talking to Ceriel), while a deleted dict item can be re-added latter
Not sure I undestand. the following should be valid:
if ( ! advert.attribute_exists ("foo") ) { advert.set_attribute ("foo", "bar"); }
assert (advert.attribute_exists ("foo"), true);
advert.remove_attribute ("foo");
assert (advert.attribute_exists ("foo"), false);
advert.set_attribute ("foo", "bar");
assert (advert.attribute_exists ("foo"), true);
Actually, I have an issue with this: I don't think this is valid. Here is why, and it all depends on what the Saga specs mean by "exists". The notes at set_attribute say, a.o.: "the attribute is created, if it does not exist" and also "only some SAGA objects allow to create new attributes - others allow only access to predefined attributes. If a non-existing attribute is queried on such objects, a 'DoesNotExist' exception is raised". I take this to mean that ALL attributes mentioned in the SAGA specs DO exist, even if they don't have a value. Now, remove_attribute has as PostCond: "the attribute is not available anymore." I assume this means: "the attribute does not exist anymore", what else would it mean? So, attribute_exists() returns false on a removed attribute, but then a call to set_attribute() gives a "DoesNotExist". From Mathijs, I understand that the C++ implementation has a different take on what "exists" means. I may even like that interpretation better, but I don't think it is supported by the current Saga specs. Cheers, Ceriel