Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp

Issue 1512763013: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include "core/include/fxcrt/fx_string.h" 9 #include "core/include/fxcrt/fx_string.h"
10 10
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return nullptr; 154 return nullptr;
155 } 155 }
156 } 156 }
157 157
158 CPDF_Array* CPDF_Object::GetArray() const { 158 CPDF_Array* CPDF_Object::GetArray() const {
159 // The method should be made non-const if we want to not be const. 159 // The method should be made non-const if we want to not be const.
160 // See bug #234. 160 // See bug #234.
161 return const_cast<CPDF_Array*>(AsArray()); 161 return const_cast<CPDF_Array*>(AsArray());
162 } 162 }
163 void CPDF_Object::SetString(const CFX_ByteString& str) { 163 void CPDF_Object::SetString(const CFX_ByteString& str) {
164 ASSERT(this != NULL);
165 switch (m_Type) { 164 switch (m_Type) {
166 case PDFOBJ_BOOLEAN: 165 case PDFOBJ_BOOLEAN:
167 AsBoolean()->m_bValue = (str == "true"); 166 AsBoolean()->m_bValue = (str == "true");
168 return; 167 return;
169 case PDFOBJ_NUMBER: 168 case PDFOBJ_NUMBER:
170 AsNumber()->SetString(str); 169 AsNumber()->SetString(str);
171 return; 170 return;
172 case PDFOBJ_STRING: 171 case PDFOBJ_STRING:
173 AsString()->m_String = str; 172 AsString()->m_String = str;
174 return; 173 return;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 pOld->Release(); 518 pOld->Release();
520 if (pObj->GetObjNum()) { 519 if (pObj->GetObjNum()) {
521 ASSERT(pObjs); 520 ASSERT(pObjs);
522 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); 521 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
523 } 522 }
524 m_Objects.SetAt(i, pObj); 523 m_Objects.SetAt(i, pObj);
525 } 524 }
526 void CPDF_Array::InsertAt(FX_DWORD index, 525 void CPDF_Array::InsertAt(FX_DWORD index,
527 CPDF_Object* pObj, 526 CPDF_Object* pObj,
528 CPDF_IndirectObjects* pObjs) { 527 CPDF_IndirectObjects* pObjs) {
529 ASSERT(pObj != NULL);
530 if (pObj->GetObjNum()) { 528 if (pObj->GetObjNum()) {
531 ASSERT(pObjs != NULL); 529 ASSERT(pObjs);
532 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); 530 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
533 } 531 }
534 m_Objects.InsertAt(index, pObj); 532 m_Objects.InsertAt(index, pObj);
535 } 533 }
536 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) { 534 void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) {
537 ASSERT(pObj != NULL);
538 if (pObj->GetObjNum()) { 535 if (pObj->GetObjNum()) {
539 ASSERT(pObjs != NULL); 536 ASSERT(pObjs);
540 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); 537 pObj = new CPDF_Reference(pObjs, pObj->GetObjNum());
541 } 538 }
542 m_Objects.Add(pObj); 539 m_Objects.Add(pObj);
543 } 540 }
544 void CPDF_Array::AddName(const CFX_ByteString& str) { 541 void CPDF_Array::AddName(const CFX_ByteString& str) {
545 ASSERT(IsArray()); 542 ASSERT(IsArray());
546 Add(new CPDF_Name(str)); 543 Add(new CPDF_Name(str));
547 } 544 }
548 void CPDF_Array::AddString(const CFX_ByteString& str) { 545 void CPDF_Array::AddString(const CFX_ByteString& str) {
549 ASSERT(IsArray()); 546 ASSERT(IsArray());
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 } 1170 }
1174 pObj->m_ObjNum = objnum; 1171 pObj->m_ObjNum = objnum;
1175 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); 1172 m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj);
1176 if (m_LastObjNum < objnum) 1173 if (m_LastObjNum < objnum)
1177 m_LastObjNum = objnum; 1174 m_LastObjNum = objnum;
1178 return TRUE; 1175 return TRUE;
1179 } 1176 }
1180 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { 1177 FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const {
1181 return m_LastObjNum; 1178 return m_LastObjNum;
1182 } 1179 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp ('k') | core/src/fpdfapi/fpdf_render/fpdf_render.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698