7 #ifndef PDF_NAME_TREES_H
8 #define PDF_NAME_TREES_H
10 #include "PdfNameTree.h"
11 #include "PdfNameTreeOperations.h"
38 template <
typename TNameTree>
41 return static_cast<TNameTree*
>(getNameTree(getType<TNameTree>()));
44 template <
typename TNameTree>
45 const TNameTree* GetTree()
const
47 return static_cast<const TNameTree*
>(getNameTree(getType<TNameTree>()));
50 template <
typename TNameTree>
51 TNameTree& MustGetTree()
53 return static_cast<TNameTree&
>(mustGetNameTree(getType<TNameTree>()));
56 template <
typename TNameTree>
57 const TNameTree& MustGetTree()
const
59 return static_cast<const TNameTree&
>(mustGetNameTree(getType<TNameTree>()));
62 template <
typename TNameTree>
63 TNameTree& GetOrCreateTree()
65 return static_cast<TNameTree&
>(getOrCreateNameTree(getType<TNameTree>()));
69 const PdfObject*
GetValue(PdfKnownNameTree tree,
const std::string_view& key)
const override;
70 PdfObject* GetValue(PdfKnownNameTree tree,
const std::string_view& key)
override;
71 bool HasKey(PdfKnownNameTree tree,
const std::string_view& key)
const override;
72 void ToDictionary(PdfKnownNameTree tree, PdfStringMap<PdfObject>& dict,
bool skipClear =
false)
const override;
75 void AddValue(PdfKnownNameTree tree,
const PdfString& key,
const PdfObject& value)
override;
77 const PdfObject* GetValue(
const std::string_view& treeName,
const std::string_view& key)
const override;
78 PdfObject* GetValue(
const std::string_view& treeName,
const std::string_view& key)
override;
79 bool HasKey(
const std::string_view& treeName,
const std::string_view& key)
const override;
80 void ToDictionary(
const std::string_view& treeName, PdfStringMap<PdfObject>& dict,
bool skipClear =
false)
const override;
100 PdfObject* getRootNode(
const std::string_view& treeName)
const;
103 PdfObject* getValue(
const std::string_view& name,
const std::string_view& key)
const;
105 PdfNameTreeBase* getNameTree(PdfKnownNameTree tree)
const;
107 PdfNameTreeBase& mustGetNameTree(PdfKnownNameTree tree)
const;
109 PdfNameTreeBase& getOrCreateNameTree(PdfKnownNameTree tree);
111 template <
typename TNameTree>
112 static constexpr PdfKnownNameTree getType()
114 if (std::is_same_v<TNameTree, PdfEmbeddedFiles>)
115 return PdfKnownNameTree::EmbeddedFiles;
116 else if (std::is_same_v<TNameTree, PdfDestinations>)
117 return PdfKnownNameTree::Dests;
119 return PdfKnownNameTree::Unknown;
PdfDocument is the core interface for working with PDF documents.
Definition: PdfDocument.h:108
A low level interface with operations to handle document name trees stored in the /Names element.
Definition: PdfNameTreeOperations.h:18
Interface to access names trees in the document.
Definition: PdfNameTrees.h:22
bool HasKey(PdfKnownNameTree tree, const std::string_view &key) const override
Tests whether a certain nametree has a value.
const PdfObject * GetValue(PdfKnownNameTree tree, const std::string_view &key) const override
Get the object referenced by a string key in one of the dictionaries of the name tree.
This class represents a PdfName.
Definition: PdfName.h:24
This class represents a PDF indirect Object in memory.
Definition: PdfObject.h:35
A string that can be written to a PDF document.
Definition: PdfString.h:24
Alternative to std::optional that supports reference (but not pointer) types.
Definition: nullable.h:29
SPDX-FileCopyrightText: (C) 2022 Francesco Pretto ceztko@gmail.com SPDX-License-Identifier: LGPL-2....
Definition: basetypes.h:16