Coverage Report

Created: 2026-06-13 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/xerces-c/src/xercesc/util/EncodingValidator.cpp
Line
Count
Source
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
/*
19
 * $Id: EncodingValidator.cpp 1798771 2017-06-14 21:31:52Z rleigh $
20
 */
21
22
// ---------------------------------------------------------------------------
23
//  Includes
24
// ---------------------------------------------------------------------------
25
#include <xercesc/util/EncodingValidator.hpp>
26
#include <xercesc/internal/IANAEncodings.hpp>
27
#include <xercesc/util/XMLInitializer.hpp>
28
29
XERCES_CPP_NAMESPACE_BEGIN
30
31
EncodingValidator* EncodingValidator::fInstance = 0;
32
33
void XMLInitializer::initializeEncodingValidator()
34
2
{
35
2
    EncodingValidator::fInstance = new EncodingValidator();
36
2
}
37
38
void XMLInitializer::terminateEncodingValidator()
39
0
{
40
0
    delete EncodingValidator::fInstance;
41
0
    EncodingValidator::fInstance = 0;
42
0
}
43
44
// ---------------------------------------------------------------------------
45
//  EncodingValidator: Constructors and Destructor
46
// ---------------------------------------------------------------------------
47
EncodingValidator::EncodingValidator() :
48
2
    fEncodingRegistry(0)
49
2
{
50
2
    initializeRegistry();
51
2
}
52
53
0
EncodingValidator::~EncodingValidator() {
54
55
0
    delete fEncodingRegistry;
56
0
    fEncodingRegistry = 0;
57
0
}
58
59
// ---------------------------------------------------------------------------
60
//  EncodingValidator: Validation methods
61
// ---------------------------------------------------------------------------
62
0
bool EncodingValidator::isValidEncoding(const XMLCh* const encName) {
63
64
0
    if (fEncodingRegistry->containsKey(encName))
65
0
    return true;
66
67
0
  return false;
68
0
}
69
70
71
// ---------------------------------------------------------------------------
72
//  EncodingValidator: Initialization methods
73
// ---------------------------------------------------------------------------
74
2
void EncodingValidator::initializeRegistry() {
75
76
2
    fEncodingRegistry = new ValueHashTableOf<bool>(109);
77
78
1.58k
    for (unsigned int i=0; i < gEncodingArraySize; i++) {
79
1.58k
        fEncodingRegistry->put(const_cast<void *>(reinterpret_cast<const void *>(gEncodingArray[i])), true);
80
1.58k
    }
81
2
}
82
83
84
// ---------------------------------------------------------------------------
85
//  EncodingValidator: Instance methods
86
// ---------------------------------------------------------------------------
87
EncodingValidator* EncodingValidator::instance()
88
0
{
89
0
    return fInstance;
90
0
}
91
92
XERCES_CPP_NAMESPACE_END
93
94
/**
95
  * End of file EncodingValidator.cpp
96
  */