#ifndef XFA_FXFA_PARSER_CXFA_NODEITERATORTEMPLATE_H_
#define XFA_FXFA_PARSER_CXFA_NODEITERATORTEMPLATE_H_
#include <type_traits>
#include "core/fxcrt/unowned_ptr.h"
#include "v8/include/cppgc/macros.h"
#include "v8/include/cppgc/type-traits.h"
template <class NodeType,
class TraverseStrategy,
typename HolderType = std::conditional_t<
cppgc::IsGarbageCollectedOrMixinTypeV<NodeType>,
NodeType*,
UnownedPtr<NodeType>>>
class CXFA_NodeIteratorTemplate {
CPPGC_STACK_ALLOCATED();
public:
explicit CXFA_NodeIteratorTemplate(NodeType* pRoot)
: … { … }
NodeType* GetRoot() const { … }
NodeType* GetCurrent() const { … }
void Reset() { … }
bool SetCurrent(NodeType* pNode) { … }
NodeType* MoveToPrev() { … }
NodeType* MoveToNext() { … }
NodeType* SkipChildrenAndMoveToNext() { … }
private:
bool RootReachableFromNode(NodeType* pNode) { … }
NodeType* ParentWithinSubtree(NodeType* pNode) { … }
NodeType* NextSiblingWithinSubtree(NodeType* pNode) { … }
NodeType* PreviousSiblingWithinSubtree(NodeType* pNode) { … }
NodeType* LastChild(NodeType* pNode) { … }
NodeType* LastDescendant(NodeType* pNode) { … }
HolderType m_pRoot;
HolderType m_pCurrent;
};
#endif