4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Enrico Forestieri
9 * Full author contact details are available in file CREDITS.
12 #ifndef LYX_TEXSTREAM_H
13 #define LYX_TEXSTREAM_H
16 #include "support/docstream.h"
20 /** Wrapper class for odocstream.
21 This class is used to automatically count the lines of the exported latex
22 code and also to ensure that no blank lines may be inadvertently output.
23 To this end, use the special variables "breakln" and "safebreakln" as if
24 they were iomanip's to ensure that the next output will start at the
25 beginning of a line. Using "breakln", a '\n' char will be output if needed,
26 while using "safebreakln", "%\n" will be output if needed.
27 The class also records the last output character and can tell whether
28 a paragraph break was just output.
34 otexstream(odocstream & os, TexRow & texrow)
35 : os_(os), texrow_(texrow), canbreakline_(false),
36 protectspace_(false), parbreak_(true), lastchar_(0) {}
38 odocstream & os() { return os_; }
40 TexRow & texrow() { return texrow_; }
42 void put(char_type const & c);
44 void canBreakLine(bool breakline) { canbreakline_ = breakline; }
46 bool canBreakLine() const { return canbreakline_; }
48 void protectSpace(bool protectspace) { protectspace_ = protectspace; }
50 bool protectSpace() const { return protectspace_; }
52 void lastChar(char_type const & c)
54 parbreak_ = (!canbreakline_ && c == '\n');
55 canbreakline_ = (c != '\n');
59 char_type lastChar() const { return lastchar_; }
61 bool afterParbreak() const { return parbreak_; }
77 /// Helper structs for breaking a line
82 struct SafeBreakLine {
86 extern BreakLine breakln;
87 extern SafeBreakLine safebreakln;
90 otexstream & operator<<(otexstream &, BreakLine);
92 otexstream & operator<<(otexstream &, SafeBreakLine);
94 otexstream & operator<<(otexstream &, odocstream_manip);
96 otexstream & operator<<(otexstream &, docstring const &);
98 otexstream & operator<<(otexstream &, std::string const &);
100 otexstream & operator<<(otexstream &, char const *);
102 otexstream & operator<<(otexstream &, char);
104 template <typename Type>
105 otexstream & operator<<(otexstream & ots, Type value);