ssc/data table.cs

43 lines
902 B
C#
Raw Normal View History

2015-12-07 13:15:02 +09:00
using arookas.IO.Binary;
using System.Collections;
using System.Collections.Generic;
namespace arookas
{
class sunDataTable : IEnumerable<string>
{
List<string> data = new List<string>(10);
public int Count { get { return data.Count; } }
public int Add(string value)
{
int index = data.IndexOf(value);
if (index < 0)
{
index = data.Count;
data.Add(value);
}
return index;
}
public void Clear() { data.Clear(); }
public void Write(aBinaryWriter writer)
{
int ofs = 0;
foreach (var value in this)
{
writer.WriteS32(ofs);
ofs += value.Length + 1; // include terminator
}
foreach (var value in this)
{
writer.WriteString(value, aBinaryStringFormat.NullTerminated);
}
}
public IEnumerator<string> GetEnumerator() { return data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
}
}