gui
[lbook_fbreader.git] / fbreader / src / formats / openreader / ORBookReader.h
blob08f568841ccb4c19393ea82959a88f7e6a630ec9
1 /*
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
17 * 02110-1301, USA.
20 #ifndef __ORBOOKREADER_H__
21 #define __ORBOOKREADER_H__
23 #include <map>
24 #include <set>
25 #include <vector>
26 #include <string>
28 #include <ZLXMLReader.h>
30 #include "../../bookmodel/BookReader.h"
32 class ORBookReader : public ZLXMLReader {
34 public:
35 ORBookReader(BookModel &model);
36 bool readBook(const std::string &fileName);
38 void startElementHandler(const char *tag, const char **attributes);
39 void endElementHandler(const char *tag);
40 void characterDataHandler(const char *text, int len);
42 private:
43 enum ReaderState {
44 READ_NONE,
45 READ_RESOURCES,
46 READ_USERSET,
47 READ_NAVIGATION,
48 READ_POINTER,
49 READ_TOCTITLE
52 BookReader myModelReader;
53 ReaderState myState;
55 std::string myFilePrefix;
56 std::map<std::string,std::string> myResources;
57 std::string myCoverReference;
58 std::set<std::string> myHtmlFileIDs;
59 std::map<std::string,std::string> myImageIDs;
60 std::vector<std::string> myHtmlFilesOrder;
62 struct TOCItem {
63 TOCItem(const std::string &reference, const std::string &text, int level) : Reference(reference), Text(text), Level(level) {
66 std::string Reference;
67 std::string Text;
68 int Level;
70 std::vector<TOCItem> myTOC;
72 std::string myTOCReference;
73 int myTOCLevel;
74 std::string myTOCTitle;
77 #endif /* __ORBOOKREADER_H__ */