2 /// \file a_alxparser.cc
3 /// ALX file parser (for one file)
7 Copyright (C) 2010, Nicolas VIVIEN
8 Copyright (C) 2005-2010, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
27 #include "a_alxparser.h"
36 ALXParser::ALXParser(OSLoader
& osloader
, std::istream
& input
)
37 : XML::XMLParser(input
, "ISO-8859-1")
46 ALXParser::~ALXParser(void)
51 bool ALXParser::Run(const bool enable
)
55 return XMLParser::Run();
59 void ALXParser::on_start_document()
61 // std::cout << "on_start_document()" << std::endl;
65 void ALXParser::on_end_document()
67 // std::cout << "on_end_document()" << std::endl;
71 void ALXParser::on_start_element(const Glib::ustring
& name
,
72 const xmlpp::SaxParser::AttributeList
& attrs
)
89 if (name
== "system") {
92 else if (name
== "application") {
93 node
= IN_APPLICATION
;
95 m_codsection
= new Application(attrs
);
97 else if (name
== "library") {
100 m_codsection
= new Library(attrs
);
105 if (name
== "directory")
106 subnode
= IN_DIRECTORY
;
107 else if (name
== "osfiles") {
108 subnode
= IN_OSFILES
;
110 else if (name
== "application") {
111 node
= IN_SYSTEM_APPLICATION
;
114 m_codsection
= new Application();
116 else if (name
== "library") {
117 node
= IN_SYSTEM_LIBRARY
;
120 else if ((subnode
== IN_OSFILES
) && (name
== "os"))
121 osloader
.AddProperties(attrs
);
126 case IN_SYSTEM_APPLICATION
:
127 if (subnode
== SUB_NONE
) {
130 else if (name
== "description")
131 subnode
= IN_DESCRIPTION
;
132 else if (name
== "version")
133 subnode
= IN_VERSION
;
134 else if (name
== "vendor")
136 else if (name
== "copyright")
137 subnode
= IN_COPYRIGHT
;
138 else if (name
== "directory") {
139 if (osloader
.IsSupported(attrs
))
140 subnode
= IN_DIRECTORY
;
142 else if (name
== "language") {
143 if (osloader
.IsSupported(attrs
))
144 subnode
= IN_LANGUAGE_SUPPORTED
;
146 subnode
= IN_LANGUAGE
;
148 else if (name
== "required")
149 subnode
= IN_REQUIRED
;
150 else if (name
== "fileset") {
151 if (osloader
.IsSupported(attrs
))
152 subnode
= IN_FILESET
;
163 void ALXParser::on_end_element(const Glib::ustring
& name
)
173 if (name
== "loader")
178 if (name
== "system") {
185 if (name
== "directory")
190 if (name
== "osfiles")
192 else if (name
== "os")
193 osloader
.SetSFIFile(buffdata
);
202 case IN_SYSTEM_APPLICATION
:
203 if (name
== "application") {
205 osloader
.AddApplication(m_codsection
);
207 if (node
== IN_APPLICATION
)
209 else if (node
== IN_SYSTEM_APPLICATION
)
212 else if (name
== "library") {
214 osloader
.AddLibrary(m_codsection
);
216 if (node
== IN_LIBRARY
)
222 if (name
== "name") {
223 m_codsection
->SetName(buffdata
);
228 if (name
== "description") {
229 m_codsection
->SetDescription(buffdata
);
234 if (name
== "version") {
235 m_codsection
->SetVersion(buffdata
);
240 if (name
== "vendor") {
241 m_codsection
->SetVendor(buffdata
);
246 if (name
== "copyright") {
247 m_codsection
->SetCopyright(buffdata
);
252 if (name
== "directory") {
253 m_codsection
->SetDirectory(buffdata
);
258 if (name
== "language") {
262 case IN_LANGUAGE_SUPPORTED
:
263 if (name
== "language") {
266 else if (name
== "name") {
267 m_codsection
->SetName(buffdata
);
271 if (name
== "required") {
273 m_codsection
->SetRequired(buffdata
);
277 if (name
== "fileset") {
280 else if (name
== "files") {
281 m_codsection
->AddFiles(buffdata
);
296 void ALXParser::on_characters(const Glib::ustring
& data
)
298 buffdata
.append(data
);
302 void ALXParser::on_comment(const Glib::ustring
& text
)
304 // std::cout << "on_comment(): " << text << std::endl;
308 void ALXParser::on_warning(const Glib::ustring
& text
)
310 // std::cout << "on_warning(): " << text << std::endl;
314 void ALXParser::on_error(const Glib::ustring
& text
)
316 // std::cout << "on_error(): " << text << std::endl;
320 void ALXParser::on_fatal_error(const Glib::ustring
& text
)
322 std::cout
<< "on_fatal_error(): " << text
<< std::endl
;