/// <summary> /// Outputs the VHDL representation of a <code>VhdlElement</code> to a <code>Writer</code> using a custom code format. /// </summary> /// <param name="element">the VHDL element</param> /// <param name="format">the custom code format</param> /// <param name="writer">the <code>Writer</code></param> public static void toWriter(VhdlElement element, IVhdlCodeFormat format, StreamWriter writer) { VhdlWriter vhdlWriter = new VhdlWriter(writer, format); OutputModule output = new VhdlOutputModule(vhdlWriter); output.writeVhdlElement(element); }
/// <summary> /// Writes the VHDL representation of a <code>VhdlElement</code> to a file using a custom code format. /// </summary> /// <param name="element">the VHDL element</param> /// <param name="format">the custom code format</param> /// <param name="fileName">the name of the file</param> public static void toFile(VhdlElement element, IVhdlCodeFormat format, string fileName) { FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write); StreamWriter writer = new StreamWriter(stream); toWriter(element, format, writer); writer.Close(); stream.Close(); }
/// <summary> /// Converts a <code>VhdlElement</code> to a string using a custom code format. /// </summary> /// <param name="element">the VHDL element</param> /// <param name="format">the custom code format</param> /// <returns>the converted string</returns> public static string toVhdlString(VhdlElement element, IVhdlCodeFormat format) { MemoryStream stream = new MemoryStream(); StreamWriter stringWriter = new StreamWriter(stream); try { toWriter(element, format, stringWriter); } catch (IOException ex) { //shouldn't happen for a string writer throw new ArgumentException(); } stringWriter.Close(); StreamReader reader = new StreamReader(stream); string res = reader.ReadToEnd(); reader.Close(); stream.Close(); return(res); }
/// <summary> /// Prints the VHDL representation of a <code>VhdlElement</code> to <code>System.out</code> using /// a custom code format. /// </summary> /// <param name="element">the VHDL element</param> /// <param name="format">the custom code format</param> public static void print(VhdlElement element, IVhdlCodeFormat format) { Console.WriteLine(toVhdlString(element, format)); }
/// <summary> /// Creates a vhdl writer adapter. /// </summary> /// <param name="out">the base writer</param> /// <param name="format">the code format</param> public VhdlWriter(StreamWriter @out, IVhdlCodeFormat format) { this.@out = @out; this.format = format; }