diff options
author | Jon Skeet <skeet@pobox.com> | 2008-10-02 21:46:17 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2008-10-02 21:46:17 +0100 |
commit | 7f90d8ee57d4af4215bc31dbb07726c023c5e047 (patch) | |
tree | 9a892e6f6f68e4a75c5e766d95e4cd42857b1bc6 /csharp/ProtocolBuffers/TextGenerator.cs | |
parent | 7fd62ffd77ccedfc6dbe2384901b375859b726b6 (diff) |
Made things a bit more public for the sake of ProtoGen
Diffstat (limited to 'csharp/ProtocolBuffers/TextGenerator.cs')
-rw-r--r-- | csharp/ProtocolBuffers/TextGenerator.cs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/csharp/ProtocolBuffers/TextGenerator.cs b/csharp/ProtocolBuffers/TextGenerator.cs index 24961570..3cb8b490 100644 --- a/csharp/ProtocolBuffers/TextGenerator.cs +++ b/csharp/ProtocolBuffers/TextGenerator.cs @@ -20,9 +20,9 @@ using System.Text; namespace Google.ProtocolBuffers { /// <summary> - /// Helper class to control indentation + /// Helper class to control indentation. Used for TextFormat and by ProtoGen. /// </summary> - internal sealed class TextGenerator { + public sealed class TextGenerator { /// <summary> /// Writer to write formatted text to. @@ -40,9 +40,10 @@ namespace Google.ProtocolBuffers { readonly StringBuilder indent = new StringBuilder(); /// <summary> - /// Creates a generator writing to the given writer. + /// Creates a generator writing to the given writer. The writer + /// is not closed by this class. /// </summary> - internal TextGenerator(TextWriter writer) { + public TextGenerator(TextWriter writer) { this.writer = writer; } @@ -51,20 +52,33 @@ namespace Google.ProtocolBuffers { /// will be inserted at the beginning of each line of text. Indent() may /// be called multiple times to produce deeper indents. /// </summary> - internal void Indent() { + public void Indent() { indent.Append(" "); } /// <summary> /// Reduces the current indent level by two spaces. /// </summary> - internal void Outdent() { + public void Outdent() { if (indent.Length == 0) { throw new InvalidOperationException("Too many calls to Outdent()"); } indent.Length -= 2; } + public void WriteLine(string text) { + Print(text); + Print("\n"); + } + + public void WriteLine(string format, params object[] args) { + WriteLine(string.Format(format, args)); + } + + public void WriteLine() { + WriteLine(""); + } + /// <summary> /// Prints the given text to the output stream, indenting at line boundaries. /// </summary> |