]> git.lyx.org Git - lyx.git/blobdiff - src/texstream.cpp
Avoid duplicating mode changing commands
[lyx.git] / src / texstream.cpp
index 84fb060552b9da4044f9cb47906f8d3331828f2d..ec8158d8fd2295d97d906ac7d349e4fb3c11772c 100644 (file)
@@ -11,6 +11,9 @@
 #include <config.h>
 
 #include "texstream.h"
+
+#include "TexRow.h"
+
 #include "support/lstrings.h"
 #include "support/unicode.h"
 
@@ -29,13 +32,38 @@ using lyx::support::split;
 
 namespace lyx {
 
+
+otexrowstream::otexrowstream(odocstream & os, bool enable)
+       : os_(os), texrow_(make_unique<TexRow>(enable))
+{}
+
+
+otexrowstream::~otexrowstream() = default;
+
+
+unique_ptr<TexRow> otexrowstream::releaseTexRow()
+{
+       auto p = make_unique<TexRow>();
+       swap(texrow_, p);
+       return p;
+}
+
+
+void otexrowstream::append(docstring const & str, TexRow texrow)
+{
+       os_ << str;
+       texrow_->append(move(texrow));
+}
+
+
 void otexrowstream::put(char_type const & c)
 {
        os_.put(c);
        if (c == '\n')
-               texrow_.newline();
+               texrow_->newline();
 }
 
+
 void otexstream::put(char_type const & c)
 {
        if (protectspace_) {
@@ -206,6 +234,11 @@ template otexrowstream & operator<< <unsigned int>(otexrowstream &,
 template otexrowstream & operator<< <unsigned long>(otexrowstream &,
                                                                                                        unsigned long);
 
+#ifdef LYX_USE_LONG_LONG
+template otexrowstream & operator<< <unsigned long long>(otexrowstream &,
+                                                         unsigned long long);
+#endif
+
 
 template <typename Type>
 otexstream & operator<<(otexstream & ots, Type value)
@@ -221,5 +254,8 @@ template otexstream & operator<< <double>(otexstream &, double);
 template otexstream & operator<< <int>(otexstream &, int);
 template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
 template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
+#ifdef LYX_USE_LONG_LONG
+template otexstream & operator<< <unsigned long long>(otexstream &, unsigned long long);
+#endif
 
 }