2 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
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., 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <ZLInputStream.h>
22 #include "DocBookDescriptionReader.h"
24 DocBookDescriptionReader::DocBookDescriptionReader(BookDescription
&description
) : myDescription(description
) {
27 for (int i
= 0; i
< 3; ++i
) {
28 myReadAuthorName
[i
] = false;
30 myDescription
.language() = "en";
34 void DocBookDescriptionReader::characterDataHandler(const char *text
, int len
) {
36 myDescription
.title().append(text
, len
);
38 for (int i
= 0; i
< 3; ++i
) {
39 if (myReadAuthorName
[i
]) {
40 myAuthorNames
[i
].append(text
, len
);
47 void DocBookDescriptionReader::startElementHandler(int tag
, const char **) {
66 myReadAuthorName
[0] = true;
71 myReadAuthorName
[1] = true;
76 myReadAuthorName
[2] = true;
84 void DocBookDescriptionReader::endElementHandler(int tag
) {
91 myDescription
.addAuthor(myAuthorNames
[0], myAuthorNames
[1], myAuthorNames
[2]);
92 myAuthorNames
[0].erase();
93 myAuthorNames
[1].erase();
94 myAuthorNames
[2].erase();
98 myReadAuthorName
[0] = false;
101 myReadAuthorName
[1] = false;
104 myReadAuthorName
[2] = false;
111 bool DocBookDescriptionReader::readDescription(shared_ptr
<ZLInputStream
> stream
) {
112 return readDocument(stream
);