**** Code with tabs ****
class tab_expanding_output_filter : public output_filter {
public:
explicit tab_expanding_output_filter(int tab_size = 8)
: tab_size_(tab_size), col_no_(0)
{ assert(tab_size > 0); }
template<typename Sink>
void put(Sink& dest, int c)
{
if (c == '\t') {
do {
this->put(dest, ' ');
} while(col_no_ % tab_size_ != 0);
} else {
boost::iostreams::put(dest, c);
if (c == '\n')
col_no_ = 0;
else
++col_no_;
}
}
templatetypename Sink
void close(Sink&) { col_no_ = 0; }
private:
int tab_size_;
int col_no_;
};
**** Code with tabs replaced ****
class tab_expanding_output_filter : public output_filter {
public:
explicit tab_expanding_output_filter(int tab_size = 8)
: tab_size_(tab_size), col_no_(0)
{ assert(tab_size > 0); }
template<typename Sink>
void put(Sink& dest, int c)
{
if (c == '\t') {
do {
this->put(dest, ' ');
} while(col_no_ % tab_size_ != 0);
} else {
boost::iostreams::put(dest, c);
if (c == '\n')
col_no_ = 0;
else
++col_no_;
}
}
template<typename Sink>
void close(Sink&) { col_no_ = 0; }
private:
int tab_size_;
int col_no_;
};
Revised 20 May, 2004
© Copyright Jonathan Turkanis, 2004
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)