C♯相談室 Part3
■ このスレッドは過去ログ倉庫に格納されています
0548デフォルトの名無しさん
NGNGiniを読むクラス。
class IniStream {
static Regex reSection = new Regex(@"^\[(?<name>\w+)\]$");
static Regex reItem = new Regex(@"^(?<name>[^=]+)=(?<value>.*)$");
Hashtable Read(TextReader r) {
Hashtable sections = new Hashtable();
StringDictionary section = null;
string line;
while((line=r.ReadLine())!=null) {
Match m = reSection.Match(line);
if(m.Count>0) {
section = new StringDictionary();
sections[m.Groups("name").Value] = section;
} else if(line.Length>0) {
m = reItem.Match(line);
section[m.Groups("name").Value] = m.Groups("value").Value;
}
}
return sections;
}
}
>>546
XMLなiniだったらXMLとして読めばいいんでないの?
■ このスレッドは過去ログ倉庫に格納されています