aboutsummaryrefslogtreecommitdiff
path: root/src/support/include_entity_resolver.h
blob: ea5fb7a91b9f4aa4e639f2e7a8c9a4e376041d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef INPUTXSLT_SRC_SUPPORT_INCLUDE_ENTITY_RESOLVER_H_
#define INPUTXSLT_SRC_SUPPORT_INCLUDE_ENTITY_RESOLVER_H_

#include <xercesc/sax/EntityResolver.hpp>
#include <xercesc/sax/InputSource.hpp>

#include "boost/optional.hpp"

#include <string>
#include <vector>

#include "filesystem_context.h"

namespace InputXSLT {

class IncludeEntityResolver : public xercesc::EntityResolver {
	public:
		static boost::filesystem::path getPathFromSystemId(const XMLCh* const);

		IncludeEntityResolver(const std::vector<std::string>&);

		xercesc::InputSource* resolveEntity(
			const XMLCh* const,
			const XMLCh* const
		);

		boost::optional<boost::filesystem::path> resolve(
			const std::string&) const;

	private:
		const std::vector<FilesystemContext> path_;

		boost::optional<boost::filesystem::path> tryIncludePaths(
			const boost::filesystem::path&) const;


};

}

#endif  // INPUTXSLT_SRC_SUPPORT_INCLUDE_ENTITY_RESOLVER_H_