diff options
Diffstat (limited to 'core/fpdfapi/parser/cpdf_object_avail.h')
-rw-r--r-- | core/fpdfapi/parser/cpdf_object_avail.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_object_avail.h b/core/fpdfapi/parser/cpdf_object_avail.h new file mode 100644 index 0000000000..233d180c94 --- /dev/null +++ b/core/fpdfapi/parser/cpdf_object_avail.h @@ -0,0 +1,52 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ +#define CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ + +#include <memory> +#include <set> +#include <stack> + +#include "core/fpdfapi/parser/cpdf_data_avail.h" +#include "core/fxcrt/cfx_maybe_owned.h" +#include "core/fxcrt/cfx_unowned_ptr.h" + +class CPDF_Object; +class CPDF_Reference; +class CPDF_IndirectObjectHolder; +class CPDF_ReadValidator; + +// Helper for check availability of object tree. +class CPDF_ObjectAvail { + public: + CPDF_ObjectAvail(CPDF_ReadValidator* validator, + CPDF_IndirectObjectHolder* holder, + const CPDF_Object* root); + CPDF_ObjectAvail(CPDF_ReadValidator* validator, + CPDF_IndirectObjectHolder* holder, + uint32_t obj_num); + virtual ~CPDF_ObjectAvail(); + + CPDF_DataAvail::DocAvailStatus CheckAvail(); + + protected: + virtual bool ExcludeObject(const CPDF_Object* object) const; + + private: + bool LoadRootObject(); + bool CheckObjects(); + bool AppendObjectSubRefs(const CPDF_Object* object, + std::stack<uint32_t>* refs) const; + void CleanMemory(); + bool HasObjectParsed(uint32_t obj_num) const; + + CFX_UnownedPtr<CPDF_ReadValidator> validator_; + CFX_UnownedPtr<CPDF_IndirectObjectHolder> holder_; + CFX_MaybeOwned<const CPDF_Object> root_; + std::set<uint32_t> parsed_objnums_; + std::stack<uint32_t> non_parsed_objects_; +}; + +#endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_AVAIL_H_ |