public static List <CStruct> parse(string sourcestring, string type) { List <CStruct> cslist = new List <CStruct>(); Regex re = new Regex(@"(typedef\s" + type + @"\s([^;]*?)\{(.*?)\})", RegexOptions.Singleline); MatchCollection mc = re.Matches(sourcestring); foreach (Match m in mc) { string name = m.Groups[2].Value.Trim(); CStruct cs = new CStruct(name); string itemsStr = m.Groups[3].Value; string itemsOneLine = Regex.Replace(itemsStr, @"\/\*(.*?)\*\/", Callback, RegexOptions.Singleline); string[] items = itemsOneLine.Split(new char[] { '\n' }); foreach (string item in items) { string itemTrimmed = item.Trim(); if (itemTrimmed.Length == 0) { continue; } CField cf = parseLine(itemTrimmed); if (cf != null) { cs.fields.Add(cf); } else { //Console.WriteLine("{0} is null", itemTrimmed); } } cslist.Add(cs); } return(cslist); }
// override object.Equals public override bool Equals(object obj) { CField o = (CField)obj; return(type == o.type && originalName == o.originalName && comment == o.comment); }