source: icXML/icXML-devel/src/xercesc/validators/schema/identity/IC_Field.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.9 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: IC_Field.cpp 471747 2006-11-06 14:31:56Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/validators/schema/identity/FieldActivator.hpp>
26#include <xercesc/validators/schema/identity/IC_Field.hpp>
27#include <xercesc/validators/schema/identity/ValueStore.hpp>
28#include <xercesc/validators/schema/identity/XercesXPath.hpp>
29#include <icxercesc/validators/schema/identity/IdentityConstraint.hpp>
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33// ---------------------------------------------------------------------------
34//  FieldMatcher: Constructors and Destructor
35// ---------------------------------------------------------------------------
36FieldMatcher::FieldMatcher
37(
38    XercesXPath* const      xpath
39    , IC_Field* const       aField
40    , ValueStore* const     valueStore
41    , FieldActivator* const fieldActivator
42    , XMLStringPool* const  stringPool
43    , MemoryManager* const  manager
44)
45: XPathMatcher(xpath, (IdentityConstraint*) 0, stringPool, manager)
46, fValueStore(valueStore)
47, fField(aField)
48, fFieldActivator(fieldActivator)
49{
50}
51
52
53// ---------------------------------------------------------------------------
54//  FieldMatcher: Match methods
55// ---------------------------------------------------------------------------
56void FieldMatcher::matched(const XMLCh* const content,
57                           DatatypeValidator* const dv,
58                           const bool isNil) {
59
60    if(isNil) {
61        fValueStore->reportNilError(fField->getIdentityConstraint());
62    }
63
64    fValueStore->addValue(fFieldActivator, fField, dv, content);
65
66    // once we've stored the value for this field, we set the mayMatch
67    // member to false so that, in the same scope, we don't match any more
68    // values (and throw an error instead).
69    fFieldActivator->setMayMatch(fField, false);
70}
71
72// ---------------------------------------------------------------------------
73//  IC_Field: Constructors and Destructor
74// ---------------------------------------------------------------------------
75IC_Field::IC_Field(XercesXPath* const xpath,
76                   IdentityConstraint* const identityConstraint)
77    : fXPath(xpath)
78    , fIdentityConstraint(identityConstraint)
79{
80
81}
82
83
84IC_Field::~IC_Field()
85{
86    delete fXPath;
87}
88
89// ---------------------------------------------------------------------------
90//  IC_Field: operators
91// ---------------------------------------------------------------------------
92bool IC_Field::operator== (const IC_Field& other) const {
93
94    return (*fXPath == *(other.fXPath));
95}
96
97bool IC_Field::operator!= (const IC_Field& other) const {
98
99    return !operator==(other);
100}
101
102// ---------------------------------------------------------------------------
103//  IC_Field: Factory methods
104// ---------------------------------------------------------------------------
105XPathMatcher* IC_Field::createMatcher(FieldActivator* const fieldActivator,
106                                      ValueStore* const valueStore,
107                                      XMLStringPool * const stringPool,
108                                      MemoryManager* const manager)
109{
110    return new (manager) FieldMatcher(fXPath, this, valueStore, fieldActivator, stringPool, manager);
111}
112
113/***
114 * Support for Serialization/De-serialization
115 ***/
116
117IMPL_XSERIALIZABLE_TOCREATE(IC_Field)
118
119void IC_Field::serialize(XSerializeEngine& serEng)
120{
121
122    if (serEng.isStoring())
123    {
124        serEng<<fXPath;
125       
126        IdentityConstraint::storeIC(serEng, fIdentityConstraint);
127    }
128    else
129    {
130        serEng>>fXPath;
131
132        fIdentityConstraint = IdentityConstraint::loadIC(serEng);
133    }
134
135}
136
137IC_Field::IC_Field(MemoryManager* const )
138:fXPath(0)
139,fIdentityConstraint(0)
140{
141}
142
143FieldMatcher::FieldMatcher(XercesXPath* const, IC_Field* const , ValueStore* const , FieldActivator* const , MemoryManager* const )
144: XPathMatcher(0, (IdentityConstraint*)0, 0, 0)
145{
146    DEPRECATED_FEATURE_IN_ICXML;
147}
148
149XPathMatcher* IC_Field::createMatcher(FieldActivator* const, ValueStore* const, MemoryManager* const)
150{
151    DEPRECATED_FEATURE_IN_ICXML;
152}
153
154
155XERCES_CPP_NAMESPACE_END
156
157/**
158  * End of file IC_Field.cpp
159  */
160
Note: See TracBrowser for help on using the repository browser.