コード例 #1
0
 public void TestIsInclude()
 {
     Assert.IsTrue(IncludeFinder.IsInclude("#include <header.h>"));
     Assert.IsTrue(IncludeFinder.IsInclude(" #include \"header.h\""));
     Assert.IsTrue(IncludeFinder.IsInclude("\t#include \"header.h\""));
     Assert.IsFalse(IncludeFinder.IsInclude(""));
     Assert.IsFalse(IncludeFinder.IsInclude("include <header.h>"));
 }
コード例 #2
0
        /// <summary>
        /// Remove #include statements from C++ source.
        /// </summary>
        /// <param name="ioContents"></param>
        public void RemoveIncludes(ref string ioContents)
        {
            List <string> lines       = LineUtil.GetLineList(ioContents);
            StringBuilder output      = new StringBuilder();
            bool          add_newline = false;

            foreach (string line in lines)
            {
                if (add_newline)
                {
                    output.Append("\r\n");
                }
                add_newline = true;

                string trimmed_line = line.Trim();
                if (!IncludeFinder.IsInclude(line))
                {
                    output.Append(line);
                }
            }
            ioContents = output.ToString();
        }