/usr/include/bobcat/ofoldstreambuf is in libbobcat-dev 3.23.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | #ifndef INCLUDED_BOBCAT_OFOLDSTREAMBUF_
#define INCLUDED_BOBCAT_OFOLDSTREAMBUF_
#include <iostream>
#include <string>
#include <vector>
#include <bobcat/ofilterstreambuf>
namespace FBB
{
class lm
{
size_t d_value;
public:
lm(int value); // 1.f
std::ostream &modify(std::ostream &out) const; // 1.f
};
class mlm
{
int d_value;
public:
mlm(int value); // 1.f
std::ostream &modify(std::ostream &out) const; // 2.f
};
struct OFoldStreambufEnums
{
enum TrailingBlanks
{
IGNORE_TRAILING_BLANKS,
HANDLE_TRAILING_BLANKS
};
enum TabsOrBlanks
{
BLANKS,
TABS
};
};
// 'virtual public OFoldStreambufBlanks is used to avoid 'base class not
// accessible' warnings when classes inherit from OFoldStreambuf like
// OFoldStream.
class OFoldStreambuf: virtual public OFoldStreambufEnums,
public OFilterStreambuf
{
friend std::ostream &lm::modify(std::ostream &) const;
friend std::ostream &mlm::modify(std::ostream &) const;
enum Mode
{
INDENT,
WS,
NON_WS
};
std::string d_nonWs;
std::string d_ws;
size_t d_rightMargin;
size_t d_indent;
bool d_reqIndent;
size_t d_wsLength;
size_t d_next;
Mode d_mode;
char d_indentChar;
size_t d_indentWidth;
bool d_handleTrailingBlanks;
typedef std::vector<OFoldStreambuf const *>::iterator BufIt;
static std::vector<OFoldStreambuf const *> s_buffers;
public:
explicit OFoldStreambuf(
size_t leftIndent = 0, size_t rightMargin = 80,
TabsOrBlanks tob = BLANKS,
TrailingBlanks tb = IGNORE_TRAILING_BLANKS);
explicit OFoldStreambuf(char const *fname,
size_t leftIndent = 0, size_t rightMargin = 80,
TabsOrBlanks tob = BLANKS,
TrailingBlanks tb = IGNORE_TRAILING_BLANKS);
explicit OFoldStreambuf(std::ostream &stream,
size_t leftIndent = 0, size_t rightMargin = 80,
TabsOrBlanks tob = BLANKS,
TrailingBlanks tb = IGNORE_TRAILING_BLANKS);
virtual ~OFoldStreambuf();
void setMargins(size_t leftMargin, size_t rightMargin);
void setTrailingBlanks(TrailingBlanks tb); // .f
void useBlanks(); // .f
void useTabs(size_t tabWidth = 8); // .f
static size_t leftMargin(std::streambuf const *buffer);
static size_t rightMargin(std::streambuf const *buffer);
protected:
int pSync();
private:
virtual int sync();
virtual int overflow(int c);
void indent(int c);
void ws(int c);
void nonWs(int c);
size_t length() const;
void iniBlankTabs(TabsOrBlanks tob);
void newline();
void addNonWs(int c); // .f
void addWs(int c);
void indent();
void flush();
void clearWs();
void modifyIndent(int delta);
void setIndent(int value); // .f
void writeWs() const; // .f
void writeNonWs() const; // .f
void put(int ch) const; // .f
static BufIt findOFoldStreambuf(std::streambuf const *buffer);
};
inline lm::lm(int value)
:
d_value(value < 0 ? 0 : value)
{}
inline std::ostream &lm::modify(std::ostream &out) const
{
dynamic_cast<OFoldStreambuf &>(*out.rdbuf()).setIndent(d_value);
return out;
}
inline mlm::mlm(int value)
:
d_value(value)
{}
inline std::ostream &mlm::modify(std::ostream &out) const
{
dynamic_cast<OFoldStreambuf &>(*out.rdbuf()).modifyIndent(d_value);
return out;
}
inline size_t OFoldStreambuf::leftMargin(std::streambuf const *buffer)
{
return (*findOFoldStreambuf(buffer))->d_indent;
}
inline size_t OFoldStreambuf::rightMargin(std::streambuf const *buffer)
{
return (*findOFoldStreambuf(buffer))->d_rightMargin;
}
inline void OFoldStreambuf::setIndent(int value)
{
d_indent = value;
}
inline void OFoldStreambuf::setTrailingBlanks(TrailingBlanks tb)
{
d_handleTrailingBlanks = tb == HANDLE_TRAILING_BLANKS;
}
inline void OFoldStreambuf::useBlanks()
{
d_indentChar = ' ';
d_indentWidth = 1;
}
inline void OFoldStreambuf::useTabs(size_t tabWidth)
{
d_indentChar = '\t';
d_indentWidth = tabWidth;
}
// Free functions
inline std::ostream &operator<<(std::ostream &out, lm const &idt)
{
return idt.modify(out);
}
inline std::ostream &operator<<(std::ostream &out, mlm const &idt)
{
return idt.modify(out);
}
} // FBB
#endif
|