From 98148a5575db1f552cf0d26a87945f6b3c6de1ed Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Thu, 5 Dec 2024 17:49:32 +0100 Subject: [PATCH] add a Stream::new_empty() method --- src/log/log.cpp | 6 ++++++ src/log/log.h | 2 ++ src/textstream/stream.h | 4 ++++ src/textstream/textstream.h | 8 +++++++- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/log/log.cpp b/src/log/log.cpp index af5ed8f..2f40e91 100644 --- a/src/log/log.cpp +++ b/src/log/log.cpp @@ -79,6 +79,12 @@ bool Log::is_wchar_stream() const } +Log * Log::new_empty() const +{ + return new Log(); +} + + void Log::clear() { diff --git a/src/log/log.h b/src/log/log.h index 13cae96..1d93948 100644 --- a/src/log/log.h +++ b/src/log/log.h @@ -77,6 +77,8 @@ public: bool is_char_stream() const; bool is_wchar_stream() const; + Log * new_empty() const; + void clear(); bool empty() const; size_t size() const; diff --git a/src/textstream/stream.h b/src/textstream/stream.h index 69dd17f..a1bd4b8 100644 --- a/src/textstream/stream.h +++ b/src/textstream/stream.h @@ -61,6 +61,8 @@ public: virtual ~Stream() {}; + virtual Stream * new_empty() const = 0; + virtual bool is_char_stream() const = 0; virtual bool is_wchar_stream() const = 0; @@ -79,6 +81,8 @@ public: virtual char get_char(size_t index) const = 0; virtual wchar_t get_wchar(size_t index) const = 0; + virtual void escape_input(bool) {}; + virtual Stream & operator<<(const char * str) = 0; virtual Stream & operator<<(const std::string & str) = 0; virtual Stream & operator<<(const wchar_t * str) = 0; diff --git a/src/textstream/textstream.h b/src/textstream/textstream.h index f49a4e5..764d369 100644 --- a/src/textstream/textstream.h +++ b/src/textstream/textstream.h @@ -136,6 +136,8 @@ public: bool is_char_stream() const; bool is_wchar_stream() const; + TextStreamBase * new_empty() const; + void clear(); bool empty() const; size_t size() const; @@ -540,7 +542,11 @@ bool TextStreamBase::is_wchar_stream() c } - +template +TextStreamBase * TextStreamBase::new_empty() const +{ + return new TextStreamBase(); +} template