Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        // override object.Equals
        public override bool Equals(object obj)
        {
            CField o = (CField)obj;

            return(type == o.type && originalName == o.originalName && comment == o.comment);
        }