Пример #1
0
        //============================================================
        // <T>将被选择的文件解析为类对象数组,并解析出代码在编译器外的警告或者错误。</T>
        //
        // @param indextable 从.h文件中解析出来的类与头文件对应的MAP表
        // @param putPath XML文档的输出路径
        // @param swPrint StringWriter对象用来输出警告或者错误。
        // @param fileCpp 当前解析的文件
        // @param relativePath 被选择解析的文件夹路径
        //============================================================
        public void ParserFileCpp(FileInfo fileCpp, FCppClassesIndexTable indextable, string outPath, string relativePath, StreamWriter swPrint)
        {
            FStrings           strLines = FCppParser.GetLines(fileCpp.FullName);
            string             strClass = string.Empty;
            FArray <FCppClass> classArr = new FArray <FCppClass>();
            int start, end = CheckParaAnnotate(strLines, 0, out start);

            for (int n = 0; n < strLines.Count; n++)
            {
                if (IsInInterregional(n, start, end))
                {
                    continue;
                }
                if (FCppMethod.IsMethodInCpp(strLines, n))
                {
                    FCppMethod method   = new FCppMethod(strLines, n, GetPairNum(strLines, n));
                    string     classStr = GetClassInCpp(strLines, n);
                    strClass = classStr;
                    FFileNode node      = MakeNode(strLines, GetClassInCpp(strLines, n));
                    string    fileHpath = indextable.LookInMap(node);
                    if (fileHpath == "")
                    {
                        continue;
                    }
                    FCppClass cppClass = ParserFileH(fileHpath, classStr);
                    int       index    = ExistNo(classArr, cppClass);
                    if (index != -1)
                    {
                        classArr.Get(index).Method.Add(method);
                    }
                    else
                    {
                        cppClass.Method.Add(method);
                        classArr.Add(cppClass);
                    }
                }
            }
            ProduceXMLFile(classArr, outPath, swPrint, fileCpp, relativePath);
            if (strLines[strLines.Count - 1].Trim() != "")
            {
                string errID = "CPP07CL06E" + strLines.Count.ToString() + "L";
                string path  = fileCpp.FullName.Substring(relativePath.Length);
                string error = "[错误][" + errID.PadRight(16) + "][" + path + "(" + strLines.Count.ToString().PadRight(5) + ")]";
                swPrint.WriteLine(error);
            }
        }
Пример #2
0
        //============================================================
        // <T>在MAP表中查找对应值。</T>
        //
        // @param filenode 在文件中生成的查找节点。
        // @return 查找到的值
        //============================================================
        public string LookInMap(FFileNode filenode)
        {
            FArray <string> heads = new FArray <string>();

            heads = filenode.HeadHS;
            string classstr = filenode.ClassStr;

            foreach (string head in heads)
            {
                if (_classesMap.Contains(head))
                {
                    if (_classesMap[head].Contains(classstr))
                    {
                        return(_classesMap[head][0].Trim());
                    }
                }
            }
            return(string.Empty);
        }