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