fastdo  0.6.8
elem_package.hpp
浏览该文件的文档.
1 /* 元素包 - 表示一套标签语言体系的相关要素 */
2 #ifndef __ELEMPACKAGE_HPP__
3 #define __ELEMPACKAGE_HPP__
4 
5 namespace eienml
6 {
7 
8 typedef Element * ( * ElementCreator )( void );
9 typedef Document * ( * DocumentCreator )( void );
10 typedef TextNode * ( * TextNodeCreator )( void );
11 typedef Block * ( * BlockCreator )( void );
12 
13 typedef std::map< winux::AnsiString, ElementCreator > ElementCreatorTable;
14 typedef std::map< winux::AnsiString, BlockCreator > BlockCreatorTable;
15 
20 {
21 public:
22  static const char * ADDSLASHES/* = "\\\"\'" */;
23 
26  ElemPackage( void );
27 
32  winux::AnsiString escape( winux::AnsiString const & str ) const;
34  winux::AnsiString unescape( winux::AnsiString const & str ) const;
36  winux::AnsiString addSlashes( winux::AnsiString const & str ) const;
38  winux::AnsiString stripSlashes( winux::AnsiString const & str ) const;
39 
41  void setEntitiesTable(
42  winux::AnsiString const & specialChar,
43  winux::AnsiString const & specialCharEntity,
44  winux::AnsiString const & lElemDelimEntity,
45  winux::AnsiString const & rElemDelimEntity,
46  winux::AnsiString const & lBlockDelimEntity,
47  winux::AnsiString const & rBlockDelimEntity,
48  winux::StringStringMap const * entitiesTable = NULL
49  );
51  void setDelims( winux::AnsiString const & le, winux::AnsiString const & re, winux::AnsiString const & lb = "", winux::AnsiString const & rb = "" );
53  TextNodeCreator setTextCreator( TextNodeCreator creator );
54 
56  void setElement( winux::AnsiString const & tagName, ElementCreator creator );
58  void delElement( winux::AnsiString const & tagName );
60  void setBlock( winux::AnsiString const & blockTag, BlockCreator creator );
62  void delBlock( winux::AnsiString const & blockTag );
64  Element * createElement( winux::AnsiString const & tagName ) const;
66  Block * createBlock( winux::AnsiString const & blockTag ) const;
68  TextNode * createTextNode( winux::AnsiString const & str ) const;
69 
71  bool exists( winux::AnsiString const & tagName ) const;
73  bool blockExists( winux::AnsiString const & blockTag ) const;
74 public:
79 protected:
81  ElementCreatorTable elemTable;
82  BlockCreatorTable blockTable;
85 };
86 
87 }
88 
89 
90 #endif // __ELEMPACKAGE_HPP__
XString< char > AnsiString
Definition: utilities.hpp:212
winux::AnsiString lBlockDelim
左块元素定界符
BlockCreatorTable blockTable
块名=>创建块的函数映射表
Element *(* ElementCreator)(void)
Definition: elem_package.hpp:8
块节点类
Definition: elem_utils.hpp:94
winux::MultiMatch text2entities
文本到实体
TextNode *(* TextNodeCreator)(void)
std::map< String, String > StringStringMap
Definition: utilities.hpp:229
#define EIENML_DLL
Definition: eienml.hpp:19
winux::AnsiString rBlockDelim
右块元素定界符
元素节点类
Definition: elem_utils.hpp:114
winux::AnsiString rElemDelim
右定界符
winux::AnsiString lElemDelim
左定界符
TextNodeCreator textCreator
文本节点创建函数
文本节点类
Definition: elem_utils.hpp:77
std::map< winux::AnsiString, BlockCreator > BlockCreatorTable
标签式语言支持库
Definition: elem_package.hpp:5
Block *(* BlockCreator)(void)
winux::MultiMatch entities2text
实体到文本
KMP多项匹配/替换
Definition: strings.hpp:536
std::map< winux::AnsiString, ElementCreator > ElementCreatorTable
ElementCreatorTable elemTable
元素名=>创建函数映射表