Exemple #1
0
 /// <summary>
 /// Helper function for AddMocStep.
 /// </summary>
 /// <param name="file">header or source file name</param>
 /// <returns>True, if the file contains an include of the
 /// corresponding moc_xxx.cpp file. False in all other cases</returns>
 public bool IsMoccedFileIncluded(VCFile file)
 {
     bool isHeaderFile = HelperFunctions.HasHeaderFileExtension(file.FullPath);
     if (isHeaderFile || HelperFunctions.HasSourceFileExtension(file.FullPath))
     {
         string srcName;
         if (isHeaderFile)
             srcName = file.FullPath.Substring(0, file.FullPath.LastIndexOf(".")) + ".cpp";
         else
             srcName = file.FullPath;
         VCFile f = GetFileFromProject(srcName);
         CxxStreamReader sr = null;
         if (f != null)
         {
             try
             {
                 string strLine;
                 sr = new CxxStreamReader(f.FullPath);
                 string baseName = file.Name.Substring(0, file.Name.LastIndexOf("."));
                 while ((strLine = sr.ReadLine()) != null)
                 {
                     if (strLine.IndexOf("#include \"moc_" + baseName + ".cpp\"") != -1 ||
                         strLine.IndexOf("#include <moc_" + baseName + ".cpp>") != -1)
                     {
                         sr.Close();
                         return true;
                     }
                 }
                 sr.Close();
             }
             catch (System.Exception)
             {
                 // do nothing
                 if (sr != null)
                     sr.Close();
                 return false;
             }
         }
     }
     return false;
 }
        public static bool CxxFileContainsNotCommented(VCFile file, string[] searchStrings, bool caseSensitive, bool suppressStrings)
        {
            if (!caseSensitive)
                for (int i = 0; i < searchStrings.Length; ++i)
                    searchStrings[i] = searchStrings[i].ToLower();

            CxxStreamReader sr = null;
            bool found = false;
            try
            {
                string strLine;
                sr = new CxxStreamReader(file.FullPath);
                while (!found && (strLine = sr.ReadLine(suppressStrings)) != null)
                {
                    if (!caseSensitive)
                        strLine = strLine.ToLower();
                    foreach (string str in searchStrings)
                    {
                        if (strLine.IndexOf(str) != -1)
                        {
                            found = true;
                            break;
                        }
                    }
                }
                sr.Close();
            }
            catch (System.Exception)
            {
                if (sr != null)
                    sr.Close();
            }
            return found;
        }