Home | History | Annotate | Download | only in xml
      1 // Copyright 2017 PDFium Authors. All rights reserved.
      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_FXCRT_XML_CXML_OBJECT_H_
      8 #define CORE_FXCRT_XML_CXML_OBJECT_H_
      9 
     10 class CXML_Content;
     11 class CXML_Element;
     12 
     13 class CXML_Object {
     14  public:
     15   virtual ~CXML_Object();
     16 
     17   virtual CXML_Content* AsContent();
     18   virtual const CXML_Content* AsContent() const;
     19 
     20   virtual CXML_Element* AsElement();
     21   virtual const CXML_Element* AsElement() const;
     22 
     23  protected:
     24   CXML_Object() {}
     25 };
     26 
     27 inline CXML_Content* ToContent(CXML_Object* pObj) {
     28   return pObj ? pObj->AsContent() : nullptr;
     29 }
     30 
     31 inline const CXML_Content* ToContent(const CXML_Object* pObj) {
     32   return pObj ? pObj->AsContent() : nullptr;
     33 }
     34 
     35 inline CXML_Element* ToElement(CXML_Object* pObj) {
     36   return pObj ? pObj->AsElement() : nullptr;
     37 }
     38 
     39 inline const CXML_Element* ToElement(const CXML_Object* pObj) {
     40   return pObj ? pObj->AsElement() : nullptr;
     41 }
     42 
     43 #endif  // CORE_FXCRT_XML_CXML_OBJECT_H_
     44