1 using System;
 2 using System.XPath;
 3 using System.Dom;
 4 using System.Collections;
 5 using System.IO;
 6 
 7 namespace soulcm.scm2html
 8 {
 9     public class Scm2htmlXml
10     {
11         public Scm2htmlXml(const string& scm2htmlFilePath_) : 
12             scm2HtmlFilePath(scm2htmlFilePath_)rootDir(Path.GetDirectoryName(GetFullPath(scm2HtmlFilePath)))
13         {
14         }
15         public void Process(bool verbose)
16         {
17             this->verbose = verbose;
18             if (verbose)
19             {
20                 Console.Out() << "> " << scm2HtmlFilePath << endl();
21             }
22             scm2htmlDoc = ReadDocument(scm2HtmlFilePath);
23             ReadProjects();
24             ProcessProjects();
25         }
26         public void ReadProjects()
27         {
28             UniquePtr<XPathObject> result = Evaluate(u"/scm2html/project"scm2htmlDoc.Get());
29             if (!result.IsNull())
30             {
31                 if (result.Get() is XPathNodeSet*)
32                 {
33                     XPathNodeSet* nodeSet = cast<XPathNodeSet*>(result.Get());
34                     int n = nodeSet->Length();
35                     for (int i = 0; i < n; ++i;)
36                     {
37                         Node* node = (*nodeSet)[i];
38                         if (node is Element*)
39                         {
40                             Element* element = cast<Element*>(node);
41                             projects.Add(UniquePtr<Project>(new Project(thiselement)));
42                         }
43                     }
44                 }
45             }
46         }
47         public void ProcessProjects()
48         {
49             for (const UniquePtr<Project>& project : projects)
50             {
51                 project->Process(verbose);
52             }
53         }
54         public inline nothrow const string& RootDir() const
55         {
56             return rootDir;
57         }
58         private bool verbose;
59         private string scm2HtmlFilePath;
60         private string rootDir;
61         private UniquePtr<Document> scm2htmlDoc;
62         private List<UniquePtr<Project>> projects;
63     }
64 } // namespace soulcm.scm2html