3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Enrico Forestieri
8 * Full author contact details are available in file CREDITS.
13 #include "texstream.h"
14 #include "support/lstrings.h"
15 #include "support/unicode.h"
26 using lyx::support::contains;
27 using lyx::support::split;
32 void otexrowstream::put(char_type const & c)
39 void otexstream::put(char_type const & c)
42 if (!canbreakline_ && c == ' ')
44 protectspace_ = false;
46 otexrowstream::put(c);
52 SafeBreakLine safebreakln;
55 otexstream & operator<<(otexstream & ots, BreakLine)
57 if (ots.canBreakLine()) {
58 ots.otexrowstream::put('\n');
61 ots.protectSpace(false);
66 otexstream & operator<<(otexstream & ots, SafeBreakLine)
68 otexrowstream & otrs = ots;
69 if (ots.canBreakLine()) {
73 ots.protectSpace(false);
78 otexrowstream & operator<<(otexrowstream & ots, odocstream_manip pf)
81 if (pf == static_cast<odocstream_manip>(endl)) {
82 ots.texrow().newline();
87 otexstream & operator<<(otexstream & ots, odocstream_manip pf)
89 otexrowstream & otrs = ots;
91 if (pf == static_cast<odocstream_manip>(endl)) {
98 otexrowstream & operator<<(otexrowstream & ots, docstring const & s)
101 ots.texrow().newlines(count(s.begin(), s.end(), '\n'));
106 otexstream & operator<<(otexstream & ots, docstring const & s)
108 size_t const len = s.length();
110 // Check whether there's something to output
113 otexrowstream & otrs = ots;
114 if (ots.protectSpace()) {
115 if (!ots.canBreakLine() && s[0] == ' ')
117 ots.protectSpace(false);
120 if (contains(s, 0xF0000)) {
121 // Some encoding changes for the underlying stream are embedded
122 // in the docstring. The encoding names to be used are enclosed
123 // between the code points 0xF0000 and 0xF0001, the first two
124 // characters of plane 15, which is a Private Use Area whose
125 // codepoints don't have any associated glyph.
127 docstring s2 = split(s, s1, 0xF0000);
134 docstring const s3 = split(s2, enc, 0xF0001);
135 if (!contains(s2, 0xF0001))
136 s2 = split(enc, s1, 0xF0000);
138 otrs << setEncoding(to_ascii(enc));
139 s2 = split(s3, s1, 0xF0000);
146 ots.canBreakLine(s[len - 2] != '\n');
147 ots.lastChar(s[len - 1]);
152 otexrowstream & operator<<(otexrowstream & ots, string const & s)
159 otexstream & operator<<(otexstream & ots, string const & s)
166 otexrowstream & operator<<(otexrowstream & ots, char const * s)
173 otexstream & operator<<(otexstream & ots, char const * s)
180 otexrowstream & operator<<(otexrowstream & ots, char c)
187 otexstream & operator<<(otexstream & ots, char c)
194 template <typename Type>
195 otexrowstream & operator<<(otexrowstream & ots, Type value)
201 template otexrowstream & operator<< <SetEnc>(otexrowstream & os, SetEnc);
202 template otexrowstream & operator<< <double>(otexrowstream &, double);
203 template otexrowstream & operator<< <int>(otexrowstream &, int);
204 template otexrowstream & operator<< <unsigned int>(otexrowstream &,
206 template otexrowstream & operator<< <unsigned long>(otexrowstream &,
210 template <typename Type>
211 otexstream & operator<<(otexstream & ots, Type value)
215 ots.protectSpace(false);
219 template otexstream & operator<< <SetEnc>(otexstream & os, SetEnc);
220 template otexstream & operator<< <double>(otexstream &, double);
221 template otexstream & operator<< <int>(otexstream &, int);
222 template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
223 template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);