Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_numbertree.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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_FPDFDOC_CPDF_NUMBERTREE_H_
8#define CORE_FPDFDOC_CPDF_NUMBERTREE_H_
9
10#include <optional>
11
12#include "core/fxcrt/retain_ptr.h"
13
14class CPDF_Dictionary;
15class CPDF_Object;
16
17// Represents a number tree that allows for sub-linear lookups of tree nodes.
18// See ISO 32000-1:2008 spec, section 7.9.7.
20 public:
21 struct KeyValue {
22 KeyValue(int key, RetainPtr<const CPDF_Object> value);
23 KeyValue(const KeyValue&) = delete;
24 KeyValue& operator=(const KeyValue&) = delete;
25 KeyValue(KeyValue&&) noexcept;
26 KeyValue& operator=(KeyValue&&) noexcept;
28
29 int key;
31 };
32
33 explicit CPDF_NumberTree(RetainPtr<const CPDF_Dictionary> root);
35
36 // Finds the object in the number tree whose key is `num`. Returns nullptr in
37 // there is no `num` key in the tree.
38 RetainPtr<const CPDF_Object> LookupValue(int num) const;
39
40 // Finds the object in the number tree with the largest key, such that
41 // `num` >= key. Returns the key/value pair if such a key exists, or
42 // std::nullopt otherwise.
43 // Note that this is similar to, but not exactly the same as
44 // std::lower_bound().
45 std::optional<KeyValue> GetLowerBound(int num) const;
46
47 protected:
49};
50
51#endif // CORE_FPDFDOC_CPDF_NUMBERTREE_H_
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition cpdf_array.h:29
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
RetainPtr< const CPDF_Dictionary > const root_
CPDF_NumberTree(RetainPtr< const CPDF_Dictionary > root)
std::optional< KeyValue > GetLowerBound(int num) const
RetainPtr< const CPDF_Object > LookupValue(int num) const
RetainPtr< const CPDF_Object > value
KeyValue(const KeyValue &)=delete
KeyValue(KeyValue &&) noexcept
KeyValue & operator=(const KeyValue &)=delete
KeyValue & operator=(KeyValue &&) noexcept
KeyValue(int key, RetainPtr< const CPDF_Object > value)