Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
iostream.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 
5 #include <boost/iostreams/filtering_stream.hpp>
6 #include <boost/iostreams/char_traits.hpp> // EOF, WOULD_BLOCK
7 #include <boost/iostreams/concepts.hpp> // multichar_output_filter
8 #include <boost/iostreams/operations.hpp> // get
9 
10 namespace vcsn
11 {
12  namespace detail
13  {
14  namespace io = boost::iostreams;
15 
18  : public io::multichar_output_filter
19  {
20  public:
22  {}
23 
24  void enable()
25  {
26  enabled_ = true;
27  }
28 
29  void disable()
30  {
31  enabled_ = false;
32  }
33 
34  template <typename Sink>
35  std::streamsize
36  write(Sink& dest, const char* s, std::streamsize n)
37  {
38  std::streamsize z;
39  for (z = 0; z < n; ++z)
40  {
41  char c = s[z];
42  if (enabled_ && c == '\\')
43  if (!io::put(dest, '\\'))
44  // FIXME: probably lost a char here.
45  break;
46  if (!io::put(dest, c))
47  break;
48  }
49  return z;
50  }
51 
52  bool enabled_ = false;
53  };
54  }
55 
56 #if 0
57  detail::io::filtering_ostream
59  backslashify(std::ostream& os)
60  {
61  detail::io::filtering_ostream res;
63  res.push(os);
64  return std::move(res);
65  }
66 #endif
67 }
std::streamsize write(Sink &dest, const char *s, std::streamsize n)
Definition: iostream.hh:36
variadic_mul_mixin< detail::z_impl > z
Definition: fwd.hh:43
std::ostringstream os
The output stream: the corresponding C++ snippet to compile.
Definition: translate.cc:331