From c9f4f0dbcaaf9e86ef2b64c844b094bd2f6b1a92 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 12 Apr 2018 20:59:25 +0000 Subject: Make some CPDF_StreamContentParser methods const. Change-Id: Idd1d865741bb487647fa823846ea5751245ed86a Reviewed-on: https://pdfium-review.googlesource.com/30453 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 8 ++++---- core/fpdfapi/page/cpdf_streamcontentparser.h | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index c251c5ec66..9cd05cbb2d 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -383,7 +383,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { return nullptr; } -ByteString CPDF_StreamContentParser::GetString(uint32_t index) { +ByteString CPDF_StreamContentParser::GetString(uint32_t index) const { if (index >= m_ParamCount) { return ByteString(); } @@ -391,7 +391,7 @@ ByteString CPDF_StreamContentParser::GetString(uint32_t index) { if (real_index >= kParamBufSize) { real_index -= kParamBufSize; } - ContentParam& param = m_ParamBuf[real_index]; + const ContentParam& param = m_ParamBuf[real_index]; if (param.m_Type == ContentParam::NAME) { return ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len); } @@ -401,7 +401,7 @@ ByteString CPDF_StreamContentParser::GetString(uint32_t index) { return ByteString(); } -float CPDF_StreamContentParser::GetNumber(uint32_t index) { +float CPDF_StreamContentParser::GetNumber(uint32_t index) const { if (index >= m_ParamCount) { return 0; } @@ -409,7 +409,7 @@ float CPDF_StreamContentParser::GetNumber(uint32_t index) { if (real_index >= kParamBufSize) { real_index -= kParamBufSize; } - ContentParam& param = m_ParamBuf[real_index]; + const ContentParam& param = m_ParamBuf[real_index]; if (param.m_Type == ContentParam::NUMBER) { return param.m_Number.m_bInteger ? static_cast(param.m_Number.m_Integer) diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index 5dcfbe5308..ff80ae9ef1 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -90,9 +90,11 @@ class CPDF_StreamContentParser { int GetNextParamPos(); void ClearAllParams(); CPDF_Object* GetObject(uint32_t index); - ByteString GetString(uint32_t index); - float GetNumber(uint32_t index); - int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } + ByteString GetString(uint32_t index) const; + float GetNumber(uint32_t index) const; + int GetInteger(uint32_t index) const { + return static_cast(GetNumber(index)); + } void OnOperator(const ByteStringView& op); void AddTextObject(ByteString* pText, float fInitKerning, -- cgit v1.2.3