Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: xfa/fgas/crt/fgas_utils.h

Issue 1944893003: Remove unused CFX_CPLTree<> template (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef XFA_FGAS_CRT_FGAS_UTILS_H_ 7 #ifndef XFA_FGAS_CRT_FGAS_UTILS_H_
8 #define XFA_FGAS_CRT_FGAS_UTILS_H_ 8 #define XFA_FGAS_CRT_FGAS_UTILS_H_
9 9
10 #include "core/fxcrt/include/fx_coordinates.h" 10 #include "core/fxcrt/include/fx_coordinates.h"
11 #include "xfa/fgas/crt/fgas_memory.h" 11 #include "xfa/fgas/crt/fgas_memory.h"
12 12
13 class FX_BASEARRAYDATA; 13 class FX_BASEARRAYDATA;
14 14
15 template <class baseType>
16 class CFX_CPLTree;
17
18 class CFX_BaseArray : public CFX_Target { 15 class CFX_BaseArray : public CFX_Target {
19 protected: 16 protected:
20 CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); 17 CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize);
21 ~CFX_BaseArray(); 18 ~CFX_BaseArray();
22 int32_t GetSize() const; 19 int32_t GetSize() const;
23 int32_t GetBlockSize() const; 20 int32_t GetBlockSize() const;
24 uint8_t* AddSpaceTo(int32_t index); 21 uint8_t* AddSpaceTo(int32_t index);
25 uint8_t* GetAt(int32_t index) const; 22 uint8_t* GetAt(int32_t index) const;
26 uint8_t* GetBuffer() const; 23 uint8_t* GetBuffer() const;
27 int32_t Append(const CFX_BaseArray& src, 24 int32_t Append(const CFX_BaseArray& src,
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 iEnd = iSize; 486 iEnd = iSize;
490 } 487 }
491 RemoveAll(TRUE); 488 RemoveAll(TRUE);
492 for (int32_t i = iStart; i < iEnd; i++) { 489 for (int32_t i = iStart; i < iEnd; i++) {
493 Push(*src.GetAt(i)); 490 Push(*src.GetAt(i));
494 } 491 }
495 return CFX_BaseStack::GetSize(); 492 return CFX_BaseStack::GetSize();
496 } 493 }
497 }; 494 };
498 495
499 template <class baseType>
500 class CFX_CPLTreeNode : public CFX_Target {
501 public:
502 typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
503 CFX_CPLTreeNode()
504 : m_pParentNode(NULL),
505 m_pChildNode(NULL),
506 m_pPrevNode(NULL),
507 m_pNextNode(NULL),
508 m_Data() {}
509 enum TreeNode {
510 Root = 0,
511 Parent,
512 FirstSibling,
513 PreviousSibling,
514 NextSibling,
515 LastSibling,
516 FirstNeighbor,
517 PreviousNeighbor,
518 NextNeighbor,
519 LastNeighbor,
520 FirstChild,
521 LastChild
522 };
523 CPLTreeNode* GetNode(TreeNode eNode) const {
524 switch (eNode) {
525 case Root: {
526 CPLTreeNode* pParent = (CPLTreeNode*)this;
527 CPLTreeNode* pTemp;
528 while ((pTemp = pParent->m_pParentNode) != NULL) {
529 pParent = pTemp;
530 }
531 return pParent;
532 }
533 case Parent:
534 return m_pParentNode;
535 case FirstSibling: {
536 CPLTreeNode* pNode = (CPLTreeNode*)this;
537 CPLTreeNode* pTemp;
538 while ((pTemp = pNode->m_pPrevNode) != NULL) {
539 pNode = pTemp;
540 }
541 return pNode == (CPLTreeNode*)this ? NULL : pNode;
542 }
543 case PreviousSibling:
544 return m_pPrevNode;
545 case NextSibling:
546 return m_pNextNode;
547 case LastSibling: {
548 CPLTreeNode* pNode = (CPLTreeNode*)this;
549 CPLTreeNode* pTemp;
550 while ((pTemp = pNode->m_pNextNode) != NULL) {
551 pNode = pTemp;
552 }
553 return pNode == (CPLTreeNode*)this ? NULL : pNode;
554 }
555 case FirstNeighbor: {
556 CPLTreeNode* pParent = (CPLTreeNode*)this;
557 CPLTreeNode* pTemp;
558 while ((pTemp = pParent->m_pParentNode) != NULL) {
559 pParent = pTemp;
560 }
561 return pParent == (CPLTreeNode*)this ? NULL : pParent;
562 }
563 case PreviousNeighbor: {
564 if (m_pPrevNode == NULL) {
565 return m_pParentNode;
566 }
567 CPLTreeNode* pNode = m_pPrevNode;
568 CPLTreeNode* pTemp;
569 while ((pTemp = pNode->m_pChildNode) != NULL) {
570 pNode = pTemp;
571 while ((pTemp = pNode->m_pNextNode) != NULL) {
572 pNode = pTemp;
573 }
574 }
575 return pNode;
576 }
577 case NextNeighbor: {
578 if (m_pChildNode != NULL) {
579 return m_pChildNode;
580 }
581 if (m_pNextNode != NULL) {
582 return m_pNextNode;
583 }
584 CPLTreeNode* pNode = m_pParentNode;
585 while (pNode != NULL) {
586 if (pNode->m_pNextNode != NULL) {
587 return pNode->m_pNextNode;
588 }
589 pNode = pNode->m_pParentNode;
590 }
591 return NULL;
592 }
593 case LastNeighbor: {
594 CPLTreeNode* pNode = (CPLTreeNode*)this;
595 CPLTreeNode* pTemp;
596 while ((pTemp = pNode->m_pParentNode) != NULL) {
597 pNode = pTemp;
598 }
599 while (TRUE) {
600 CPLTreeNode* pTemp;
601 while ((pTemp = pNode->m_pNextNode) != NULL) {
602 pNode = pTemp;
603 }
604 if (pNode->m_pChildNode == NULL) {
605 break;
606 }
607 pNode = pNode->m_pChildNode;
608 }
609 return pNode == (CPLTreeNode*)this ? NULL : pNode;
610 }
611 case FirstChild:
612 return m_pChildNode;
613 case LastChild: {
614 if (m_pChildNode == NULL) {
615 return NULL;
616 }
617 CPLTreeNode* pChild = m_pChildNode;
618 CPLTreeNode* pTemp;
619 while ((pTemp = pChild->m_pNextNode) != NULL) {
620 pChild = pTemp;
621 }
622 return pChild;
623 }
624 default:
625 break;
626 }
627 return NULL;
628 }
629 void SetParentNode(CPLTreeNode* pNode) { m_pParentNode = pNode; }
630 int32_t CountChildNodes() const {
631 int32_t iCount = 0;
632 CPLTreeNode* pNode = m_pChildNode;
633 while (pNode) {
634 iCount++;
635 pNode = pNode->m_pNextNode;
636 }
637 return iCount;
638 }
639 CPLTreeNode* GetChildNode(int32_t iIndex) const {
640 int32_t iCount = 0;
641 CPLTreeNode* pNode = m_pChildNode;
642 while (pNode) {
643 if (iIndex == iCount) {
644 return pNode;
645 }
646 iCount++;
647 pNode = pNode->m_pNextNode;
648 }
649 return NULL;
650 }
651 int32_t GetNodeIndex() const {
652 int32_t index = 0;
653 CPLTreeNode* pNode = m_pPrevNode;
654 while (pNode != NULL) {
655 index++;
656 pNode = pNode->m_pPrevNode;
657 }
658 return index;
659 }
660 FX_BOOL IsParentNode(const CPLTreeNode* pNode) const {
661 CPLTreeNode* pParent = m_pParentNode;
662 while (pParent != NULL) {
663 if (pParent == pNode) {
664 return TRUE;
665 }
666 pParent = pParent->GetTreeNode(Parent);
667 }
668 return FALSE;
669 }
670 FX_BOOL IsChildNode(const CPLTreeNode* pNode) const {
671 if (pNode == NULL) {
672 return FALSE;
673 }
674 return pNode->IsParentNode((const CPLTreeNode*)this);
675 }
676 void SetChildNode(CPLTreeNode* pNode) { m_pChildNode = pNode; }
677 void SetPrevNode(CPLTreeNode* pNode) { m_pPrevNode = pNode; }
678 void SetNextNode(CPLTreeNode* pNode) { m_pNextNode = pNode; }
679 int32_t GetNodeLevel() const {
680 int32_t iLevel = 0;
681 CPLTreeNode* pNode = (CPLTreeNode*)this;
682 while ((pNode = pNode->m_pParentNode) != NULL) {
683 iLevel++;
684 }
685 return iLevel;
686 }
687 bool IsRootNode() const { return !m_pParentNode; }
688 baseType GetData() const { return m_Data; }
689 void SetData(baseType data) { m_Data = data; }
690
691 protected:
692 CPLTreeNode* m_pParentNode;
693 CPLTreeNode* m_pChildNode;
694 CPLTreeNode* m_pPrevNode;
695 CPLTreeNode* m_pNextNode;
696 baseType m_Data;
697 friend class CFX_CPLTree<baseType>;
698 };
699
700 template <class baseType>
701 class CFX_CPLTree {
702 public:
703 typedef CFX_CPLTreeNode<baseType> CPLTreeNode;
704 CFX_CPLTree() : m_Root() {}
705 ~CFX_CPLTree() {
706 CPLTreeNode* pNode = m_Root.GetNode(CPLTreeNode::LastNeighbor);
707 while (pNode != NULL) {
708 if (pNode->IsRootNode()) {
709 break;
710 }
711 CPLTreeNode* pTemp = pNode->GetNode(CPLTreeNode::PreviousNeighbor);
712 delete pNode;
713 pNode = pTemp;
714 }
715 }
716 CPLTreeNode* GetRoot() { return &m_Root; }
717 CPLTreeNode* AddChild(baseType data, CPLTreeNode* pParent = NULL) {
718 if (pParent == NULL) {
719 pParent = &m_Root;
720 }
721 CPLTreeNode* pChild = new CPLTreeNode;
722 pChild->SetParentNode(pParent);
723 pChild->SetData(data);
724 if (pParent->m_pChildNode == NULL) {
725 pParent->m_pChildNode = pChild;
726 } else {
727 CPLTreeNode* pLast = pParent->GetNode(CPLTreeNode::LastChild);
728 pChild->SetPrevNode(pLast);
729 pLast->SetNextNode(pChild);
730 }
731 return pChild;
732 }
733
734 protected:
735 CPLTreeNode m_Root;
736 };
737
738 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_ 496 #endif // XFA_FGAS_CRT_FGAS_UTILS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698