XmlResolver.h
1 /*
2  * Copyright (C) 2012 Marc Boris Duerner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  */
28 
29 #ifndef Pt_Xml_XmlResolver_h
30 #define Pt_Xml_XmlResolver_h
31 
32 #include <Pt/Xml/Api.h>
33 #include <Pt/Xml/XmlError.h>
34 #include <Pt/String.h>
35 #include <Pt/TextCodec.h>
36 
37 namespace Pt {
38 
39 namespace Xml {
40 
41 class ByteorderMark;
42 class InputSource;
43 class XmlDeclaration;
44 
54 {
55  public:
58  virtual ~XmlResolver()
59  {}
60 
63  InputSource* resolveInput(const Pt::String& publicId,
64  const Pt::String& systemId)
65  {
66  return onResolveInput(publicId, systemId);
67  }
68 
72  {
73  onReleaseInput(is);
74  }
75 
82  const XmlDeclaration& decl)
83  {
84  return onResolveEncoding(bom, decl);
85  }
86 
87  protected:
91  {}
92 
95  virtual InputSource* onResolveInput(const Pt::String& publicId,
96  const Pt::String& systemId) = 0;
97 
100  virtual void onReleaseInput(InputSource* is) = 0;
101 
108  const XmlDeclaration& decl)
109  { return 0; }
110 };
111 
112 } // namespace Xml
113 
114 } // namespace Pt
115 
116 #endif // Pt_Xml_XmlResolver_h
XML byte order mark.
Definition: ByteorderMark.h:40
Input source for the XML reader.
Definition: InputSource.h:60
InputSource * resolveInput(const Pt::String &publicId, const Pt::String &systemId)
Returns an input source for the given IDs.
Definition: XmlResolver.h:63
virtual TextCodec< Char, char > * onResolveEncoding(const ByteorderMark &bom, const XmlDeclaration &decl)
Returns a text codec for an encoding string.
Definition: XmlResolver.h:107
TextCodec< Char, char > * resolveEncoding(const ByteorderMark &bom, const XmlDeclaration &decl)
Returns a text codec for an encoding string.
Definition: XmlResolver.h:81
XML declaration of an XML document.
Definition: XmlDeclaration.h:42
virtual InputSource * onResolveInput(const Pt::String &publicId, const Pt::String &systemId)=0
Returns an input source for the given IDs.
virtual ~XmlResolver()
Destructor.
Definition: XmlResolver.h:58
Unicode capable basic_string.
Definition: String.h:42
Resolves external entities and DTDs.
Definition: XmlResolver.h:53
void releaseInput(InputSource *is)
Releases an input source resolved by this resolver.
Definition: XmlResolver.h:71
virtual void onReleaseInput(InputSource *is)=0
Releases an input source resolved by this resolver.
XmlResolver()
Default constructor.
Definition: XmlResolver.h:90