Boost C++ Libraries: Ticket #4454: iterator range output format, and for IO adaptor https://svn.boost.org/trac10/ticket/4454 <p> When output Range of {1,2,3} by iterator_range_io, it becomes format : "123". In this format, it is difficult(or impossible) to parse. </p> <p> I propose, the new range format inspired by Oven : "{1,2,3}". This proposal is break change, but the present format wouldn't be used. </p> <p> Additionally, it propose identities Range Adaptor that Range adapt to iterator_range. It can be used to output a standard container easily. This was inspired by Oven, too. </p> <p> <a class="ext-link" href="http://p-stade.sourceforge.net/oven/doc/html/oven/utilities.html#oven.utilities.io_hpp"><span class="icon">​</span>http://p-stade.sourceforge.net/oven/doc/html/oven/utilities.html#oven.utilities.io_hpp</a> </p> <p> <a class="ext-link" href="http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.range_adaptors.identities"><span class="icon">​</span>http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.range_adaptors.identities</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4454 Trac 1.4.3 Akira Takahashi <faithandbrave@…> Tue, 20 Jul 2010 05:21:42 GMT attachment set https://svn.boost.org/trac10/ticket/4454 https://svn.boost.org/trac10/ticket/4454 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">range_io.zip</span> </li> </ul> <p> source file, and test. </p> Ticket Akira Takahashi <faithandbrave@…> Tue, 20 Jul 2010 05:34:56 GMT <link>https://svn.boost.org/trac10/ticket/4454#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:1</guid> <description> <p> Sorry, since description was bad. it re-description. </p> <p> -- </p> <p> When Range {1,2,3} is output by iterator_range_io, its format is "123" which is difficult (or impossible) to parse. </p> <p> I propose, the new range format inspired by Oven : "{1,2,3}". This proposal is break change, but the present format wouldn't be used. </p> <p> I also propose "identities Range Adaptor" which adapts Range to iterator_range. The adaptor enables you to use standard containers easily. This was inspired by Oven, too. </p> <p> <a class="ext-link" href="http://p-stade.sourceforge.net/oven/doc/html/oven/utilities.html#oven.utilities.io_hpp"><span class="icon">​</span>http://p-stade.sourceforge.net/oven/doc/html/oven/utilities.html#oven.utilities.io_hpp</a> </p> <p> <a class="ext-link" href="http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.range_adaptors.identities"><span class="icon">​</span>http://p-stade.sourceforge.net/oven/doc/html/oven/range_adaptors.html#oven.range_adaptors.identities</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Thu, 22 Jul 2010 20:22:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4454#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:2</guid> <description> <p> I will maintain compatibility. Not producing delimiters by default is exactly what I intended and continue to believe is the correct default. I have many users that use this facility to stream binary messages, for example. </p> <p> I will investigate a solution that learns from the Oven solution and achieves the same result. I hope this compromise will reassure those using the library currently that breaking contract changes will not occur, while providing sufficient resolution to your needs. </p> <p> Generally I think I need to be talking with p-stade to bring some of the great ideas into Boost. </p> <p> Thank you for your report. I intend to have this resolved for Boost 1.45 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Sun, 14 Nov 2010 17:47:53 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/4454#comment:3 https://svn.boost.org/trac10/ticket/4454#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket giecrilj@… Mon, 12 Dec 2011 01:09:37 GMT <link>https://svn.boost.org/trac10/ticket/4454#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:4</guid> <description> <p> BTW, <em>outputed</em> is not an English word (in comment). </p> </description> <category>Ticket</category> </item> <item> <author>giecrilj@…</author> <pubDate>Mon, 12 Dec 2011 02:35:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4454#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:5</guid> <description> <dl class="wiki"><dt>Syntax</dt><dd><code>(cout &lt;&lt; separated (range, " "))</code> </dd></dl> <h2 class="section" id="Implementation">Implementation</h2> <div class="wiki-code"><div class="code"><pre> <span class="k">namespace</span> <span class="n">boost</span> <span class="p">{</span> <span class="k">namespace</span> <span class="n">detail</span> <span class="p">{</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_R</span><span class="p">,</span> <span class="k">class</span> <span class="nc">P_C</span> <span class="o">&gt;</span> <span class="k">struct</span> <span class="n">output_range</span> <span class="p">{</span> <span class="k">typedef</span> <span class="n">P_R</span> <span class="n">range_type</span><span class="p">;</span> <span class="k">typedef</span> <span class="n">P_C</span> <span class="n">char_type</span><span class="p">;</span> <span class="n">range_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">m_range</span><span class="p">;</span> <span class="n">char_type</span> <span class="k">const</span> <span class="o">*</span><span class="n">m_sep</span><span class="p">;</span> <span class="kr">inline</span> <span class="nf">output_range</span> <span class="p">(</span><span class="n">range_type</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">,</span> <span class="n">char_type</span> <span class="k">const</span> <span class="n">p_s</span> <span class="p">[])</span> <span class="o">:</span><span class="n">m_range</span> <span class="p">(</span><span class="n">p_r</span><span class="p">),</span> <span class="n">m_sep</span> <span class="p">(</span><span class="n">p_s</span><span class="p">)</span> <span class="p">{}};</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_R</span><span class="p">,</span> <span class="k">class</span> <span class="nc">P_C</span><span class="p">,</span> <span class="k">class</span> <span class="nc">P_T</span> <span class="o">&gt;</span> <span class="kr">inline</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">basic_ostream</span> <span class="o">&lt;</span> <span class="n">P_C</span><span class="p">,</span> <span class="n">P_T</span> <span class="o">&gt;</span> <span class="o">&amp;</span><span class="k">operator</span> <span class="o">&lt;&lt;</span> <span class="p">(</span><span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">basic_ostream</span> <span class="o">&lt;</span> <span class="n">P_C</span><span class="p">,</span> <span class="n">P_T</span> <span class="o">&gt;</span> <span class="o">&amp;</span><span class="n">p_s</span><span class="p">,</span> <span class="n">output_range</span> <span class="o">&lt;</span> <span class="n">P_R</span><span class="p">,</span> <span class="n">P_C</span> <span class="o">&gt;</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">)</span> <span class="p">{</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">copy</span> <span class="p">(</span><span class="n">p_r</span><span class="p">.</span> <span class="n">m_range</span><span class="p">,</span> <span class="o">::</span><span class="n">std</span> <span class="o">::</span><span class="n">ostream_iterator</span> <span class="o">&lt;</span> <span class="k">typename</span> <span class="o">::</span><span class="n">boost</span> <span class="o">::</span><span class="n">range_value</span> <span class="o">&lt;</span> <span class="n">P_R</span> <span class="o">&gt;</span> <span class="o">::</span><span class="n">type</span><span class="p">,</span> <span class="n">P_C</span><span class="p">,</span> <span class="n">P_T</span> <span class="o">&gt;</span> <span class="p">(</span><span class="n">p_s</span><span class="p">,</span> <span class="n">p_r</span> <span class="p">.</span><span class="n">m_sep</span><span class="p">));</span> <span class="k">return</span> <span class="n">p_s</span><span class="p">;</span> <span class="p">}}</span> <span class="k">template</span> <span class="o">&lt;</span> <span class="k">class</span> <span class="nc">P_R</span><span class="p">,</span> <span class="k">class</span> <span class="nc">P_C</span> <span class="o">&gt;</span> <span class="n">detail</span> <span class="o">::</span><span class="n">output_range</span> <span class="o">&lt;</span> <span class="n">P_R</span><span class="p">,</span> <span class="n">P_C</span> <span class="o">&gt;</span> <span class="n">separated</span> <span class="p">(</span><span class="n">P_R</span> <span class="k">const</span> <span class="o">&amp;</span><span class="n">p_r</span><span class="p">,</span> <span class="n">P_C</span> <span class="k">const</span> <span class="n">p_s</span> <span class="p">[])</span> <span class="p">{</span> <span class="k">return</span> <span class="n">detail</span> <span class="o">::</span><span class="n">output_range</span> <span class="o">&lt;</span> <span class="n">P_R</span><span class="p">,</span> <span class="n">P_C</span> <span class="o">&gt;</span> <span class="p">(</span><span class="n">p_r</span><span class="p">,</span> <span class="n">p_s</span><span class="p">);</span> <span class="p">}</span> <span class="p">}</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Tue, 04 Mar 2014 13:02:45 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/4454#comment:6 https://svn.boost.org/trac10/ticket/4454#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.44.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> Ticket Neil Groves Sun, 09 Mar 2014 21:19:07 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4454#comment:7 https://svn.boost.org/trac10/ticket/4454#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I've gone with an implementation called "separated" as suggested but have made the Separated type a template type deduced to allow more flexibility. I also copy the iterators rather than refer to the range to avoid lifetime issues. </p> <p> The original suggestion of having a prefix and suffix built into this function has been dropped since this unnecessary coupling. </p> <p> This is committed to develop and will be merged for Release 1.56 </p> Ticket Akira Takahashi <faithandbrave@…> Mon, 10 Mar 2014 05:48:25 GMT <link>https://svn.boost.org/trac10/ticket/4454#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:8</guid> <description> <p> I checked the feature. Now interface is follow: </p> <pre class="wiki">separated(v, ',') </pre><p> I think better interface is follow: </p> <pre class="wiki">v | separated(','); // pipe operator version (past participle) separate(v, ','); // function version (present form) </pre><p> More improvement interface: </p> <pre class="wiki">v | formatted; // {a,b,c} v | formatted(','); // {a,b,c} v | formatted(',', '{', '}'); // {a,b,c} </pre> </description> <category>Ticket</category> </item> <item> <author>Akira Takahashi <faithandbrave@…></author> <pubDate>Mon, 24 Mar 2014 02:15:53 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/4454#comment:9 https://svn.boost.org/trac10/ticket/4454#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Please check my comment, Neil. </p> Ticket Neil Groves Thu, 05 Jun 2014 00:06:35 GMT <link>https://svn.boost.org/trac10/ticket/4454#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:10</guid> <description> <p> Reimplemented as the formatted adaptor. This is committed to develop. Once the tests have cycled a few times I shall merge this to master and therefore to the next release. </p> </description> <category>Ticket</category> </item> <item> <author>Akira Takahashi <faithandbrave@…></author> <pubDate>Thu, 05 Jun 2014 04:58:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4454#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4454#comment:11</guid> <description> <p> checked. It seems good design and implementation. Thanks! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Neil Groves</dc:creator> <pubDate>Thu, 05 Jun 2014 13:48:42 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4454#comment:12 https://svn.boost.org/trac10/ticket/4454#comment:12 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I apologise for taking so long. My ego is a little bruised from making so many poor decisions and then U-turns, but at least the end result is good. </p> <p> Thanks for your patience. The code is now merged to master. </p> Ticket