X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftexstream.h;h=2cfcd16da40379e3d9ad40147e56bd232a9fa205;hb=7a7c2117bfb2037495f2642555651962851a9bba;hp=53040d1b7f4745c036e3ed213ee4aef4a2a87e06;hpb=3fd2398a28c8d2c85d1bb2c33c6ca15bfc398b54;p=lyx.git diff --git a/src/texstream.h b/src/texstream.h index 53040d1b7f..2cfcd16da4 100644 --- a/src/texstream.h +++ b/src/texstream.h @@ -18,11 +18,9 @@ namespace lyx { class TexRow; +struct TexString; -// declared below -class otexstringstream; - /** Wrapper class for odocstream. This class is used to automatically count the lines of the exported latex code. @@ -43,7 +41,7 @@ public: /// void put(char_type const & c); /// - void append(docstring const & str, TexRow texrow); + void append(TexString ts); private: /// odocstream & os_; @@ -54,6 +52,8 @@ private: /// otexrowstream & operator<<(otexrowstream &, odocstream_manip); /// +otexrowstream & operator<<(otexrowstream &, TexString); +/// otexrowstream & operator<<(otexrowstream &, docstring const &); /// otexrowstream & operator<<(otexrowstream &, std::string const &); @@ -81,10 +81,13 @@ public: /// explicit otexstream(odocstream & os) : otexrowstream(os), canbreakline_(false), - protectspace_(false), parbreak_(true), lastchar_(0) {} + protectspace_(false), terminate_command_(false), + parbreak_(true), lastchar_(0) {} /// void put(char_type const & c); /// + void append(TexString ts); + /// void canBreakLine(bool breakline) { canbreakline_ = breakline; } /// bool canBreakLine() const { return canbreakline_; } @@ -93,6 +96,10 @@ public: /// bool protectSpace() const { return protectspace_; } /// + void terminateCommand(bool terminate) { terminate_command_ = terminate; } + /// + bool terminateCommand() const { return terminate_command_; } + /// void lastChar(char_type const & c) { parbreak_ = (!canbreakline_ && c == '\n'); @@ -109,11 +116,32 @@ private: /// bool protectspace_; /// + bool terminate_command_; + /// bool parbreak_; /// char_type lastchar_; }; + +/// because we need to pass ods_ to the base class +struct otexstringstream_helper { odocstringstream ods_; }; + +/// otexstringstream : a odocstringstream with tex/row correspondence +class otexstringstream : otexstringstream_helper, public otexstream { +public: + otexstringstream() : otexstringstream_helper(), otexstream(ods_) {} + /// + docstring str() const { return ods_.str(); } + /// + size_t length(); + /// + bool empty() { return 0 == length(); } + /// move-returns the contents and reset the texstream + TexString release(); +}; + + /// Helper structs for breaking a line struct BreakLine { char n; @@ -123,16 +151,26 @@ struct SafeBreakLine { char n; }; +/// Helper structs for terminating a command +struct TerminateCommand { + char n; +}; + extern BreakLine breakln; extern SafeBreakLine safebreakln; +extern TerminateCommand termcmd; /// otexstream & operator<<(otexstream &, BreakLine); /// otexstream & operator<<(otexstream &, SafeBreakLine); /// +otexstream & operator<<(otexstream &, TerminateCommand); +/// otexstream & operator<<(otexstream &, odocstream_manip); /// +otexstream & operator<<(otexstream &, TexString); +/// otexstream & operator<<(otexstream &, docstring const &); /// otexstream & operator<<(otexstream &, std::string const &); @@ -145,6 +183,6 @@ template otexstream & operator<<(otexstream & ots, Type value); -} +} // namespace lyx #endif