From 970c11e2225d73234009ccdc6f656abd01ae4026 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Tue, 16 Feb 2016 14:26:22 -0800 Subject: 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 . --- core/include/fpdfapi/fpdf_parser.h | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'core/include/fpdfapi') 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); -- cgit v1.2.3