[2674] | 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 568078 2007-08-21 11:43:25Z amassari $ |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #if !defined(VALUESTORE_HPP) |
---|
| 23 | #define 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 <xercesc/util/RefVectorOf.hpp> |
---|
| 36 | |
---|
| 37 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 38 | |
---|
| 39 | // --------------------------------------------------------------------------- |
---|
| 40 | // Forward Declaration |
---|
| 41 | // --------------------------------------------------------------------------- |
---|
| 42 | class FieldActivator; |
---|
| 43 | class IdentityConstraint; |
---|
| 44 | class XMLScanner; |
---|
| 45 | class ValueStoreCache; |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | class VALIDATORS_EXPORT ValueStore : public XMemory |
---|
| 49 | { |
---|
| 50 | public: |
---|
| 51 | // ----------------------------------------------------------------------- |
---|
| 52 | // Constructors/Destructor |
---|
| 53 | // ----------------------------------------------------------------------- |
---|
| 54 | ValueStore(IdentityConstraint* const ic, |
---|
| 55 | XMLScanner* const scanner, |
---|
| 56 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 57 | ~ValueStore(); |
---|
| 58 | |
---|
| 59 | // ----------------------------------------------------------------------- |
---|
| 60 | // Getter methods |
---|
| 61 | // ----------------------------------------------------------------------- |
---|
| 62 | IdentityConstraint* getIdentityConstraint() const; |
---|
| 63 | |
---|
| 64 | // ----------------------------------------------------------------------- |
---|
| 65 | // Helper methods |
---|
| 66 | // ----------------------------------------------------------------------- |
---|
| 67 | void append(const ValueStore* const other); |
---|
| 68 | void startValueScope(); |
---|
| 69 | void endValueScope(); |
---|
| 70 | void addValue(FieldActivator* const fieldActivator, |
---|
| 71 | IC_Field* const field, |
---|
| 72 | DatatypeValidator* const dv, |
---|
| 73 | const XMLCh* const value); |
---|
| 74 | bool contains(const FieldValueMap* const other); |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | * @deprecated |
---|
| 78 | */ |
---|
| 79 | void addValue(IC_Field* const field, DatatypeValidator* const dv, |
---|
| 80 | const XMLCh* const value); |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | // ----------------------------------------------------------------------- |
---|
| 84 | // Document handling methods |
---|
| 85 | // ----------------------------------------------------------------------- |
---|
| 86 | void endDcocumentFragment(ValueStoreCache* const valueStoreCache); |
---|
| 87 | |
---|
| 88 | // ----------------------------------------------------------------------- |
---|
| 89 | // Error reporting methods |
---|
| 90 | // ----------------------------------------------------------------------- |
---|
| 91 | void duplicateValue(); |
---|
| 92 | void reportNilError(IdentityConstraint* const ic); |
---|
| 93 | |
---|
| 94 | private: |
---|
| 95 | // ----------------------------------------------------------------------- |
---|
| 96 | // Unimplemented contstructors and operators |
---|
| 97 | // ----------------------------------------------------------------------- |
---|
| 98 | ValueStore(const ValueStore& other); |
---|
| 99 | ValueStore& operator= (const ValueStore& other); |
---|
| 100 | |
---|
| 101 | // ----------------------------------------------------------------------- |
---|
| 102 | // Helper methods |
---|
| 103 | // ----------------------------------------------------------------------- |
---|
| 104 | /** |
---|
| 105 | * Returns whether a field associated <DatatypeValidator, String> value |
---|
| 106 | * is a duplicate of another associated value. |
---|
| 107 | * It is a duplicate only if either of these conditions are true: |
---|
| 108 | * - The Datatypes are the same or related by derivation and the values |
---|
| 109 | * are in the same valuespace. |
---|
| 110 | * - The datatypes are unrelated and the values are Stringwise identical. |
---|
| 111 | */ |
---|
| 112 | bool isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1, |
---|
| 113 | DatatypeValidator* const dv2, const XMLCh* const val2); |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | // ----------------------------------------------------------------------- |
---|
| 117 | // Data |
---|
| 118 | // ----------------------------------------------------------------------- |
---|
| 119 | bool fDoReportError; |
---|
| 120 | int fValuesCount; |
---|
| 121 | IdentityConstraint* fIdentityConstraint; |
---|
| 122 | FieldValueMap fValues; |
---|
| 123 | RefVectorOf<FieldValueMap>* fValueTuples; |
---|
| 124 | ValueStore* fKeyValueStore; |
---|
| 125 | XMLScanner* fScanner; // for error reporting - REVISIT |
---|
| 126 | MemoryManager* fMemoryManager; |
---|
| 127 | }; |
---|
| 128 | |
---|
| 129 | // --------------------------------------------------------------------------- |
---|
| 130 | // ValueStore: Getter methods |
---|
| 131 | // --------------------------------------------------------------------------- |
---|
| 132 | inline IdentityConstraint* |
---|
| 133 | ValueStore::getIdentityConstraint() const { |
---|
| 134 | return fIdentityConstraint; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | XERCES_CPP_NAMESPACE_END |
---|
| 138 | |
---|
| 139 | #endif |
---|
| 140 | |
---|
| 141 | /** |
---|
| 142 | * End of file ValueStore.hpp |
---|
| 143 | */ |
---|
| 144 | |
---|