﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Error-随笔分类-boost::iostream</title><link>http://www.cppblog.com/Error/category/20211.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 06 Aug 2013 09:25:32 GMT</lastBuildDate><pubDate>Tue, 06 Aug 2013 09:25:32 GMT</pubDate><ttl>60</ttl><item><title>boost::iostreams 3</title><link>http://www.cppblog.com/Error/archive/2013/07/28/202203.html</link><dc:creator>Enic</dc:creator><author>Enic</author><pubDate>Sun, 28 Jul 2013 15:02:00 GMT</pubDate><guid>http://www.cppblog.com/Error/archive/2013/07/28/202203.html</guid><wfw:comment>http://www.cppblog.com/Error/comments/202203.html</wfw:comment><comments>http://www.cppblog.com/Error/archive/2013/07/28/202203.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Error/comments/commentRss/202203.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Error/services/trackbacks/202203.html</trackback:ping><description><![CDATA[<p>boost的iostreams组件基本上诠释了stream的概念，但是考虑东西似乎太多了，不管怎么样都得好好学学他的思想。此番重新学习一下。</p> <p>&nbsp;</p> <p>模板的世界比较累，先从OOP的视角看看：</p> <p><a href="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_thumb.png" width="687" height="517" /></a></p> <p>咋看一下似乎也没多少东西，是库的作者拿了一堆基础概念在那玩文字游戏好像。</p> <p>抽象起来应该是这样几个东东：IIOStream IIStream IOStream IInSeek IOutSeek&nbsp; IIOSeek IStreamInFilter IStreamOutFilter&nbsp; IStreamIOFilter</p> <p><a href="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_thumb_1.png" width="590" height="453" /></a></p> <p>看起来确实有点恶心，理论和现实是有差距的，，，唉，，，</p> <p>接下来让他更恶心一点，应为还缺少一个Filterable的概念</p> <p><a href="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_6.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_thumb_2.png" width="944" height="470" /></a></p> <p>很快出来一张蜘蛛网，，，这也不能说过度设计吧，也许有些系统需要这么细化呢？</p> <p>不过看到这张蜘蛛网之后果断决定我后面练手绝对不要这么负责，可以考虑v神的做法，接口都是全的，但是功能不一定，使用的不支持的接口就弄个提示啥的。。。</p> <p><a href="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_8.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/Error/Windows-Live-Writer/boostiostreams_11863/image_thumb_3.png" width="600" height="320" /></a></p> <p>这样看上去是那么回事了，，，seek被提炼到stream里边，filter添加sink的概念，或者直接用delegate更合适？</p><img src ="http://www.cppblog.com/Error/aggbug/202203.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Error/" target="_blank">Enic</a> 2013-07-28 23:02 <a href="http://www.cppblog.com/Error/archive/2013/07/28/202203.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>2.boost::iostreams分析暂停一段时间</title><link>http://www.cppblog.com/Error/archive/2012/11/19/195365.html</link><dc:creator>Enic</dc:creator><author>Enic</author><pubDate>Mon, 19 Nov 2012 08:17:00 GMT</pubDate><guid>http://www.cppblog.com/Error/archive/2012/11/19/195365.html</guid><wfw:comment>http://www.cppblog.com/Error/comments/195365.html</wfw:comment><comments>http://www.cppblog.com/Error/archive/2012/11/19/195365.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Error/comments/commentRss/195365.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Error/services/trackbacks/195365.html</trackback:ping><description><![CDATA[<p>原因：</p> <p>1.文档不够完善</p> <p>2.熟悉程度不够，学习曲线比较陡峭，直接用有可能失控</p> <p>3.实现太过复杂，还需要mpl库的支持</p> <p>4.如果使用，iostreams将成为底层，整个项目都会对其依赖，有风险</p> <p>5.说白了，还是能力不够，不过了解了一些iostreams归纳出来的concepts也是非常有收货。</p> <p>6.网上的一句归纳：<div style="display: inline-block; "></div><span class="Apple-style-span" style="color: #333333; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 24px; background-color: #ffffff; ">在真正掌握模版之前尽量少用</span></p> <p>//////////////////////////////////////////////</p> <h4>Device Concepts</h4> <p>The most important Device concepts are these: </p><ul> <li><a href="../concepts/device.html">Device:</a> Base for all Device concepts, provides associated character type and category.  </li><li><a href="../concepts/source.html">Source:</a> Provides read-only access to a sequence of characters.  </li><li><a href="../concepts/sink.html">Sink:</a> Provides write-only access to a sequence of characters.  </li><li><a href="../concepts/bidirectional_device.html">BidirectionalDevice:</a> Provides access to two separate sequences of characters, one for reading and the other for writing.  </li><li><a href="../concepts/seekable_device.html">SeekableDevice:</a> Provides read-write access to a single sequence of characters, with a single repositionable read/write head. </li></ul><a name="filter_concepts"></a> <h4>Filter Concepts</h4> <p>The most important Filter concepts are these: </p><ul> <li><a href="../concepts/filter.html">Filter:</a> Base for all Filter concepts, provides associated character type and category.  </li><li><a href="../concepts/input_filter.html">InputFilter:</a> Filters characters read from a Source.  </li><li><a href="../concepts/output_filter.html">OutputFilter:</a> Filters characters written to a Sink  </li><li><a href="../concepts/bidirectional_filter.html">BidirectionalFilter:</a> Filters two separate character sequences, one read from a Sink and the other written to a Sink.  </li><li><a href="../concepts/seekable_filter.html">SeekableFilter:</a> Filters a single characters sequence, controlled by a SeekableDevice, providing filtered input, output and random access with a single repositionable read/write head </li></ul><a name="optional_behavior"></a> <h4>Optional Behavior</h4> <p>Boost.Iostreams prvides several concepts corresponding to optional behavior that a Filter or Device might implement: </p><ul> <li><a href="../concepts/blocking.html">Blocking:</a> A Device which blocks when it receives a read or write request until all requested characters are available, or until the end of a stream is reached.  </li><li><a href="../concepts/direct.html">Direct:</a> A Device which provides access to its controlled sequences as regions of memory rather than <em>via</em> a socket-like interface.  </li><li><a href="../concepts/closable.html">Closable:</a> A Filter or Device which receives notifications immediately before a stream is closed.  </li><li><a href="../concepts/flushable.html">Flushable</a> A Filter or Device which receives notifications when a stream is flushed.  </li><li><a href="../concepts/localizable.html">Localizable:</a> A Filter or Device which receives notifications when the <code>locale</code> of a stream or stream buffer is set using <code>basic_ios::imbue</code> or <code>basic_streambuf::pubimbue</code>.  </li><li><a href="../concepts/multi_character.html">Multi-Character:</a> A Filter which provides access to its controlled sequences several characters at a time, <em>via</em> a socket-like interface.  </li><li><a href="../concepts/optimally_buffered.html">OptimallyBuffered</a> A Filter or Device which will be fitted with a buffer of custom size if no buffer size is explicitly requested by the user.  </li><li><a href="../concepts/peekable.html">Peekable:</a> A source which allows characters to be put back to the input sequence.  </li><li><a href="../concepts/pipable.html">Pipable:</a> A Filter which can appear in <a href="pipelines.html">pipelines</a>. </li></ul><img src ="http://www.cppblog.com/Error/aggbug/195365.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Error/" target="_blank">Enic</a> 2012-11-19 16:17 <a href="http://www.cppblog.com/Error/archive/2012/11/19/195365.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>1.modes</title><link>http://www.cppblog.com/Error/archive/2012/11/19/195348.html</link><dc:creator>Enic</dc:creator><author>Enic</author><pubDate>Mon, 19 Nov 2012 03:49:00 GMT</pubDate><guid>http://www.cppblog.com/Error/archive/2012/11/19/195348.html</guid><wfw:comment>http://www.cppblog.com/Error/comments/195348.html</wfw:comment><comments>http://www.cppblog.com/Error/archive/2012/11/19/195348.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Error/comments/commentRss/195348.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Error/services/trackbacks/195348.html</trackback:ping><description><![CDATA[<p>mode（模式？）：<br>&nbsp;&nbsp;&nbsp; input: 使用一个character队列，用来输入<br>&nbsp;&nbsp;&nbsp; output: 使用一个character队列，用来输出<br>&nbsp;&nbsp;&nbsp; bidirectional: 使用两个character队列，分别用来输入、输出<br>&nbsp;&nbsp;&nbsp; input-seekable: 使用一个character队列用来输入，包含一个读索引游标<br>&nbsp;&nbsp;&nbsp; output-seekable: 使用一个character队列用来输出，包含一个写索引游标<br>&nbsp;&nbsp;&nbsp; seekable: 使用一个character队列用来输入输出，包含一个读/写复用的索引游标<br>&nbsp;&nbsp;&nbsp; dual-seekable: 使用一个character队列来输入输出，包含两个索引游标分别用来标识读写<br>&nbsp;&nbsp;&nbsp; bidirectional-seekable: 使用两个character队列分别用来输入输出，同时每个队列包含一个各自的索引游标<br>&nbsp;&nbsp;&nbsp; *blocking: 如果读请求永远比剩下的character少除了end情况，而且写请求需要的永远比现有的少。那就是一个blocking。<br>The Blocking concept does not apply to filters. Instead, filters are required to be blocking-preserving, which means that  <p>a read request never produces fewer characters than requested unless end-of-stream has been reached or unless a read request to a downsteam Source produces fewer characters than requested, and <br>a write request never consumes fewer characters than requested unless a write request to a downsteam Sink consumes fewer characters than requested.  <p>&nbsp;</p> <p><a href="http://www.cppblog.com/images/cppblog_com/Error/WindowsLiveWriter/1.modes_A6E3/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.cppblog.com/images/cppblog_com/Error/WindowsLiveWriter/1.modes_A6E3/image_thumb.png" width="943" height="643"></a> </p> <p>&nbsp;</p> <p>&nbsp;</p> <p>*如果熟悉stl应该就了解traits技术（应该是技巧）</p> <p><a href="../../../../boost/iostreams/traits.hpp"><code>&lt;boost/iostreams/traits.hpp&gt;</code></a>这里是boost::iostream库的traits</p> <p>还有个模版元函数mod_of</p><img src ="http://www.cppblog.com/Error/aggbug/195348.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Error/" target="_blank">Enic</a> 2012-11-19 11:49 <a href="http://www.cppblog.com/Error/archive/2012/11/19/195348.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>