public CSVThread ParseLine(string aLine) { CSVThread ret = null; // Match m = KParserRegEx.Match(aLine); if (m.Success) { ret = CSVThread.New(); // string[] items = m.Value.Split(','); if (items.Length >= KExpectedItemCount) { // Ensure each item is trimmed before processing for (int i = 0; i < items.Length; i++) { items[i] = items[i].Trim(); } try { // THREAD ret.ThreadName = items[0]; // CHUNK ret.ChunkName = items[1]; ret.ChunkBaseAddress = ParseHexValue(items[2]); // HEAP ret.SizeCurrent = ParseDecimalValue(items[3]); ret.SizeMin = ParseDecimalValue(items[4]); ret.SizeMax = ParseDecimalValue(items[5]); // FIRST FREE CELL ret.FirstFreeCellAddress = ParseHexValue(items[6]); ret.FirstFreeCellLength = ParseDecimalValue(items[7]); // OTHER FREE CELL INFO ret.FreeCellCount = ParseDecimalValue(items[8]); ret.FreeSpaceTotal = ParseDecimalValue(items[9]); ret.FreeSpaceSlack = ParseDecimalValue(items[10]); ret.FreeCellLargest = ParseDecimalValue(items[11]); // ALLOC CELL INFO ret.AllocCellLargest = ParseDecimalValue(items[12]); ret.AllocCellCount = ParseDecimalValue(items[13]); ret.AllocSpaceTotal = ParseDecimalValue(items[15]); // MISC ret.MinCellSize = ParseDecimalValue(items[14]); } catch (Exception) { ret = null; } } } return(ret); }
private bool TryToParseEntry(string aLine) { Match matchEntry = KRegExEntry.Match(aLine); if (matchEntry.Success) { // Check if it's an opening or closing tag. bool isOpen = string.IsNullOrEmpty(matchEntry.Groups["TagType"].Value); int index = int.Parse(matchEntry.Groups["Index"].Value); if (isOpen) { // Opening tag - starting a new entry, save entry id ChangeState(TState.EStateSeenEntryStart); SaveCurrentEntryIfValidState(); iCurrentEntryId = index; iWorkInProgressThread = CSVThread.New(); } else { // Closing tag, we should've finished an entry now. // Validate the index is as we expect CheckExpectedIndexId(index); ChangeState(TState.EStateSeenEntryEnd); SaveCurrentEntryIfValidState(); } } return(matchEntry.Success); }