namespace lyx {
-otexrowstream::otexrowstream(odocstream & os, bool enable)
- : os_(os), texrow_(make_unique<TexRow>(enable))
+otexrowstream::otexrowstream(odocstream & os)
+ : os_(os), texrow_(make_unique<TexRow>())
{}
}
-void otexrowstream::append(docstring const & str, TexRow texrow)
-{
- os_ << str;
- texrow_->append(move(texrow));
-}
-
-
void otexrowstream::put(char_type const & c)
{
os_.put(c);
}
+size_t otexstringstream::length()
+{
+ auto pos = ods_.tellp();
+ return (pos >= 0) ? size_t(pos) : 0;
+}
+
+
+TexString otexstringstream::release()
+{
+ TexString ts(ods_.str(), move(texrow()));
+ // reset this
+ texrow() = TexRow();
+ ods_.clear();
+ ods_.str(docstring());
+ return ts;
+}
+
+
BreakLine breakln;
SafeBreakLine safebreakln;
return ots;
}
+
otexstream & operator<<(otexstream & ots, odocstream_manip pf)
{
otexrowstream & otrs = ots;
}
+otexrowstream & operator<<(otexrowstream & ots, TexString ts)
+{
+ ts.validate();
+ ots.os() << move(ts.str);
+ ots.texrow().append(move(ts.texrow));
+ return ots;
+}
+
+
+otexstream & operator<<(otexstream & ots, TexString ts)
+{
+ size_t const len = ts.str.length();
+ // Check whether there is something to output
+ if (len == 0)
+ return ots;
+
+ otexrowstream & otrs = ots;
+ if (ots.protectSpace()) {
+ if (!ots.canBreakLine() && ts.str[0] == ' ')
+ otrs << "{}";
+ ots.protectSpace(false);
+ }
+
+ if (len > 1)
+ ots.canBreakLine(ts.str[len - 2] != '\n');
+ ots.lastChar(ts.str[len - 1]);
+
+ otrs << move(ts);
+ return ots;
+}
+
+
otexrowstream & operator<<(otexrowstream & ots, docstring const & s)
{
ots.os() << s;