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
cxfa_arraynodelist.cpp
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#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
8
9#include <utility>
10#include <vector>
11
12#include "fxjs/gc/container_trace.h"
13#include "xfa/fxfa/parser/cxfa_node.h"
14
15CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument)
16 : CXFA_TreeList(pDocument) {}
17
18CXFA_ArrayNodeList::~CXFA_ArrayNodeList() = default;
19
20void CXFA_ArrayNodeList::Trace(cppgc::Visitor* visitor) const {
21 CXFA_TreeList::Trace(visitor);
22 ContainerTrace(visitor, m_array);
23}
24
25void CXFA_ArrayNodeList::SetArrayNodeList(
26 const std::vector<CXFA_Node*>& srcArray) {
27 if (!srcArray.empty()) {
28 m_array =
29 std::vector<cppgc::Member<CXFA_Node>>(srcArray.begin(), srcArray.end());
30 }
31}
32
33size_t CXFA_ArrayNodeList::GetLength() {
34 return m_array.size();
35}
36
37bool CXFA_ArrayNodeList::Append(CXFA_Node* pNode) {
38 m_array.push_back(pNode);
39 return true;
40}
41
42bool CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) {
43 if (!pBeforeNode) {
44 m_array.push_back(pNewNode);
45 return true;
46 }
47
48 auto it = std::find(m_array.begin(), m_array.end(), pBeforeNode);
49 if (it == m_array.end())
50 return false;
51
52 m_array.insert(it, pNewNode);
53 return true;
54}
55
56void CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) {
57 auto it = std::find(m_array.begin(), m_array.end(), pNode);
58 if (it != m_array.end())
59 m_array.erase(it);
60}
61
62CXFA_Node* CXFA_ArrayNodeList::Item(size_t index) {
63 return index < m_array.size() ? m_array[index] : nullptr;
64}
size_t GetLength() override
CXFA_Node * Item(size_t iIndex) override
~CXFA_ArrayNodeList() override
bool Append(CXFA_Node *pNode) override
void SetArrayNodeList(const std::vector< CXFA_Node * > &srcArray)
void Remove(CXFA_Node *pNode) override
void Trace(cppgc::Visitor *visitor) const override
bool Insert(CXFA_Node *pNewNode, CXFA_Node *pBeforeNode) override
virtual void Trace(cppgc::Visitor *visitor) const
CXFA_TreeList(CXFA_Document *pDocument)
Definition heap.h:12