TWriter doesn't stream empty value
Original Reporter info from Mantis: havezet
-
Reporter name: Hert Vanz
Original Reporter info from Mantis: havezet
- Reporter name: Hert Vanz
Description:
By default, the TWriter class is not streaming properties which match the default value.
For instance; I create an object with a single string property and load it from a previously saves stream that contains a value in the string property. This works fine and my object now contains that value. Then subsequently, for this same object, I now load from another stream but this time the stream has an object with an empty string value. This string value was not written out to the stream because the TWriter thinks that an empty string value shouldn't have to be written. So after this second load, my object still contains the value of the first load, simply because the TReader didn't find (hence load) this property in the stream.
I know that this is by design, but would like to start a discussion to have this behavior changed. Delphi7 for instance writes empty strings to the output streams which is to be expected as an empty string is also a value. This doen't only apply to strings but any type... a 0 integer is also a value; a null variant is also a value.
In short I'd like to either have the default checking removed in TWriter.WriteProperty or have a setting for a TWriter where I can tell it to not check default values.
Mantis conversion info:
- Mantis ID: 20166
- OS: any
- OS Build: any
- Platform: any
- Version: 2.5.1
- Monitored by: » havezet (Hert Vanz), » Vincent (Vincent Snijders)