fastdo  0.6.16
elem_package.hpp
浏览该文件的文档.
1 
2 #ifndef __ELEMPACKAGE_HPP__
3 #define __ELEMPACKAGE_HPP__
4 
5 namespace eienml
6 {
7 typedef Element * ( * ElementCreator )( void );
8 typedef Document * ( * DocumentCreator )( void );
9 typedef TextNode * ( * TextNodeCreator )( void );
10 typedef Block * ( * BlockCreator )( void );
11 
12 typedef std::map< winux::AnsiString, ElementCreator > ElementCreatorTable;
13 typedef std::map< winux::AnsiString, BlockCreator > BlockCreatorTable;
14 
17 {
19  epfTagNameLower = 0x02,
22 };
23 
28 {
29 public:
31 
34  ElemPackage( void );
35 
40  winux::AnsiString escape( winux::AnsiString const & str ) const { return this->_text2entities.replace(str); }
42  winux::AnsiString unescape( winux::AnsiString const & str ) const { return this->_entities2text.replace(str); }
44  winux::AnsiString addSlashes( winux::AnsiString const & str ) const { return winux::AddSlashes( str, ADDSLASHES ); }
46  winux::AnsiString stripSlashes( winux::AnsiString const & str ) const { return winux::StripSlashes( str, ADDSLASHES ); }
47 
49  void setDelims( winux::AnsiString const & le, winux::AnsiString const & re, winux::AnsiString const & lb = "", winux::AnsiString const & rb = "" );
51  void setEntities(
52  winux::AnsiString const & specialChar,
53  winux::AnsiString const & specialCharEntity,
54  winux::AnsiString const & lElemDelimEntity,
55  winux::AnsiString const & rElemDelimEntity,
56  winux::AnsiString const & lBlockDelimEntity,
57  winux::AnsiString const & rBlockDelimEntity,
58  winux::StringStringMap const * extraEntitiesTable = NULL
59  );
61  void setExtraEntities( winux::StringStringMap const & extraEntitiesTable );
63  TextNodeCreator setTextCreator( TextNodeCreator creator );
64 
66  void setElement( winux::AnsiString const & tagName, ElementCreator creator );
68  void delElement( winux::AnsiString const & tagName );
70  void setBlock( winux::AnsiString const & blockTag, BlockCreator creator );
72  void delBlock( winux::AnsiString const & blockTag );
73 
75  Element * createElement( winux::AnsiString const & tagName ) const;
77  Block * createBlock( winux::AnsiString const & blockTag ) const;
79  TextNode * createTextNode( winux::AnsiString const & str ) const;
80 
82 
83 
84  void addFlags( winux::uint flags ) { _flags |= flags; }
86  void removeFlags( winux::uint flags ) { _flags &= ~flags; }
87 
89  winux::AnsiString & convTagName( winux::AnsiString * tagName ) const { return ( _flags & epfTagNameLower ) ? winux::StrMakeLower(tagName) : *tagName; }
91  winux::AnsiString & convAttrName( winux::AnsiString * attrName ) const { return ( _flags & epfAttrNameLower ) ? winux::StrMakeLower(attrName) : *attrName; }
92 
94  bool exists( winux::AnsiString const & tagName ) const { return !( _flags & epfParseKnownTagName ) || this->_elemTable.find(tagName) != this->_elemTable.end(); }
96  bool blockExists( winux::AnsiString const & blockTag ) const { return this->_blockTable.find(blockTag) != this->_blockTable.end(); }
97 
98 public:
103 
104 protected:
105  ElementCreatorTable _elemTable;
106  BlockCreatorTable _blockTable;
111 };
112 
113 } // namespace eienml
114 
115 
116 #endif // __ELEMPACKAGE_HPP__
XString< char > AnsiString
Definition: utilities.hpp:257
winux::AnsiString lBlockDelim
左块元素定界符
Element *(* ElementCreator)(void)
Definition: elem_package.hpp:7
XString< _ChTy > AddSlashes(XString< _ChTy > const &str, XString< _ChTy > const &charlist)
winux::AnsiString escape(winux::AnsiString const &str) const
对字符进行换码,与unescape()配套
属性名小写化
#define DEFINE_ATTR_METHOD_VAL(ty, name, memname)
Definition: utilities.hpp:142
块节点类
Definition: elem_utils.hpp:102
ElemPackageFlags
元素包旗标选项开关
TextNode *(* TextNodeCreator)(void)
Definition: elem_package.hpp:9
std::map< String, String > StringStringMap
Definition: utilities.hpp:274
winux::MultiMatch _text2entities
文本到实体
#define EIENML_DLL
Definition: eienml.hpp:19
winux::AnsiString rBlockDelim
右块元素定界符
元素节点类
Definition: elem_utils.hpp:126
winux::AnsiString & convAttrName(winux::AnsiString *attrName) const
根据包设定转换属性名
winux::AnsiString addSlashes(winux::AnsiString const &str) const
特殊字符加上反斜杠
winux::MultiMatch _entities2text
实体到文本
static winux::AnsiString ADDSLASHES
要加反斜杠的字符 "\\\"\&#39;"
标签名小写化(若指定,则设置元素创建器时标签名也要小写化)
BlockCreatorTable _blockTable
块名=>创建块的函数映射表
winux::AnsiString rElemDelim
右定界符
winux::uint _flags
旗标选项开关
winux::AnsiString lElemDelim
左定界符
文本节点类
Definition: elem_utils.hpp:83
ElementCreatorTable _elemTable
元素名=>创建函数映射表
XString< _ChTy > & StrMakeLower(XString< _ChTy > *str)
void removeFlags(winux::uint flags)
移除旗标选项
winux::AnsiString unescape(winux::AnsiString const &str) const
进行反换码,与escape()配套
Simple,Tree,Strip,Replace的toString()是否换码文本内容
bool exists(winux::AnsiString const &tagName) const
指定的元素创建器是否存在
unsigned int uint
Definition: utilities.hpp:215
TextNodeCreator _textCreator
文本节点创建函数
winux::AnsiString & convTagName(winux::AnsiString *tagName) const
根据包设定转换标签名
std::map< winux::AnsiString, BlockCreator > BlockCreatorTable
元素包 - 表示一套标签语言体系的相关要素
Definition: elem_package.hpp:5
XString< _ChTy > StripSlashes(XString< _ChTy > const &str, XString< _ChTy > const &charlist)
Block *(* BlockCreator)(void)
bool blockExists(winux::AnsiString const &blockTag) const
指定的块创建器是否存在
多项匹配/替换
Definition: strings.hpp:790
std::map< winux::AnsiString, ElementCreator > ElementCreatorTable
winux::AnsiString stripSlashes(winux::AnsiString const &str) const
去掉反斜杠
跨平台基础功能库
Definition: archives.hpp:7