Have Makefile.auto depend on xml build files
[reactos.git] / reactos / tools / rbuild / XML.h
1 #ifndef XML_H
2 #define XML_H
3
4 #include "pch.h"
5
6 class XMLElement;
7
8 void
9 InitWorkingDirectory();
10
11 #ifdef _MSC_VER
12 unsigned __int64
13 #else
14 unsigned long long
15 #endif
16 filelen ( FILE* f );
17
18 class Path
19 {
20 std::vector<std::string> path;
21 public:
22 Path(); // initializes path to getcwd();
23 Path ( const Path& cwd, const std::string& filename );
24 std::string Fixup ( const std::string& filename, bool include_filename ) const;
25
26 std::string RelativeFromWorkingDirectory ();
27 static std::string RelativeFromWorkingDirectory ( const std::string& path );
28
29 static void Split ( std::vector<std::string>& out,
30 const std::string& path,
31 bool include_last );
32 };
33
34 class XMLInclude
35 {
36 public:
37 XMLElement *e;
38 Path path;
39 std::string topIncludeFilename;
40 bool fileExists;
41
42 XMLInclude ( XMLElement* e_, const Path& path_, const std::string topIncludeFilename_ )
43 : e ( e_ ), path ( path_ ), topIncludeFilename ( topIncludeFilename_ )
44 {
45 }
46 };
47
48 class XMLIncludes : public std::vector<XMLInclude*>
49 {
50 public:
51 ~XMLIncludes();
52 };
53
54 class XMLFile
55 {
56 friend class XMLElement;
57 public:
58 XMLFile();
59 void close();
60 bool open(const std::string& filename);
61 void next_token();
62 bool next_is_text();
63 bool more_tokens();
64 bool get_token(std::string& token);
65 const std::string& filename() { return _filename; }
66 std::string Location() const;
67
68 private:
69 std::string _buf, _filename;
70
71 const char *_p, *_end;
72 };
73
74
75 class XMLAttribute
76 {
77 public:
78 std::string name;
79 std::string value;
80
81 XMLAttribute();
82 XMLAttribute ( const std::string& name_, const std::string& value_ );
83 XMLAttribute ( const XMLAttribute& );
84 XMLAttribute& operator = ( const XMLAttribute& );
85 };
86
87
88 class XMLElement
89 {
90 public:
91 std::string location;
92 std::string name;
93 std::vector<XMLAttribute*> attributes;
94 XMLElement* parentElement;
95 std::vector<XMLElement*> subElements;
96 std::string value;
97
98 XMLElement ( const std::string& location_ );
99 ~XMLElement();
100 bool Parse(const std::string& token,
101 bool& end_tag);
102 void AddSubElement ( XMLElement* e );
103 XMLAttribute* GetAttribute ( const std::string& attribute,
104 bool required);
105 const XMLAttribute* GetAttribute ( const std::string& attribute,
106 bool required) const;
107 };
108
109 XMLElement*
110 XMLLoadFile ( const std::string& filename,
111 const Path& path,
112 XMLIncludes& includes );
113
114 #endif // XML_H