From 6dd7d19165e51bc8473fb132c2574b1f42e890cd Mon Sep 17 00:00:00 2001 From: triton Date: Sun, 14 Jul 2013 19:32:03 +0100 Subject: [PATCH] Add support for deep cloning TextGenerator instances. --- src/Generator/Utils/TextGenerator.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Generator/Utils/TextGenerator.cs b/src/Generator/Utils/TextGenerator.cs index c2083734..5a205c89 100644 --- a/src/Generator/Utils/TextGenerator.cs +++ b/src/Generator/Utils/TextGenerator.cs @@ -21,6 +21,19 @@ namespace CppSharp CurrentIndent = new Stack(); } + public TextGenerator(TextGenerator generator) + { + StringBuilder = new StringBuilder(generator); + IsStartOfLine = generator.IsStartOfLine; + NeedsNewLine = generator.NeedsNewLine; + CurrentIndent = new Stack(generator.CurrentIndent); + } + + public TextGenerator Clone() + { + return new TextGenerator(this); + } + public void Write(string msg, params object[] args) { if (string.IsNullOrEmpty(msg))