Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #777 (closed enhancement: fixed)

Opened 1 year ago

Last modified 10 months ago

tango.io.stream.MapStream, allow comments

Reported by: mandel Assigned to: kris
Priority: minor Milestone: 1.0
Component: IO Version: 0.99.3 Triller
Keywords: Cc:

Description

MapOutput.append (T[] name, T[] value, char[] comment = "");
MapOutput append (T[][T[]] properties, char[] comment = "");

To allow optional comments would make the settings file human readable in case the name isn't meaningful enough or just some number.

A comment for a bulk of settings passed as AA would also make sense.

The comment should appear above or behind the setting line, depending on it's size.

Change History

01/31/08 06:02:59 changed by larsivi

Patch?

01/31/08 06:03:13 changed by larsivi

  • milestone set to 1.0.

01/31/08 07:28:14 changed by mandel

Without testing, I would say the straightforward (trivial) solution is this:

        /***********************************************************************

                Write name & value to the provided stream

        ***********************************************************************/

        final MapOutput append (T[] name, T[] value, char[] comment = "")
        {
		if(comment.length)
                        output ("#") (comment) (NL) (name) (equals) (value) (NL);
		else
			output (name) (equals) (value) (NL);
                return this;
        }

        /***********************************************************************

                Write AA properties to the provided stream

        ***********************************************************************/

        final MapOutput append (T[][T[]] properties, char[] comment = "")
        {
		if(comment.length)
			output ("#") (comment) (NL);
		
                foreach (key, value; properties)
                         append (key, value);
                return this;
        }

01/31/08 17:16:42 changed by kris

  • status changed from new to assigned.

I'd rather this was done via some application specific wrapper. Otherwise, people will doubtless complain that the formatting is all wrong, or they want tabs instead of spaces for the alignment, or whatever :)

Still, let's see what can be done

01/31/08 20:40:40 changed by kris

I think adding a discrete comment(char[] text) should be sufficient, especially if it can be chained with other calls e.g.

map.comment("some comment").append(properties);

02/01/08 00:24:48 changed by kris

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3152]) added comment() and newline() methods to MapOutput?. Closes #777