source: icXML/icXML-devel/src/xercesc/validators/schema/identity/FieldActivator.cpp @ 3565

Last change on this file since 3565 was 3565, checked in by cameron, 6 years ago

Updates to xercesc sources

File size: 4.5 KB
Line 
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: FieldActivator.cpp 679340 2008-07-24 10:28:29Z borisk $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/validators/schema/identity/FieldActivator.hpp>
26#include <xercesc/validators/schema/identity/ValueStore.hpp>
27#include <xercesc/validators/schema/identity/ValueStoreCache.hpp>
28#include <xercesc/validators/schema/identity/XPathMatcherStack.hpp>
29#include <xercesc/util/StringPool.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33// ---------------------------------------------------------------------------
34//  FieldActivator: Constructors and Destructor
35// ---------------------------------------------------------------------------
36FieldActivator::FieldActivator(ValueStoreCache* const valueStoreCache,
37                               XPathMatcherStack* const matcherStack,
38                               MemoryManager* const manager)
39    : fValueStoreCache(valueStoreCache)
40    , fMatcherStack(matcherStack)
41    , fMayMatch(0)
42    , fMemoryManager(manager)
43{
44    fMayMatch = new (manager) ValueHashTableOf<bool, PtrHasher>(29, manager);
45}
46
47FieldActivator::FieldActivator(const FieldActivator& other)
48    : XMemory(other)
49    , fValueStoreCache(other.fValueStoreCache)
50    , fMatcherStack(other.fMatcherStack)
51    , fMayMatch(0)
52    , fMemoryManager(other.fMemoryManager)
53{
54    fMayMatch = new (fMemoryManager) ValueHashTableOf<bool, PtrHasher>(29, fMemoryManager);
55    ValueHashTableOfEnumerator<bool, PtrHasher> mayMatchEnum(other.fMayMatch, false, fMemoryManager);
56
57    // Build key set
58    while (mayMatchEnum.hasMoreElements())
59    {
60        IC_Field* field = (IC_Field*) mayMatchEnum.nextElementKey();
61        fMayMatch->put(field, other.fMayMatch->get(field));
62    }
63}
64
65
66FieldActivator::~FieldActivator()
67{
68    delete fMayMatch;
69}
70
71// ---------------------------------------------------------------------------
72//  FieldActivator: Operator methods
73// ---------------------------------------------------------------------------
74FieldActivator& FieldActivator::operator =(const FieldActivator& other) {
75
76    if (this == &other) {
77        return *this;
78    }
79
80    fValueStoreCache = other.fValueStoreCache;
81    fMatcherStack = other.fMatcherStack;
82    return *this;
83}
84
85// ---------------------------------------------------------------------------
86//  FieldActivator: Operator methods
87// ---------------------------------------------------------------------------
88XPathMatcher* FieldActivator::activateField(IC_Field* const field, XMLStringPool * const stringPool, const int initialDepth)
89{
90    ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth);
91    XPathMatcher* matcher = field->createMatcher(this, valueStore, stringPool, fMemoryManager);
92
93    setMayMatch(field, true);
94    fMatcherStack->addMatcher(matcher);
95    matcher->startDocumentFragment();
96
97    return matcher;
98}
99
100void FieldActivator::startValueScopeFor(const IdentityConstraint* const ic,
101                                        const int initialDepth) {
102
103    XMLSize_t fieldCount = ic->getFieldCount();
104
105    for(XMLSize_t i=0; i<fieldCount; i++) {
106
107        const IC_Field* field = ic->getFieldAt(i);
108        ValueStore* valueStore = fValueStoreCache->getValueStoreFor(field, initialDepth);
109
110        valueStore->startValueScope();
111    }
112}
113
114void FieldActivator::endValueScopeFor(const IdentityConstraint* const ic, const int initialDepth) {
115
116    ValueStore* valueStore = fValueStoreCache->getValueStoreFor(ic, initialDepth);
117
118    valueStore->endValueScope();
119}
120
121XPathMatcher* FieldActivator::activateField(IC_Field* const, const int)
122{
123    DEPRECATED_FEATURE_IN_ICXML;
124}
125
126XERCES_CPP_NAMESPACE_END
127
128/**
129  * End of file FieldActivator.cpp
130  */
Note: See TracBrowser for help on using the repository browser.