
Hi Reece,
io::sequence_decorators< char > seq( "; " ); std::cout << '"' << seq.open( std::cout ) << "\"\n" // "[ " << '"' << seq.close( std::cout ) << "\"\n" // " ]" << '"' << seq.separator( std::cout ) << "\"\n"; // "; "
where separator( std::cout ) uses the separator value specified by seq and the others use the values set on the std::cout stream.
I don't understand this phrase, could you clarify. What does it mean to "use the separator".
To change these defaults, you can use:
std::cout << io::cdecorate( "[{ ", " }]" ); // [{ a, b, c }]
The problem with this is that it changes the defaults for all the formatting used, thus you cannot have different defaults for sequences and n-ary types.
I don't undestand this, either. Probably I've missed something in earlier messages. What's "n-ary" type? Do you provide the ability to use different separators for sequences, sets and maps? Then I don't understand why you can set different default style for those kinds of object, and cannot selectively override the style
== Dynamic Styles
You can also set CSS properties within script code, e.g. tag.style.fontFamily = "Times New Roman";
This style behaviour is available in the new decorators, for example: io::wrapper_decorators< char > wrap; wrap.open = "<< "; wrap.close = " >>";
What does this decorator "wrap"?
== Cascading Style Sheets
HTML provides a <style> tag to specify styling across the document without linking to an external file, e.g.: <style>h1{ color: orange; font-size: 2pc; }</style>
The equivalent within my library would be to define the styling on a stream, e.g.:
std::cout << css::element( "pair" ) [ ( css::attribute( "open" ) = "<< " ) + ( css::attribute( "close" ) = " >>" ) ] << css::element( "container" ) [ css::attribute( "separator" ) = " | " ] << io::object( ob ) // output: [ << a, 5 >> | << b, -1 >> ] << css::element( "pair" ) [ css::attribute( "separator" ) = " = " ] << io::object( ob ); // output: [ << a = 5 >> | << b = -1 >> ]
I'm sorry, but I'm worried of the direction you took. For me, the primary utility of this library is debugging output. For that, I'd be happy with a single style, as long as it's something usable, like YAML (http://www.yaml.org/). I agree that you might want to store and then restore STL container from a file, and the library addresses this need to. But I don't understand why you would want to customize the formatting style. Basically, you either should the data to user, or not. In first case, you need a single usable style. For the second case, you might need another "compact" style. I don't see the point of customization. Finally, is this library going to be used for producing generic text files? E.g. code generation. I think no, to generate text you need some text template system, and that's way beyond the scope of the library. So, I'm not convinced custom style gives you anything. On the other hand, it will cost a lot. At the very least, even documenting the above will be considerable effort. And given that the library is header-only, this features will cost everyone extra compile time. Even is 'css' stuff is in separate header, you'd need the hooks for customization. Are you sure adding even more features is the way to go? - Volodya