source: icXML/icXML-devel/src/xercesc/validators/schema/identity/ValueStore.hpp @ 3565

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

Original Xerces files with import mods for icxercesc

File size: 5.6 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: ValueStore.hpp 932887 2010-04-11 13:04:59Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_VALUESTORE_HPP)
23#define XERCESC_INCLUDE_GUARD_VALUESTORE_HPP
24
25/**
26  * This class stores values associated to an identity constraint.
27  * Each value stored corresponds to a field declared for the identity
28  * constraint.
29  */
30
31// ---------------------------------------------------------------------------
32//  Includes
33// ---------------------------------------------------------------------------
34#include <xercesc/validators/schema/identity/FieldValueMap.hpp>
35#include <icxercesc/util/RefHashTableOf.hpp>
36
37XERCES_CPP_NAMESPACE_BEGIN
38
39// ---------------------------------------------------------------------------
40//  Forward Declaration
41// ---------------------------------------------------------------------------
42class FieldActivator;
43class IdentityConstraint;
44class XMLScanner;
45class ValueStoreCache;
46
47struct ICValueHasher
48{
49    ICValueHasher(MemoryManager* const manager) : fMemoryManager(manager) {}
50
51    XMLSize_t getHashVal(const void* key, XMLSize_t mod) const;
52    bool equals(const void *const key1, const void *const key2) const;
53
54    // -----------------------------------------------------------------------
55    //  Helper methods
56    // -----------------------------------------------------------------------
57    /**
58      * Returns whether a field associated <DatatypeValidator, String> value
59      * is a duplicate of another associated value.
60      * It is a duplicate only if either of these conditions are true:
61      * - The Datatypes are the same or related by derivation and the values
62      *   are in the same valuespace.
63      * - The datatypes are unrelated and the values are Stringwise identical.
64      */
65    bool isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
66                       DatatypeValidator* const dv2, const XMLCh* const val2) const;
67
68
69    MemoryManager* fMemoryManager;
70};
71
72class VALIDATORS_EXPORT ValueStore : public XMemory
73{
74public:
75    // -----------------------------------------------------------------------
76    //  Constructors/Destructor
77    // -----------------------------------------------------------------------
78    ValueStore(IdentityConstraint* const ic,
79               XMLScanner* const scanner,
80               MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
81        ~ValueStore();
82
83    // -----------------------------------------------------------------------
84    //  Getter methods
85    // -----------------------------------------------------------------------
86    IdentityConstraint* getIdentityConstraint() const;
87
88    // -----------------------------------------------------------------------
89    //  Helper methods
90    // -----------------------------------------------------------------------
91    void append(const ValueStore* const other);
92    void startValueScope();
93    void endValueScope();
94    void addValue(FieldActivator* const fieldActivator,
95                  IC_Field* const field,
96                  DatatypeValidator* const dv,
97                  const XMLCh* const value);
98    bool contains(const FieldValueMap* const other);
99    void clear();
100
101    // -----------------------------------------------------------------------
102    //  Document handling methods
103    // -----------------------------------------------------------------------
104    void endDocumentFragment(ValueStoreCache* const valueStoreCache);
105
106    // -----------------------------------------------------------------------
107    //  Error reporting methods
108    // -----------------------------------------------------------------------
109    void duplicateValue();
110    void reportNilError(IdentityConstraint* const ic);
111
112private:
113    // -----------------------------------------------------------------------
114    //  Unimplemented constructors and operators
115    // -----------------------------------------------------------------------
116    ValueStore(const ValueStore& other);
117    ValueStore& operator= (const ValueStore& other);
118
119    // -----------------------------------------------------------------------
120    //  Data
121    // -----------------------------------------------------------------------
122    bool                        fDoReportError;
123    XMLSize_t                   fValuesCount;
124    IdentityConstraint*         fIdentityConstraint;
125    FieldValueMap               fValues;
126    RefHashTableOf<FieldValueMap, ICValueHasher>* fValueTuples;
127    XMLScanner*                 fScanner; // for error reporting - REVISIT
128    MemoryManager*              fMemoryManager;
129};
130
131// ---------------------------------------------------------------------------
132//  ValueStore: Getter methods
133// ---------------------------------------------------------------------------
134inline IdentityConstraint*
135ValueStore::getIdentityConstraint() const {
136    return fIdentityConstraint;
137}
138
139XERCES_CPP_NAMESPACE_END
140
141#endif
142
143/**
144  * End of file ValueStore.hpp
145  */
146
Note: See TracBrowser for help on using the repository browser.