Opentk/Source/Bind/BindStreamWriter.cs
the_fiddler f5db25f32c Enhanced BindStreamWriter.Indent() and Unindent() implementation (they now change a simple counter).
Suppressed warning CS0649 (uninitialised field) in generated code for delegates.
2007-09-21 19:59:22 +00:00

67 lines
1.5 KiB
C#

#region --- License ---
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
* See license.txt for license info
*/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Bind.Structures;
using System.Text.RegularExpressions;
namespace Bind
{
class BindStreamWriter : StreamWriter
{
int indent_level = 0;
Regex splitLines = new Regex(System.Environment.NewLine, RegexOptions.Compiled);
public BindStreamWriter(string file)
: base(file)
{
}
private string indent = "";
public void Indent()
{
++indent_level;
}
public void Unindent()
{
if (indent_level > 0)
--indent_level;
}
public override void Write(string value)
{
for (int i = indent_level; i > 0; i--)
base.Write(" ");
base.Write(value);
}
public override void WriteLine(string value)
{
for (int i = indent_level; i > 0; i--)
base.Write(" ");
base.WriteLine(value);
}
public void Write(Bind.Structures.Enum e)
{
foreach (string s in splitLines.Split(e.ToString()))
WriteLine(s);
}
public void Write(Bind.Structures.Function f)
{
foreach (string s in splitLines.Split(f.ToString()))
WriteLine(s);
}
}
}