13 Project::Project(const string
& filename
)
15 if ( !xmlfile
.open ( filename
) )
16 throw FileNotFoundException ( filename
);
22 for ( size_t i
= 0; i
< modules
.size(); i
++ )
26 void Project::ReadXml()
29 bool projectFound
= false;
32 XMLElement
* head
= XMLParse ( xmlfile
, path
);
34 throw InvalidBuildFileException ( "Document contains no 'project' tag." );
36 if ( head
->name
!= "project" )
38 throw InvalidBuildFileException ( "Expected 'project', got '%s'.",
42 this->ProcessXML ( *head
, "." );
45 } while (!projectFound
);
49 Project::ProcessXML ( const XMLElement
& e
, const string
& path
)
51 const XMLAttribute
*att
;
53 if ( e
.name
== "project" )
55 att
= e
.GetAttribute ( "name", false );
61 else if ( e
.name
== "module" )
63 att
= e
.GetAttribute ( "name", true );
66 Module
* module
= new Module ( e
, att
->value
, path
);
67 modules
.push_back ( module
);
68 module
->ProcessXML ( e
, path
);
71 else if ( e
.name
== "directory" )
73 // this code is duplicated between Project::ProcessXML() and Module::ProcessXML() :(
74 const XMLAttribute
* att
= e
.GetAttribute ( "name", true );
77 subpath
= path
+ "/" + att
->value
;
79 for ( size_t i
= 0; i
< e
.subElements
.size(); i
++ )
80 ProcessXML ( *e
.subElements
[i
], subpath
);