123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <chapter>
- <title><tt>__vic/writers/</tt></title>
- <chapter>
- <title><tt>Writer</tt> concept</title>
- <code-block lang="C++"><![CDATA[
- template<class ElementT>
- class ]]><nt>Writer</nt><![CDATA[
- {
- public:
- Writer(Writer &&o); or Writer(const Writer &o);
- void write(ElementT v); // throws on errors
- };
- ]]></code-block>
- <p>A concept used by the library algorihms to write logical sequence of elements
- of type <tt>ElementT</tt> element by element. It is a generalization and rework
- of the <tt>OutputIterator</tt> concept. In particular it better handles streams
- and other output sequences where <tt>end</tt>-iterator is meaningless or
- expensive to obtain. At the same time, traditional output iterators as
- <tt>std::back_insert_iterator</tt> are just a particular case and fully and well
- handled by <tt>__vic::push_back_writer</tt> adapter.</p>
- <p>When the particular class meets the requirements of this concept for some
- <tt>ElementT = T</tt> it is said <b>to model</b> the <tt>Writer<T></tt>
- concept.</p>
- <p>Each instance of the class has to be move- or copy-constructible.</p>
- <section><title>Class members</title>
- <synopsis>
- <prototype>void write(ElementT v)</prototype>
- <p>Writes the element or throws an exception on error.</p>
- </synopsis>
- </section>
- </chapter>
- <chapter>
- <title><tt>push_back_writer</tt></title>
- <code-block lang="C++"><![CDATA[
- #include<__vic/writers/push_back.h>
- template<class Cont, class T = typename Cont::value_type>
- class push_back_writer
- {
- public:
- explicit push_back_writer(Cont &c);
- void write(T v) { c->push_back(v); }
- };
- ]]></code-block>
- <p>An adapter. Uses <tt>push_back()</tt> member function to write elements.</p>
- </chapter>
- <chapter>
- <title><tt>string_writer</tt></title>
- <code-block lang="C++"><![CDATA[
- #include<__vic/writers/string.h>
- template<
- class charT,
- class Tr = std::char_traits<charT>,
- class Al = std::allocator<charT>
- >
- class basic_string_writer
- {
- public:
- explicit basic_string_writer(std::basic_string<charT,Tr,Al> &s);
- void write(charT ch);
- };
- using string_writer = basic_string_writer<char>;
- ]]></code-block>
- <p>An adapter for <tt>std::basic_string</tt>.</p>
- </chapter>
- <chapter>
- <title><tt>cstream_writer</tt></title>
- <code-block lang="C++"><![CDATA[
- #include<__vic/writers/cstream.h>
- class cstream_writer
- {
- public:
- explicit cstream_writer(std::FILE *fp);
- void write(char ch) { __vic::write(fp, ch); }
- };
- ]]></code-block>
- <p>Models <tt>Writer<char></tt> for <tt>std::FILE</tt>.</p>
- </chapter>
- </chapter>
|