文檔金喜正規買球>>BCGControlBar 中文文檔>>XML格式的大綱解析器
XML格式的大綱解析器
本文介紹了與CBCGPOutlineParser一起使用的 XML 文件格式以及編輯控件的自動大綱功能,XML 解析器是通過調用CBCGPEditCtrl::LoadOutlineParserXMLSettings來調用的。
用于大綱解析器的結構如下:
<SETTINGS> <OUTLINE_DATA> <IgnoreOneLineBlocks></IgnoreOneLineBlocks> <EscapeSequences> <EscapeSequence></EscapeSequence> </EscapeSequences> <BLOCKS> <BLOCK> <Start></Start> <End></End> <ReplaceString></ReplaceString> <AllowNestedBlocks></AllowNestedBlocks> <Ignore></Ignore> </BLOCK> </BLOCKS> </OUTLINE_DATA> </SETTINGS>
除了主要的“SETTINGS”標簽外,沒有強制性標簽。
- "OUTLINE_DATA"標簽定義一般大綱解析器設置。
- “IgnoreOneLineBlocks”標簽定義了編輯控件是否應該將一行塊視為可折疊的,默認為False。
- "EscapeSequences"標簽定義了一個轉義序列列表。
- "EscapeSequence"標記表示單個轉義序列。
- “BLOCKS”標記用于該語言的語法定義,每個塊指定大綱解析器如何找到大綱可折疊區域的規則。當您需要定義一組相同語言語法塊的自動概述區域時,它很有用,對于每個塊,XML解析器將調用CBCGPOutlineParser::AddBlockType。
- “BLOCK”標簽代表單個塊。
- “Start”——定義BlockType::m_strOpen。
- “End”——定義BlockType::m_strClose。
- “ReplaceString”——定義BlockType::m_strReplace,默認為“...”。
- “AllowNestedBlocks” —— 定義BlockType::m_bAllowNestedBlocks,默認為“True”。
- “Ignore”——定義BlockType::m_bIgnore,默認為“False”。
C++ 的默認 XML 設置
<SETTINGS> <OUTLINE_DATA> <IgnoreOneLineBlocks>True</IgnoreOneLineBlocks> <IncludeSpaceLines>True</IncludeSpaceLines> <EscapeSequences> <EscapeSequence>\\\"</EscapeSequence> </EscapeSequences> <BLOCKS> <BLOCK> <Start>\\\"</Start> <End></End> <ReplaceString></ReplaceString> <AllowNestedBlocks>False</AllowNestedBlocks> <Ignore>True</Ignore> </BLOCK> <BLOCK> <Start>\"</Start> <End>\"</End> <ReplaceString>\"\"</ReplaceString> <AllowNestedBlocks>False</AllowNestedBlocks> <Ignore>True</Ignore> </BLOCK> <BLOCK> <Start>{</Start> <End>}</End> <ReplaceString>..</ReplaceString> <KEYWORDS> <Keyword>else</Keyword> <Keyword>struct</Keyword> <Keyword>enum</Keyword> <Keyword>switch</Keyword> <Keyword>catch</Keyword> <Keyword>try</Keyword> <Keyword>for</Keyword> <Keyword>operator</Keyword> <Keyword>class</Keyword> <Keyword>if</Keyword> <Keyword>union</Keyword> <Keyword>do</Keyword> <Keyword>while</Keyword> <Keyword>namespace</Keyword> </KEYWORDS> </BLOCK> <BLOCK> <Start>{</Start> <End>}</End> <ReplaceString>...</ReplaceString> </BLOCK> <BLOCK> <Start>//</Start> <End>\n</End> <ReplaceString>/**/</ReplaceString> <AllowNestedBlocks>False</AllowNestedBlocks> </BLOCK> <BLOCK> <Start>/*</Start> <End>*/</End> <ReplaceString>/**/</ReplaceString> <AllowNestedBlocks>False</AllowNestedBlocks> </BLOCK> </BLOCKS> </OUTLINE_DATA> </SETTINGS>