示例#1
0
        /// <summary>
        /// Read "Forward Declarations" of .h file and parse interface names
        /// </summary>
        /// <param name="lines">Content of .h file</param>
        /// <returns>InterfaceObject collection which has names</returns>
        public static Interfaces ParseInterfaceNames(List <string> lines)
        {
            LogHelper.Log("Start getting interfaces:");
            Interfaces interfaces = new Interfaces();

            const string sFlag = "/* Forward Declarations */";
            const string eFlag = "/* header files for imported files */";
            const string match = "typedef interface";
            const char   space = ' ';

            int i = 0;

            // Read till "Forward Declarations"
            while (i < lines.Count && lines[i] != sFlag)
            {
                i++;
                continue;
            }

            // Get interface name if that line contains key words "typedef interface"
            // Skip duplicated ones
            while (i < lines.Count && lines[i] != eFlag)
            {
                if (lines[i].Contains(match))
                {
                    string name = lines[i].Split(space)[2];

                    if (!interfaces.ContainsName(name))
                    {
                        interfaces.Add(name, null);
                    }
                }

                i++;
            }

            LogHelper.Log("Completed getting interfaces: {0} interfaces.", interfaces.Count);
            return(interfaces);
        }