diff options
author | Wei Li <weili@chromium.org> | 2016-02-16 14:26:22 -0800 |
---|---|---|
committer | Wei Li <weili@chromium.org> | 2016-02-16 14:26:22 -0800 |
commit | 970c11e2225d73234009ccdc6f656abd01ae4026 (patch) | |
tree | c184a4d3b62785ee5431cc2c6d7199103b78986f /core/include | |
parent | 4f7f4eea92b607ca3864df63e4b277abd5e5af97 (diff) | |
download | pdfium-970c11e2225d73234009ccdc6f656abd01ae4026.tar.xz |
Refactor CPDF_SimpleParser and add unit tests.
Remove unused member functions and simplify calls to find tag parameters.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1681403007 .
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/fpdfapi/fpdf_parser.h | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h index 18a942e4e8..de32b1fb37 100644 --- a/core/include/fpdfapi/fpdf_parser.h +++ b/core/include/fpdfapi/fpdf_parser.h @@ -212,28 +212,16 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder { class CPDF_SimpleParser { public: CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); - CPDF_SimpleParser(const CFX_ByteStringC& str); CFX_ByteStringC GetWord(); - FX_BOOL SearchToken(const CFX_ByteStringC& token); - - FX_BOOL SkipWord(const CFX_ByteStringC& token); - - FX_BOOL FindTagPair(const CFX_ByteStringC& start_token, - const CFX_ByteStringC& end_token, - FX_DWORD& start_pos, - FX_DWORD& end_pos); + // Find the token and its |nParams| parameters from the start of data, + // and move the current position to the start of those parameters. + bool FindTagParamFromStart(const CFX_ByteStringC& token, int nParams); - FX_BOOL FindTagParam(const CFX_ByteStringC& token, int nParams); - - FX_DWORD GetPos() { return m_dwCurPos; } - - void SetPos(FX_DWORD pos) { - ASSERT(pos <= m_dwSize); - m_dwCurPos = pos; - } + // For testing only. + FX_DWORD GetCurPos() const { return m_dwCurPos; } private: void ParseWord(const uint8_t*& pStart, FX_DWORD& dwSize); |