aboutsummaryrefslogtreecommitdiff
path: root/src/ProtoGen/SourceFileGenerator.cs
blob: b5bd5efbed69de4e8fd2930ee44dfad7d8ff5734 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.IO;

namespace Google.ProtocolBuffers.ProtoGen {
  /// <summary>
  /// Generator to hold a TextGenerator, generate namespace aliases etc.
  /// Each source file created uses one of these, and it can be used to create
  /// multiple classes within the same file.
  /// </summary>
  internal class SourceFileGenerator  {

    private readonly TextGenerator output;

    private SourceFileGenerator(TextWriter writer) {
      output = new TextGenerator(writer);
    }

    /// <summary>
    /// Creates a ClassFileGenerator for the given writer, which will be closed
    /// when the instance is disposed. The specified namespace is created, if it's non-null.
    /// </summary>
    internal static SourceFileGenerator ForWriter(TextWriter writer) {
      return new SourceFileGenerator(writer);
    }
  }
}