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

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

Original Xerces files with import mods for icxercesc

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