Copy wininet to branch
[reactos.git] / reactos / tools / rbuild / stubbedcomponent.cpp
1 #include "pch.h"
2 #include <assert.h>
3
4 #include "rbuild.h"
5
6 using std::string;
7 using std::vector;
8
9 StubbedComponent::StubbedComponent ( const Module* module_,
10 const XMLElement& stubbedComponentNode )
11 : module(module_),
12 node(stubbedComponentNode)
13 {
14 const XMLAttribute* att = node.GetAttribute ( "name", true );
15 assert ( att );
16 name = att->value;
17 }
18
19 StubbedComponent::~StubbedComponent ()
20 {
21 for ( size_t i = 0; i < symbols.size(); i++ )
22 delete symbols[i];
23 }
24
25 void
26 StubbedComponent::ProcessXML ()
27 {
28 size_t i;
29 for ( i = 0; i < node.subElements.size (); i++ )
30 ProcessXMLSubElement ( *node.subElements[i] );
31 for ( i = 0; i < symbols.size (); i++ )
32 symbols[i]->ProcessXML ();
33 }
34
35 void
36 StubbedComponent::ProcessXMLSubElement ( const XMLElement& e )
37 {
38 bool subs_invalid = false;
39 if ( e.name == "symbol" )
40 {
41 symbols.push_back ( new StubbedSymbol ( e ) );
42 subs_invalid = false;
43 }
44 if ( subs_invalid && e.subElements.size () > 0 )
45 throw InvalidBuildFileException (
46 e.location,
47 "<%s> cannot have sub-elements",
48 e.name.c_str() );
49 for ( size_t i = 0; i < e.subElements.size (); i++ )
50 ProcessXMLSubElement ( *e.subElements[i] );
51 }
52
53
54
55 StubbedSymbol::StubbedSymbol ( const XMLElement& stubbedSymbolNode )
56 : node(stubbedSymbolNode)
57 {
58 }
59
60 StubbedSymbol::~StubbedSymbol ()
61 {
62 }
63
64 void
65 StubbedSymbol::ProcessXML ()
66 {
67 if ( node.value.size () == 0 )
68 {
69 throw InvalidBuildFileException (
70 node.location,
71 "<symbol> is empty." );
72 }
73 symbol = node.value;
74
75 const XMLAttribute* att = node.GetAttribute ( "newname", false );
76 if ( att != NULL )
77 newname = att->value;
78 else
79 newname = symbol;
80 }