Remove trailing whitespaces in core.
[pdfium.git] / core / include / fxcrt / fx_xml.h
index 1217677..ba33b20 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#ifndef _FX_XML_H_\r
-#define _FX_XML_H_\r
-#ifndef _FX_BASIC_H_\r
-#include "fx_basic.h"\r
-#endif\r
-class CXML_AttrItem : public CFX_Object\r
-{\r
-public:\r
-    CFX_ByteStringL    m_QSpaceName;\r
-    CFX_ByteStringL    m_AttrName;\r
-    CFX_WideStringL    m_Value;\r
-\r
-    void       Empty(IFX_Allocator* pAllocator = NULL)\r
-    {\r
-        m_QSpaceName.Empty(pAllocator);\r
-        m_AttrName.Empty(pAllocator);\r
-        m_Value.Empty(pAllocator);\r
-    }\r
-};\r
-class CXML_AttrMap : public CFX_Object\r
-{\r
-public:\r
-    CXML_AttrMap()\r
-    {\r
-        m_pMap = NULL;\r
-    }\r
-    ~CXML_AttrMap()\r
-    {\r
-        RemoveAll(NULL);\r
-    }\r
-    const CFX_WideStringL*     Lookup(FX_BSTR space, FX_BSTR name) const;\r
-    void                                       SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value, IFX_Allocator* pAllocator = NULL);\r
-    void                                       RemoveAt(FX_BSTR space, FX_BSTR name, IFX_Allocator* pAllocator = NULL);\r
-    void                                       RemoveAll(IFX_Allocator* pAllocator = NULL);\r
-    int                                                GetSize() const;\r
-    CXML_AttrItem&                     GetAt(int index) const;\r
-    CFX_ObjectArray<CXML_AttrItem>*    m_pMap;\r
-};\r
-class CXML_Content : public CFX_Object\r
-{\r
-public:\r
-    CXML_Content() : m_bCDATA(FALSE), m_Content() {}\r
-    ~CXML_Content()\r
-    {\r
-        Empty(NULL);\r
-    }\r
-    void       Empty(IFX_Allocator* pAllocator = NULL)\r
-    {\r
-        m_Content.Empty(pAllocator);\r
-    }\r
-    void       Set(FX_BOOL bCDATA, FX_WSTR content, IFX_Allocator* pAllocator = NULL)\r
-    {\r
-        m_bCDATA = bCDATA;\r
-        m_Content.Set(content, pAllocator);\r
-    }\r
-    FX_BOOL                    m_bCDATA;\r
-    CFX_WideStringL    m_Content;\r
-};\r
-class CXML_Element : public CFX_Object\r
-{\r
-public:\r
-\r
-    static CXML_Element*       Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);\r
-\r
-    static CXML_Element*       Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);\r
-\r
-    static CXML_Element*       Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);\r
-\r
-    CXML_Element(FX_BSTR qSpace, FX_BSTR tagName, IFX_Allocator* pAllocator = NULL);\r
-\r
-    CXML_Element(FX_BSTR qTagName, IFX_Allocator* pAllocator = NULL);\r
-\r
-    CXML_Element(IFX_Allocator* pAllocator = NULL);\r
-\r
-    ~CXML_Element();\r
-\r
-    void       Empty();\r
-\r
-\r
-\r
-    CFX_ByteString                     GetTagName(FX_BOOL bQualified = FALSE) const;\r
-    void                                       GetTagName(CFX_ByteStringL &tagName, FX_BOOL bQualified = FALSE) const;\r
-\r
-    CFX_ByteString                     GetNamespace(FX_BOOL bQualified = FALSE) const;\r
-    void                                       GetNamespace(CFX_ByteStringL &nameSpace, FX_BOOL bQualified = FALSE) const;\r
-\r
-    CFX_ByteString                     GetNamespaceURI(FX_BSTR qName) const;\r
-    void                                       GetNamespaceURI(FX_BSTR qName, CFX_ByteStringL &uri) const;\r
-\r
-    CXML_Element*                      GetParent() const\r
-    {\r
-        return m_pParent;\r
-    }\r
-\r
-    FX_DWORD                           CountAttrs() const\r
-    {\r
-        return m_AttrMap.GetSize();\r
-    }\r
-\r
-    void                                       GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;\r
-    void                                       GetAttrByIndex(int index, CFX_ByteStringL &space, CFX_ByteStringL &name, CFX_WideStringL &value) const;\r
-\r
-    FX_BOOL                                    HasAttr(FX_BSTR qName) const;\r
-\r
-    FX_BOOL                                    GetAttrValue(FX_BSTR name, CFX_WideString& attribute) const;\r
-    CFX_WideString                     GetAttrValue(FX_BSTR name) const\r
-    {\r
-        CFX_WideString attr;\r
-        GetAttrValue(name, attr);\r
-        return attr;\r
-    }\r
-    const CFX_WideStringL*     GetAttrValuePtr(FX_BSTR name) const;\r
-\r
-    FX_BOOL                                    GetAttrValue(FX_BSTR space, FX_BSTR name, CFX_WideString& attribute) const;\r
-    CFX_WideString                     GetAttrValue(FX_BSTR space, FX_BSTR name) const\r
-    {\r
-        CFX_WideString attr;\r
-        GetAttrValue(space, name, attr);\r
-        return attr;\r
-    }\r
-    const CFX_WideStringL*     GetAttrValuePtr(FX_BSTR space, FX_BSTR name) const;\r
-\r
-    FX_BOOL                                    GetAttrInteger(FX_BSTR name, int& attribute) const;\r
-    int                                                GetAttrInteger(FX_BSTR name) const\r
-    {\r
-        int attr = 0;\r
-        GetAttrInteger(name, attr);\r
-        return attr;\r
-    }\r
-\r
-    FX_BOOL                                    GetAttrInteger(FX_BSTR space, FX_BSTR name, int& attribute) const;\r
-    int                                                GetAttrInteger(FX_BSTR space, FX_BSTR name) const\r
-    {\r
-        int attr = 0;\r
-        GetAttrInteger(space, name, attr);\r
-        return attr;\r
-    }\r
-\r
-    FX_BOOL                                    GetAttrFloat(FX_BSTR name, FX_FLOAT& attribute) const;\r
-    FX_FLOAT                           GetAttrFloat(FX_BSTR name) const\r
-    {\r
-        FX_FLOAT attr = 0;\r
-        GetAttrFloat(name, attr);\r
-        return attr;\r
-    }\r
-\r
-    FX_BOOL                                    GetAttrFloat(FX_BSTR space, FX_BSTR name, FX_FLOAT& attribute) const;\r
-    FX_FLOAT                           GetAttrFloat(FX_BSTR space, FX_BSTR name) const\r
-    {\r
-        FX_FLOAT attr = 0;\r
-        GetAttrFloat(space, name, attr);\r
-        return attr;\r
-    }\r
-\r
-    FX_DWORD                           CountChildren() const;\r
-\r
-    enum ChildType { Invalid, Element, Content};\r
-\r
-    ChildType                          GetChildType(FX_DWORD index) const;\r
-\r
-    CFX_WideString                     GetContent(FX_DWORD index) const;\r
-    const CFX_WideStringL*     GetContentPtr(FX_DWORD index) const;\r
-\r
-    CXML_Element*                      GetElement(FX_DWORD index) const;\r
-\r
-    CXML_Element*                      GetElement(FX_BSTR space, FX_BSTR tag) const\r
-    {\r
-        return GetElement(space, tag, 0);\r
-    }\r
-\r
-    FX_DWORD                           CountElements(FX_BSTR space, FX_BSTR tag) const;\r
-\r
-    CXML_Element*                      GetElement(FX_BSTR space, FX_BSTR tag, int index) const;\r
-\r
-    FX_DWORD                           FindElement(CXML_Element *pChild) const;\r
-\r
-\r
-\r
-\r
-    void                                       SetTag(FX_BSTR qSpace, FX_BSTR tagname);\r
-\r
-    void                                       SetTag(FX_BSTR qTagName);\r
-\r
-    void                                       RemoveChildren();\r
-\r
-    void                                       RemoveChild(FX_DWORD index);\r
-\r
-\r
-protected:\r
-\r
-    CXML_Element*                      m_pParent;\r
-\r
-    CFX_ByteStringL                    m_QSpaceName;\r
-\r
-    CFX_ByteStringL                    m_TagName;\r
-\r
-    CXML_AttrMap                       m_AttrMap;\r
-\r
-    CFX_PtrArray                       m_Children;\r
-    friend class CXML_Parser;\r
-    friend class CXML_Composer;\r
-};\r
-#endif\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_INCLUDE_FXCRT_FX_XML_H_
+#define CORE_INCLUDE_FXCRT_FX_XML_H_
+
+#include "fx_basic.h"
+
+class CXML_AttrItem
+{
+public:
+    CFX_ByteString     m_QSpaceName;
+    CFX_ByteString     m_AttrName;
+    CFX_WideString     m_Value;
+};
+class CXML_AttrMap
+{
+public:
+    CXML_AttrMap()
+    {
+        m_pMap = NULL;
+    }
+    ~CXML_AttrMap()
+    {
+        RemoveAll();
+    }
+    const CFX_WideString*      Lookup(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const;
+    void                                       SetAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name, const CFX_WideStringC& value);
+    void                                       RemoveAt(const CFX_ByteStringC& space, const CFX_ByteStringC& name);
+    void                                       RemoveAll();
+    int                                                GetSize() const;
+    CXML_AttrItem&                     GetAt(int index) const;
+    CFX_ObjectArray<CXML_AttrItem>*    m_pMap;
+};
+class CXML_Content
+{
+public:
+    CXML_Content() : m_bCDATA(FALSE), m_Content() {}
+    void       Set(FX_BOOL bCDATA, const CFX_WideStringC& content)
+    {
+        m_bCDATA = bCDATA;
+        m_Content = content;
+    }
+    FX_BOOL                    m_bCDATA;
+    CFX_WideString     m_Content;
+};
+class CXML_Element
+{
+public:
+    static CXML_Element*       Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+    static CXML_Element*       Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+    static CXML_Element*       Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+    CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName);
+    CXML_Element(const CFX_ByteStringC& qTagName);
+    CXML_Element();
+
+    ~CXML_Element();
+
+    void       Empty();
+
+
+
+    CFX_ByteString                     GetTagName(FX_BOOL bQualified = FALSE) const;
+
+    CFX_ByteString                     GetNamespace(FX_BOOL bQualified = FALSE) const;
+
+    CFX_ByteString                     GetNamespaceURI(const CFX_ByteStringC& qName) const;
+
+    CXML_Element*                      GetParent() const
+    {
+        return m_pParent;
+    }
+
+    FX_DWORD                           CountAttrs() const
+    {
+        return m_AttrMap.GetSize();
+    }
+
+    void                                       GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
+
+    FX_BOOL                                    HasAttr(const CFX_ByteStringC& qName) const;
+
+    FX_BOOL                                    GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const;
+    CFX_WideString                     GetAttrValue(const CFX_ByteStringC& name) const
+    {
+        CFX_WideString attr;
+        GetAttrValue(name, attr);
+        return attr;
+    }
+
+    FX_BOOL                                    GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const;
+    CFX_WideString                     GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
+    {
+        CFX_WideString attr;
+        GetAttrValue(space, name, attr);
+        return attr;
+    }
+
+    FX_BOOL                                    GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const;
+    int                                                GetAttrInteger(const CFX_ByteStringC& name) const
+    {
+        int attr = 0;
+        GetAttrInteger(name, attr);
+        return attr;
+    }
+
+    FX_BOOL                                    GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const;
+    int                                                GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
+    {
+        int attr = 0;
+        GetAttrInteger(space, name, attr);
+        return attr;
+    }
+
+    FX_BOOL                                    GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
+    FX_FLOAT                           GetAttrFloat(const CFX_ByteStringC& name) const
+    {
+        FX_FLOAT attr = 0;
+        GetAttrFloat(name, attr);
+        return attr;
+    }
+
+    FX_BOOL                                    GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const;
+    FX_FLOAT                           GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const
+    {
+        FX_FLOAT attr = 0;
+        GetAttrFloat(space, name, attr);
+        return attr;
+    }
+
+    FX_DWORD                           CountChildren() const;
+
+    enum ChildType { Invalid, Element, Content};
+
+    ChildType                          GetChildType(FX_DWORD index) const;
+
+    CFX_WideString                     GetContent(FX_DWORD index) const;
+
+    CXML_Element*                      GetElement(FX_DWORD index) const;
+
+    CXML_Element*                      GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag) const
+    {
+        return GetElement(space, tag, 0);
+    }
+
+    FX_DWORD                           CountElements(const CFX_ByteStringC& space, const CFX_ByteStringC& tag) const;
+
+    CXML_Element*                      GetElement(const CFX_ByteStringC& space, const CFX_ByteStringC& tag, int index) const;
+
+    FX_DWORD                           FindElement(CXML_Element *pChild) const;
+
+
+
+
+    void                                       SetTag(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagname);
+
+    void                                       SetTag(const CFX_ByteStringC& qTagName);
+
+    void                                       RemoveChildren();
+
+    void                                       RemoveChild(FX_DWORD index);
+
+
+protected:
+
+    CXML_Element*                      m_pParent;
+    CFX_ByteString                     m_QSpaceName;
+    CFX_ByteString                     m_TagName;
+
+    CXML_AttrMap                       m_AttrMap;
+
+    CFX_PtrArray                       m_Children;
+    friend class CXML_Parser;
+    friend class CXML_Composer;
+};
+
+#endif  // CORE_INCLUDE_FXCRT_FX_XML_H_