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

Side by Side Diff: core/fpdfapi/parser/cfdf_document.cpp

Issue 2539203002: Convert loose FX_Create* functions into static methods (Closed)
Patch Set: last batch Created 4 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
« no previous file with comments | « no previous file | core/fpdfapi/parser/cpdf_data_avail.cpp » ('j') | core/fxcrt/fx_extension.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fpdfapi/parser/cfdf_document.h" 7 #include "core/fpdfapi/parser/cfdf_document.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 27 matching lines...) Expand all
38 if (!pFile) 38 if (!pFile)
39 return nullptr; 39 return nullptr;
40 40
41 auto pDoc = pdfium::MakeUnique<CFDF_Document>(); 41 auto pDoc = pdfium::MakeUnique<CFDF_Document>();
42 pDoc->ParseStream(pFile, bOwnFile); 42 pDoc->ParseStream(pFile, bOwnFile);
43 return pDoc->m_pRootDict ? std::move(pDoc) : nullptr; 43 return pDoc->m_pRootDict ? std::move(pDoc) : nullptr;
44 } 44 }
45 45
46 std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData, 46 std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData,
47 uint32_t size) { 47 uint32_t size) {
48 return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size), 48 return CFDF_Document::ParseFile(
49 true); 49 IFX_MemoryStream::Create((uint8_t*)pData, size), true);
50 } 50 }
51 51
52 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) { 52 void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) {
53 m_pFile = pFile; 53 m_pFile = pFile;
54 m_bOwnFile = bOwnFile; 54 m_bOwnFile = bOwnFile;
55 CPDF_SyntaxParser parser; 55 CPDF_SyntaxParser parser;
56 parser.InitParser(m_pFile, 0); 56 parser.InitParser(m_pFile, 0);
57 while (1) { 57 while (1) {
58 bool bNumber; 58 bool bNumber;
59 CFX_ByteString word = parser.GetNextWord(&bNumber); 59 CFX_ByteString word = parser.GetNextWord(&bNumber);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 buf << "%FDF-1.2\r\n"; 100 buf << "%FDF-1.2\r\n";
101 for (const auto& pair : *this) 101 for (const auto& pair : *this)
102 buf << pair.first << " 0 obj\r\n" 102 buf << pair.first << " 0 obj\r\n"
103 << pair.second.get() << "\r\nendobj\r\n\r\n"; 103 << pair.second.get() << "\r\nendobj\r\n\r\n";
104 104
105 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum() 105 buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum()
106 << " 0 R>>\r\n%%EOF\r\n"; 106 << " 0 R>>\r\n%%EOF\r\n";
107 return true; 107 return true;
108 } 108 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/parser/cpdf_data_avail.cpp » ('j') | core/fxcrt/fx_extension.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698