summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxcrt/xml/cfx_saxreader.cpp70
-rw-r--r--core/fxcrt/xml/cfx_saxreader.h7
2 files changed, 53 insertions, 24 deletions
diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp
index c571e8be96..a7810c9884 100644
--- a/core/fxcrt/xml/cfx_saxreader.cpp
+++ b/core/fxcrt/xml/cfx_saxreader.cpp
@@ -28,7 +28,6 @@ enum class CFX_SaxMode {
TagClose,
TagEnd,
TargetData,
- MAX
};
class CFX_SAXCommentContext {
@@ -42,25 +41,6 @@ namespace {
const uint32_t kSaxFileBufSize = 32768;
-typedef void (CFX_SAXReader::*FX_SAXReader_LPFParse)();
-static const FX_SAXReader_LPFParse
- g_FX_SAXReader_LPFParse[static_cast<int>(CFX_SaxMode::MAX)] = {
- &CFX_SAXReader::ParseText,
- &CFX_SAXReader::ParseNodeStart,
- &CFX_SAXReader::ParseDeclOrComment,
- &CFX_SAXReader::ParseDeclNode,
- &CFX_SAXReader::ParseComment,
- &CFX_SAXReader::ParseCommentContent,
- &CFX_SAXReader::ParseTagName,
- &CFX_SAXReader::ParseTagAttributeName,
- &CFX_SAXReader::ParseTagAttributeEqual,
- &CFX_SAXReader::ParseTagAttributeValue,
- &CFX_SAXReader::ParseMaybeClose,
- &CFX_SAXReader::ParseTagClose,
- &CFX_SAXReader::ParseTagEnd,
- &CFX_SAXReader::ParseTargetData,
-};
-
} // namespace
CFX_SAXFile::CFX_SAXFile()
@@ -244,7 +224,7 @@ int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) {
const uint8_t* pBuf = m_File.m_pBuf;
while (index < size) {
m_CurByte = pBuf[index];
- (this->*g_FX_SAXReader_LPFParse[static_cast<int>(m_eMode)])();
+ ParseInternal();
index++;
}
m_File.m_dwCur += index;
@@ -264,6 +244,54 @@ int32_t CFX_SAXReader::ContinueParse(IFX_Pause* pPause) {
}
return m_iState;
}
+
+void CFX_SAXReader::ParseInternal() {
+ switch (m_eMode) {
+ case CFX_SaxMode::Text:
+ ParseText();
+ break;
+ case CFX_SaxMode::NodeStart:
+ ParseNodeStart();
+ break;
+ case CFX_SaxMode::DeclOrComment:
+ ParseDeclOrComment();
+ break;
+ case CFX_SaxMode::DeclNode:
+ ParseDeclNode();
+ break;
+ case CFX_SaxMode::Comment:
+ ParseComment();
+ break;
+ case CFX_SaxMode::CommentContent:
+ ParseCommentContent();
+ break;
+ case CFX_SaxMode::TagName:
+ ParseTagName();
+ break;
+ case CFX_SaxMode::TagAttributeName:
+ ParseTagAttributeName();
+ break;
+ case CFX_SaxMode::TagAttributeEqual:
+ ParseTagAttributeEqual();
+ break;
+ case CFX_SaxMode::TagAttributeValue:
+ ParseTagAttributeValue();
+ break;
+ case CFX_SaxMode::TagMaybeClose:
+ ParseMaybeClose();
+ break;
+ case CFX_SaxMode::TagClose:
+ ParseTagClose();
+ break;
+ case CFX_SaxMode::TagEnd:
+ ParseTagEnd();
+ break;
+ case CFX_SaxMode::TargetData:
+ ParseTargetData();
+ break;
+ }
+}
+
void CFX_SAXReader::ParseChar(uint8_t ch) {
ReallocDataBuffer();
m_pszData[m_iDataPos] = ch;
diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h
index 6c76016110..45f0d07084 100644
--- a/core/fxcrt/xml/cfx_saxreader.h
+++ b/core/fxcrt/xml/cfx_saxreader.h
@@ -101,8 +101,11 @@ class CFX_SAXReader {
uint32_t dwLen = -1,
uint32_t dwParseMode = 0);
int32_t ContinueParse(IFX_Pause* pPause = nullptr);
- void SkipCurrentNode();
void SetHandler(HandlerIface* pHandler) { m_pHandler = pHandler; }
+
+ private:
+ void ParseInternal();
+ void SkipCurrentNode();
void AppendData(uint8_t ch);
void AppendName(uint8_t ch);
void ParseText();
@@ -120,8 +123,6 @@ class CFX_SAXReader {
void ParseTagClose();
void ParseTagEnd();
void ParseTargetData();
-
- private:
void Reset();
void Push();
void Pop();