Coverage Report

Created: 2025-09-05 06:24

/src/poco/XML/src/EntityResolverImpl.cpp
Line
Count
Source (jump to first uncovered line)
1
//
2
// EntityResolverImpl.cpp
3
//
4
// Library: XML
5
// Package: SAX
6
// Module:  SAX
7
//
8
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9
// and Contributors.
10
//
11
// SPDX-License-Identifier: BSL-1.0
12
//
13
14
15
#include "Poco/SAX/EntityResolverImpl.h"
16
#include "Poco/SAX/InputSource.h"
17
#include "Poco/XML/XMLString.h"
18
#include "Poco/URI.h"
19
#include "Poco/Path.h"
20
#include "Poco/Exception.h"
21
22
23
using Poco::URIStreamOpener;
24
using Poco::URI;
25
using Poco::Path;
26
using Poco::Exception;
27
using Poco::IOException;
28
using Poco::OpenFileException;
29
30
31
namespace Poco {
32
namespace XML {
33
34
35
EntityResolverImpl::EntityResolverImpl():
36
70.7k
  _opener(URIStreamOpener::defaultOpener())
37
70.7k
{
38
70.7k
}
39
40
41
EntityResolverImpl::EntityResolverImpl(const URIStreamOpener& opener):
42
0
  _opener(opener)
43
0
{
44
0
}
45
46
47
EntityResolverImpl::~EntityResolverImpl()
48
70.7k
{
49
70.7k
}
50
51
52
InputSource* EntityResolverImpl::resolveEntity(const XMLString* publicId, const XMLString& systemId)
53
67.7k
{
54
67.7k
  std::istream* pIstr = resolveSystemId(systemId);
55
67.7k
  InputSource* pInputSource = new InputSource(systemId);
56
67.7k
  if (publicId) pInputSource->setPublicId(*publicId);
57
67.7k
  pInputSource->setByteStream(*pIstr);
58
67.7k
  return pInputSource;
59
67.7k
}
60
61
62
void EntityResolverImpl::releaseInputSource(InputSource* pSource)
63
62.7k
{
64
62.7k
  poco_check_ptr (pSource);
65
66
62.7k
  delete pSource->getByteStream();
67
62.7k
  delete pSource;
68
62.7k
}
69
70
71
std::istream* EntityResolverImpl::resolveSystemId(const XMLString& systemId)
72
67.7k
{
73
67.7k
  std::string sid = fromXMLString(systemId);
74
67.7k
  return _opener.open(sid);
75
67.7k
}
76
77
78
} } // namespace Poco::XML