public static TabTableSection Parse(TextReader input) { _TabTableHead tableHead = new _TabTableHead(); TabTableSection root = new TabTableSection("root"); _TabTableRow tableRow = new _TabTableRow(tableHead); eStatus state = eStatus.ReadHead; while (true) { string row = input.ReadLine(); if (row == null) { break; } if (row.Trim().Length == 0) { continue; } char c = row[0]; if (c == '#' || c == ';') { continue; // ignore comment } switch (state) { case eStatus.ReadHead: tableHead.initHeads(row); state = eStatus.ReadType; break; case eStatus.ReadType: tableHead.initTypeDef(row); state = eStatus.ReadDefault; break; case eStatus.ReadDefault: tableHead.initDefaultValues(row); state = eStatus.ReadBody; break; case eStatus.ReadBody: tableRow.read(row); tableRow.convertToSection(root); break; default: break; } } return(root); }
public void convertToSection(TabTableSection root) { TabTableSection subRoot = root.createSection("item"); int index = 0; foreach (string key in m_tableHead.heads) { string val = m_values[index].Length > 0 ? m_values[index] : m_tableHead.getDefaultValue(index); index++; TabTableSection section = subRoot.createSection(key); section.value = val; } }