public void WriteHeaderFile(CSourceFile parsedFile, Stream outStream) { using (var writer = new StreamWriter(outStream)) { using (var includeGuardWriter = new IncludeGuardWriter(writer, this.IncludeGuard)) { WriteHeaderComment(writer, this.HeaderComment); parsedFile.WritePPDefinitions(writer); parsedFile.WriteDeclarations(writer, this.IncludeStaticFunctions, this.IncludeExternFunctions); } } }
/// <summary> /// Writer the parsed source file to the output file /// </summary> /// <param name="showIncludeGuard">Whether to surround the header file in an include guard</param> /// <param name="codeWriter">The code writer object</param> /// <param name="headerFileName">The name of the header file to produce</param> /// <param name="c">The parse source file</param> private static void WriteToHeaderFile(bool showIncludeGuard, CHeaderFileWriter codeWriter, string headerFileName, CSourceFile c) { if (showIncludeGuard) codeWriter.IncludeGuard = new Regex(@"[^A-Z0-9_]").Replace(string.Format("__{0}__", Path.GetFileName(headerFileName).ToUpperInvariant()), "_"); else codeWriter.IncludeGuard = null; using (var stream = File.Open(headerFileName, FileMode.Create)) { codeWriter.WriteHeaderFile(c, stream); } }