Home | History | Annotate | Download | only in parser
      1 // Copyright 2016 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef CORE_FPDFAPI_PARSER_CPDF_SIMPLE_PARSER_H_
      8 #define CORE_FPDFAPI_PARSER_CPDF_SIMPLE_PARSER_H_
      9 
     10 #include <utility>
     11 
     12 #include "core/fxcrt/fx_string.h"
     13 #include "core/fxcrt/fx_system.h"
     14 
     15 class CPDF_SimpleParser {
     16  public:
     17   CPDF_SimpleParser(const uint8_t* pData, uint32_t dwSize);
     18   explicit CPDF_SimpleParser(const ByteStringView& str);
     19 
     20   ByteStringView GetWord();
     21 
     22   // Find the token and its |nParams| parameters from the start of data,
     23   // and move the current position to the start of those parameters.
     24   bool FindTagParamFromStart(const ByteStringView& token, int nParams);
     25 
     26   // For testing only.
     27   uint32_t GetCurPos() const { return m_dwCurPos; }
     28 
     29  private:
     30   std::pair<const uint8_t*, uint32_t> ParseWord();
     31 
     32   const uint8_t* m_pData;
     33   uint32_t m_dwSize;
     34   uint32_t m_dwCurPos;
     35 };
     36 
     37 #endif  // CORE_FPDFAPI_PARSER_CPDF_SIMPLE_PARSER_H_
     38