ScummVM API documentation
html_parser.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  *
21  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_HTML_PARSER_H
29 #define GOB_HTML_PARSER_H
30 
31 #include "common/hashmap.h"
32 #include "common/str.h"
33 
34 #include "gob/gob.h"
35 
36 namespace Common {
37 class SeekableReadStream;
38 }
39 
40 namespace Gob {
41 
42 struct HtmlMark {
43  uint32 _field_0;
44  uint32 _field_4;
45  uint32 _field_8;
46  uint32 _field_C;
47  uint32 _pos;
48  uint32 _field_14[5];
49  uint32 _field_28;
50 };
51 
52 
53 class HtmlContext {
54 public:
56  ~HtmlContext();
57 
58  void seekCommand(Common::String command, Common::String commandArg, uint16 destVar);
59  void nextKeyword(uint16 destVar, uint16 destVarTagType);
60 
61 private:
62  enum HtmlTagType {
63  kHtmlTagType_None = -1,
64  kHtmlTagType_Error,
65  kHtmlTagType_OutsideTag,
66  kHtmlTagType_Body,
67  kHtmlTagType_Font,
68  kHtmlTagType_Font_Close,
69  kHtmlTagType_Img,
70  kHtmlTagType_A,
71  kHtmlTagType_A_Close,
72  kHtmlTagType_Title,
73  kHtmlTagType_Title_Close,
74  kHtmlTagType_HTML_Close,
75  kHtmlTagType_BR,
76  kHtmlTagType_P,
77  kHtmlTagType_P_Close,
78  kHtmlTagType_U,
79  kHtmlTagType_U_Close,
80  kHtmlTagType_B,
81  kHtmlTagType_B_Close,
82  kHtmlTagType_EM,
83  kHtmlTagType_EM_Close,
84  kHtmlTagType_I,
85  kHtmlTagType_I_Close,
86  kHtmlTagType_SUB,
87  kHtmlTagType_SUB_Close,
88  kHtmlTagType_SUP,
89  kHtmlTagType_SUP_Close,
90  };
91 
92  static Common::HashMap<Common::String, HtmlTagType> *_htmlTagsTypesMap;
93  static Common::HashMap<Common::String, char> *_htmlEntitiesMap;
94  static Common::String popStringPrefix(const char **charPtr, char sep);
95  static HtmlTagType getHtmlTagType(const char *tag);
96  static char getHtmlEntityLatin1Char(const char *entity);
97  static Common::String substituteHtmlEntities(const char *text);
98 
99  void parseTagAttributes(const char* tagAttributes);
100  void cleanTextNode(int animDataSize);
101 
102  static const uint32 kMaxNbrOfHtmlMarks = 20;
103 
104  HtmlTagType _currentTagType;
106  int _pos;
107  int _posBak;
108  bool _field_10;
109  char _buffer[256];
110  HtmlMark _marks[kMaxNbrOfHtmlMarks];
111  uint32 _currentMarkIndex;
112  Common::String _htmlVariables[10];
113 
114  GobEngine *_vm;
115 };
116 
117 
118 } // End of namespace Gob
119 
120 #endif // GOB_HTML_PARSER_H
Definition: gob.h:166
Definition: str.h:59
Definition: stream.h:745
Definition: anifile.h:40
Definition: html_parser.h:42
Definition: html_parser.h:53
Definition: algorithm.h:29