fastdo  0.6.16
elem_parser.hpp
浏览该文件的文档.
1 #ifndef __ELEMPARSER_HPP__
2 #define __ELEMPARSER_HPP__
3 
4 namespace eienml
5 {
8 {
9 public:
10  ElemParser( ElemPackage const & package );
11 
15  Element * parse( winux::AnsiString const & str, Element * container ) const;
16 
18  Document * parse( winux::AnsiString const & str, DocumentCreator docCreator = nullptr ) const;
19 
28  int searchDelim( winux::AnsiString const & str, int offset, int * length, int * internalStart, int * internalLength ) const;
29 
43  int searchElement(
44  winux::AnsiString const & str,
45  int offset,
46  int * length,
47  int * internalStart,
48  int * internalLength,
49  winux::AnsiString * tagName,
50  int * iEndTagName,
51  int * remainLength,
52  bool * isHead,
53  bool * isOdd
54  ) const;
55 
56  /* 读取字符到键名,遇到=号键名结束,开始读值
57  * 如果第一个字符不是引号,则读到空格为止值结束
58  * 如果是引号,则继续读到另一个引号为止值结束
59  * 读到\时应对下一字符进行判断,如果是引号则不结束值继续读取 */
60 
62  void read( winux::AnsiString const & str, int iEndTagName, int remainLength, winux::AnsiString * defAttr, Attributes * attrs ) const;
63 
64 private:
65  ElemPackage const * _package;
66 };
67 
70 {
71 public:
72  ElemParserEx( ElemPackage const & package );
73 
75  Element * parse( winux::AnsiString const & str, Element * container ) const;
76 
78  Document * parse( winux::AnsiString const & str, DocumentCreator docCreator = nullptr ) const;
79 
89  int searchDelim(
90  winux::AnsiString const & str,
91  int offset,
92  int * length,
93  int * internalStart,
94  int * internalLength,
95  bool * isBlock
96  ) const;
97 
112  int search(
113  winux::AnsiString const & str,
114  int offset,
115  int * length,
116  int * internalStart,
117  int * internalLength,
118  bool * isBlock,
119  winux::AnsiString * tagName,
120  int * iEndTagName,
121  int * remainLength,
122  bool * isHead,
123  bool * isOdd
124  ) const;
125 
127  void readElement( winux::AnsiString const & str, int iEndTagName, int remainLength, winux::AnsiString * defAttr, Attributes * attrs ) const;
128 
130  void readBlock( winux::AnsiString const & str, int iEndBlockTag, int remainLength, winux::AnsiString * blockContent ) const;
131 
132 private:
133  ElemPackage const * _package;
134  winux::MultiMatch _multiMatchLeftDelim;
135 };
136 
137 namespace old_v1
138 {
141 {
142 public:
143  ElemParser( ElemPackage const & package );
144 
148  Element * parse( winux::AnsiString s, Element * container ) const;
149 
151  Document * parse( winux::AnsiString s, DocumentCreator docCreator = nullptr ) const;
152 
154  int searchElement( winux::AnsiString const & str, int * length ) const;
155 
157  int searchDelim( winux::AnsiString const & str, int offset, int * length ) const;
158 
160  bool isHeader( winux::AnsiString const & str, winux::AnsiString * data ) const;
161 
162  /* 读取字符到键名,遇到=号键名结束,开始读值
163  * 如果第一个字符不是引号,则读到空格为止值结束
164  * 如果是引号,则继续读到另一个引号为止值结束
165  * 读到\时应对下一字符进行判断,如果是引号则不结束值继续读取 */
166 
168  void read( winux::AnsiString const & str, winux::AnsiString * tagName, winux::AnsiString * defAttr = nullptr, Attributes * attrs = nullptr ) const;
169 
170 private:
171  ElemPackage const * package;
172 };
173 
176 {
177 public:
178  ElemParserEx( ElemPackage const & package );
179 
181  Element * parse( winux::AnsiString s, Element * container ) const;
182 
184  Document * parse( winux::AnsiString s, DocumentCreator docCreator = nullptr ) const;
185 
193  int searchDelim(
194  winux::AnsiString const & str,
195  int offset,
196  int * length,
197  winux::AnsiString * internalData,
198  winux::AnsiString * lDelim,
199  winux::AnsiString * rDelim,
200  bool * isBlock
201  ) const;
202 
210  int search( winux::AnsiString const & str, int offset, int * length, winux::AnsiString * data, bool * isBlock, bool * isHead, winux::AnsiString * tagName ) const;
211 
213  void readElement( winux::AnsiString data, winux::AnsiString * tagName, winux::AnsiString * defAttr, Attributes * attrs ) const;
214 
216  void readBlock( winux::AnsiString const & data, winux::AnsiString * blockTag, winux::AnsiString * blockContent ) const;
217 
218 private:
219  ElemPackage const * _package;
220  winux::MultiMatch _multiMatchLeftDelim;
221 };
222 
223 } // namespace old_v1
224 
225 } // namespace eienml
226 
227 #endif // __ELEMPARSER_HPP__
XString< char > AnsiString
Definition: utilities.hpp:257
元素和块解析器V1
#define EIENML_DLL
Definition: eienml.hpp:19
Document *(* DocumentCreator)(void)
Definition: elem_package.hpp:8
元素节点类
Definition: elem_utils.hpp:126
元素解析器
Definition: elem_parser.hpp:7
元素和块解析器
Definition: elem_parser.hpp:69
元素解析器V1
元素包 - 表示一套标签语言体系的相关要素
Definition: elem_package.hpp:5
std::map< winux::AnsiString, winux::AnsiString > Attributes
Definition: elem_utils.hpp:120
多项匹配/替换
Definition: strings.hpp:790