
Jonathan Turkanis wrote:
Although my library is still under review, I am re-architecturing it
on the feedback thus far. This post is the code associated with what was
"Reece Dunn" <msclrhd@hotmail.com> wrote in message news:BAY24-F288Jecd92bXC000d4659@hotmail.com... based the
delimiters/formatters part of the library. They are now given the better name of "decorators".
Hi Reece,
I'm planning to post a review [ favorable, presumably ;-) ], but haven't started to read the thread yet.
Great.
I'm sorry I was never able to follow through on my ideas for your library -- I just got too busy with other things.
No worries.
If there you feel there are some major architectural changes that need to be made, I'm still interested in collaborating. My main ideas were a introducing cascading style sheets and inline formatters using expression templates.
Formatters are dead! Long live decorators! ;) I am intrigued by the idea of cascading style sheets (CSS), but have a question regarding inlined formatters/decorators: What can you do with inlined decorators that you can't do with the format/decorate function? For example: namespace io = boost::io; namespace fmt = boost::io::format; std::cout << io::object( ob, fmt::container( fmt::pair().decorate( "( ", " )" )).decorate( "[{ ", " }]" ) ).decorate( " - " ); // output: [{ ( a, 5 ), ( b, -1 ) }] How do you envision CSS working? The way I see it is that you are viewing the format objects as HTML tags that have a style attribute associated with them that contains a set of ( attribute, value ) pairs (a std::map< std::string, std::string >?) This way, the decorate function would be the equivalent of setting the style attribute: fmt::pair().decorate( "( ", " )" ); // <pair style = "open: '( '; close: ' )';"/> 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 = " >>"; If you save a format object for use later, e.g.: fmt::container_t< char, fmt::pair_t< char > > my_fo = fmt::container( fmt::pair()); The library should support decorating nested format objects, e.g.: my_fo.elem.open = "<< "; my_ob.elem.close = " >>"; my_ob.separator = " | "; std::cout << io::object( ob, my_ob ); // output: [ << a, 5 >> | << b, -1
]
HTML allows you to associate a stylesheet file with the HTML markup that sets how certain tags are displayed, e.g.: body{ color: red; } This will set the font colour of the body element to red. I suppose the equivalent here would be the various format objects (each having a "tag" name) and the style being saved on a stream. This would allow something like: std::cout << ( io::css[ "container" ].separator = " : " ) << io::object( ob ); // output: [ [ a, 5 ] : [ b, -1 ] ] std::wcout << ( io::css[ L"pair" ].separator = L" = " ) << io::object( ob ); // output: [ [ a = 5 ], [ b = -1 ] ] With the "body{ color: red; }" example, the CSS attribute is inherited to all its child tags. The question here would be: should styling be inherited? Regards, Reece _________________________________________________________________ Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo