[Property tree review] Comments & layout information

I have an interesting idea how to preserve comments & layout information. The relevant structures should be included in the tree under a special meta key: Config file: key1 data1 ;comment before key2 key2 data2 ;comment after key2, on the same line The resulting tree might look like that: key1 data1 key2 data2 _metadata_ { key1 { row 1 column 1 } comment "comment before key2" { row 2 column 1 } key2 { row 3 column 1 } comment "comment after key2, on the same line" { row 3 column 15 } } This way it is easily accessible using ptree interface, it is readable, editable, and it is possible to manipulate it programatically. And above all, it does not require any extra support from ptree, only from the parsers. With some effort it also allows 100% reproduction of original layout. --Marcin

"Marcin Kalicinski" wrote:
I have an interesting idea how to preserve comments & layout information. The relevant structures should be included in the tree under a special meta key:
Config file:
key1 data1 ;comment before key2 key2 data2 ;comment after key2, on the same line
The resulting tree might look like that:
key1 data1 key2 data2 _metadata_ { key1 { row 1 column 1 } comment "comment before key2" { row 2 column 1 } .. etc }
It may be needed to store also: * location of data * anything in between key and data (=, spaces) * information about any transformations made by the parser (e.g. transparent handling of \ at the end of lines, escape sequences if they are used, presence or lack of parenthesis, their kind, numeric formatting, ...) If one deletes a data item will the corresponding metadata dissappear automatically? The metadata my use different allocator than the 'normal' data. /Pavel

It may be needed to store also: * location of data * anything in between key and data (=, spaces) * information about any transformations made by the parser (e.g. transparent handling of \ at the end of lines, escape sequences if they are used, presence or lack of parenthesis, their kind, numeric formatting, ...)
Yes, if we want to restore exact layout this will be required. But I think comments and key locations will be actually enough for majority of uses.
If one deletes a data item will the corresponding metadata dissappear automatically?
No. No support on ptree-level. Only parser knows about the metadata, for ptree it is just another branch in the tree. Btw. comments information will be included in the tree only if user explicitly requests that. It will be a responsibility of the user to update the data as he modifies the tree. Deleting a key will not usually require anything, because "orphaned" keys in metadata will be just ignored. Anyway, in many cases heavy modifications of the tree will render the layout information useless. ptree is not a text editing software.
The metadata my use different allocator than the 'normal' data.
This will require very heavy support from ptree (at the moment you cannot put nodes with different allocators in the same hierarchy). Why would anybody need it? Best regards, Marcin
participants (2)
-
Marcin Kalicinski
-
Pavel Vozenilek