GeneratorOutputs.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Sources/SwiftProtobufPluginLibrary/GeneratorOutputs.swift
  2. //
  3. // Copyright (c) 2014 - 2023 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. ///
  11. /// This provides the basic interface for providing the generation outputs.
  12. ///
  13. // -----------------------------------------------------------------------------
  14. import Foundation
  15. /// Abstract interface for receiving generation outputs.
  16. public protocol GeneratorOutputs {
  17. /// Add the a file with the given `name` and `contents` to the outputs.
  18. ///
  19. /// - Parameters:
  20. /// - fileName: The name of the file.
  21. /// - contents: The body of the file.
  22. ///
  23. /// - Throws May throw errors for duplicate file names or any other problem.
  24. /// Generally `CodeGenerator`s do *not* need to catch these, and instead
  25. /// they are ripple all the way out to the code calling the
  26. /// `CodeGenerator`.
  27. func add(fileName: String, contents: String) throws
  28. // TODO: Consider adding apis to stream things like C++ protobuf does?
  29. }