2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 extern std::string working_directory
;
28 InitWorkingDirectory();
39 std::vector
<std::string
> path
;
41 Path(); // initializes path to getcwd();
42 Path ( const Path
& cwd
, const std::string
& filename
);
43 std::string
Fixup ( const std::string
& filename
, bool include_filename
) const;
45 std::string
RelativeFromWorkingDirectory ();
46 static std::string
RelativeFromWorkingDirectory ( const std::string
& path
);
47 static std::string
RelativeFromDirectory ( const std::string
& path
, const std::string
& base_directory
);
49 static void Split ( std::vector
<std::string
>& out
,
50 const std::string
& path
,
59 std::string topIncludeFilename
;
62 XMLInclude ( XMLElement
* e_
, const Path
& path_
, const std::string topIncludeFilename_
)
63 : e ( e_
), path ( path_
), topIncludeFilename ( topIncludeFilename_
)
68 class XMLIncludes
: public std::vector
<XMLInclude
*>
76 friend class XMLElement
;
80 bool open(const std::string
& filename
);
84 bool get_token ( std::string
& token
);
85 bool get_token ( std::string
& token
, std::string
& location
);
86 const std::string
& filename() { return _filename
; }
87 std::string
Location() const;
90 std::string _buf
, _filename
;
92 const char *_p
, *_end
;
103 XMLAttribute ( const std::string
& name_
, const std::string
& value_
);
104 XMLAttribute ( const XMLAttribute
& );
105 XMLAttribute
& operator = ( const XMLAttribute
& );
113 std::string location
;
115 std::vector
<XMLAttribute
*> attributes
;
116 XMLElement
* parentElement
;
117 std::vector
<XMLElement
*> subElements
;
120 XMLElement ( XMLFile
* xmlFile
,
121 const std::string
& location
);
123 bool Parse(const std::string
& token
,
125 void AddSubElement ( XMLElement
* e
);
126 XMLAttribute
* GetAttribute ( const std::string
& attribute
,
128 const XMLAttribute
* GetAttribute ( const std::string
& attribute
,
129 bool required
) const;
133 XMLLoadFile ( const std::string
& filename
,
135 XMLIncludes
& includes
);