|
||||
File indexing completed on 2025-01-18 10:15:18
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_VALUESTORECACHE_HPP) 0023 #define XERCESC_INCLUDE_GUARD_VALUESTORECACHE_HPP 0024 0025 /** 0026 * This class is used to store the values for identity constraints. 0027 * 0028 * Sketch of algorithm: 0029 * - When a constraint is first encountered, its values are stored in the 0030 * (local) fIC2ValueStoreMap; 0031 * - Once it is validated (i.e., when it goes out of scope), its values are 0032 * merged into the fGlobalICMap; 0033 * - As we encounter keyref's, we look at the global table to validate them. 0034 * - Validation always occurs against the fGlobalIDConstraintMap (which 0035 * comprises all the "eligible" id constraints). When an endelement is 0036 * found, this Hashtable is merged with the one below in the stack. When a 0037 * start tag is encountered, we create a new fGlobalICMap. 0038 * i.e., the top of the fGlobalIDMapStack always contains the preceding 0039 * siblings' eligible id constraints; the fGlobalICMap contains 0040 * descendants+self. Keyrefs can only match descendants+self. 0041 */ 0042 0043 // --------------------------------------------------------------------------- 0044 // Includes 0045 // --------------------------------------------------------------------------- 0046 #include <xercesc/util/RefVectorOf.hpp> 0047 #include <xercesc/util/RefHashTableOf.hpp> 0048 #include <xercesc/util/RefHash2KeysTableOf.hpp> 0049 #include <xercesc/util/RefStackOf.hpp> 0050 #include <xercesc/validators/schema/identity/IdentityConstraint.hpp> 0051 #include <xercesc/validators/schema/identity/IC_Field.hpp> 0052 0053 XERCES_CPP_NAMESPACE_BEGIN 0054 0055 // --------------------------------------------------------------------------- 0056 // Forward Declaration 0057 // --------------------------------------------------------------------------- 0058 class ValueStore; 0059 class SchemaElementDecl; 0060 class XMLScanner; 0061 0062 0063 class VALIDATORS_EXPORT ValueStoreCache : public XMemory 0064 { 0065 public: 0066 // ----------------------------------------------------------------------- 0067 // Constructors/Destructor 0068 // ----------------------------------------------------------------------- 0069 ValueStoreCache(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); 0070 ~ValueStoreCache(); 0071 0072 // ----------------------------------------------------------------------- 0073 // Setter Methods 0074 // ----------------------------------------------------------------------- 0075 void setScanner(XMLScanner* const scanner); 0076 0077 // ----------------------------------------------------------------------- 0078 // Document Handling methods 0079 // ----------------------------------------------------------------------- 0080 void startDocument(); 0081 void startElement(); 0082 void endElement(); 0083 void endDocument(); 0084 0085 // ----------------------------------------------------------------------- 0086 // Initialization methods 0087 // ----------------------------------------------------------------------- 0088 void initValueStoresFor(SchemaElementDecl* const elemDecl, const int initialDepth); 0089 0090 0091 // ----------------------------------------------------------------------- 0092 // Access methods 0093 // ----------------------------------------------------------------------- 0094 ValueStore* getValueStoreFor(const IC_Field* const field, const int initialDepth); 0095 ValueStore* getValueStoreFor(const IdentityConstraint* const ic, const int initialDepth); 0096 ValueStore* getGlobalValueStoreFor(const IdentityConstraint* const ic); 0097 0098 // ----------------------------------------------------------------------- 0099 // Helper methods 0100 // ----------------------------------------------------------------------- 0101 /** This method takes the contents of the (local) ValueStore associated 0102 * with ic and moves them into the global hashtable, if ic is a <unique> 0103 * or a <key>. If it's a <keyRef>, then we leave it for later. 0104 */ 0105 void transplant(IdentityConstraint* const ic, const int initialDepth); 0106 0107 private: 0108 // ----------------------------------------------------------------------- 0109 // Unimplemented constructors and operators 0110 // ----------------------------------------------------------------------- 0111 ValueStoreCache(const ValueStoreCache& other); 0112 ValueStoreCache& operator= (const ValueStoreCache& other); 0113 0114 // ----------------------------------------------------------------------- 0115 // Helper methods 0116 // ----------------------------------------------------------------------- 0117 void init(); 0118 void cleanUp(); 0119 0120 // ----------------------------------------------------------------------- 0121 // Data 0122 // ----------------------------------------------------------------------- 0123 RefVectorOf<ValueStore>* fValueStores; 0124 RefHashTableOf<ValueStore, PtrHasher>* fGlobalICMap; 0125 RefHash2KeysTableOf<ValueStore, PtrHasher>* fIC2ValueStoreMap; 0126 RefStackOf<RefHashTableOf<ValueStore, PtrHasher> >* fGlobalMapStack; 0127 XMLScanner* fScanner; 0128 MemoryManager* fMemoryManager; 0129 }; 0130 0131 // --------------------------------------------------------------------------- 0132 // ValueStoreCache: Access methods 0133 // --------------------------------------------------------------------------- 0134 inline void ValueStoreCache::setScanner(XMLScanner* const scanner) { 0135 0136 fScanner = scanner; 0137 } 0138 0139 // --------------------------------------------------------------------------- 0140 // ValueStoreCache: Access methods 0141 // --------------------------------------------------------------------------- 0142 inline ValueStore* 0143 ValueStoreCache::getValueStoreFor(const IC_Field* const field, const int initialDepth) { 0144 0145 return fIC2ValueStoreMap->get(field->getIdentityConstraint(), initialDepth); 0146 } 0147 0148 inline ValueStore* 0149 ValueStoreCache::getValueStoreFor(const IdentityConstraint* const ic, const int initialDepth) { 0150 0151 return fIC2ValueStoreMap->get(ic, initialDepth); 0152 } 0153 0154 inline ValueStore* 0155 ValueStoreCache::getGlobalValueStoreFor(const IdentityConstraint* const ic) { 0156 0157 return fGlobalICMap->get(ic); 0158 } 0159 0160 // --------------------------------------------------------------------------- 0161 // ValueStoreCache: Document handling methods 0162 // --------------------------------------------------------------------------- 0163 inline void ValueStoreCache::endDocument() { 0164 } 0165 0166 XERCES_CPP_NAMESPACE_END 0167 0168 #endif 0169 0170 /** 0171 * End of file ValueStoreCache.hpp 0172 */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |