[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
---|
| 5 | * reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | *
|
---|
| 14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer in
|
---|
| 16 | * the documentation and/or other materials provided with the
|
---|
| 17 | * distribution.
|
---|
| 18 | *
|
---|
| 19 | * 3. The end-user documentation included with the redistribution,
|
---|
| 20 | * if any, must include the following acknowledgment:
|
---|
| 21 | * "This product includes software developed by the
|
---|
| 22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
| 23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
| 24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
| 25 | *
|
---|
| 26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
| 27 | * not be used to endorse or promote products derived from this
|
---|
| 28 | * software without prior written permission. For written
|
---|
| 29 | * permission, please contact apache\@apache.org.
|
---|
| 30 | *
|
---|
| 31 | * 5. Products derived from this software may not be called "Apache",
|
---|
| 32 | * nor may "Apache" appear in their name, without prior written
|
---|
| 33 | * permission of the Apache Software Foundation.
|
---|
| 34 | *
|
---|
| 35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
| 36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
| 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
| 42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
| 45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 46 | * SUCH DAMAGE.
|
---|
| 47 | * ====================================================================
|
---|
| 48 | *
|
---|
| 49 | * This software consists of voluntary contributions made by many
|
---|
| 50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
| 51 | * originally based on software copyright (c) 2001, International
|
---|
| 52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
| 53 | * on the Apache Software Foundation, please see
|
---|
| 54 | * <http://www.apache.org/>.
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * $Id: ValueStore.hpp,v 1.6 2003/12/16 18:41:15 knoaman Exp $
|
---|
| 59 | */
|
---|
| 60 |
|
---|
| 61 | #if !defined(VALUESTORE_HPP)
|
---|
| 62 | #define VALUESTORE_HPP
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * This class stores values associated to an identity constraint.
|
---|
| 66 | * Each value stored corresponds to a field declared for the identity
|
---|
| 67 | * constraint.
|
---|
| 68 | */
|
---|
| 69 |
|
---|
| 70 | // ---------------------------------------------------------------------------
|
---|
| 71 | // Includes
|
---|
| 72 | // ---------------------------------------------------------------------------
|
---|
| 73 | #include <xercesc/validators/schema/identity/FieldValueMap.hpp>
|
---|
| 74 | #include <xercesc/util/RefVectorOf.hpp>
|
---|
| 75 |
|
---|
| 76 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 77 |
|
---|
| 78 | // ---------------------------------------------------------------------------
|
---|
| 79 | // Forward Declaration
|
---|
| 80 | // ---------------------------------------------------------------------------
|
---|
| 81 | class IdentityConstraint;
|
---|
| 82 | class XMLScanner;
|
---|
| 83 | class ValueStoreCache;
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | class VALIDATORS_EXPORT ValueStore : public XMemory
|
---|
| 87 | {
|
---|
| 88 | public:
|
---|
| 89 | // -----------------------------------------------------------------------
|
---|
| 90 | // Constructors/Destructor
|
---|
| 91 | // -----------------------------------------------------------------------
|
---|
| 92 | ValueStore(IdentityConstraint* const ic,
|
---|
| 93 | XMLScanner* const scanner,
|
---|
| 94 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
|
---|
| 95 | ~ValueStore();
|
---|
| 96 |
|
---|
| 97 | // -----------------------------------------------------------------------
|
---|
| 98 | // Getter methods
|
---|
| 99 | // -----------------------------------------------------------------------
|
---|
| 100 | IdentityConstraint* getIdentityConstraint() const;
|
---|
| 101 |
|
---|
| 102 | // -----------------------------------------------------------------------
|
---|
| 103 | // Helper methods
|
---|
| 104 | // -----------------------------------------------------------------------
|
---|
| 105 | void append(const ValueStore* const other);
|
---|
| 106 | void startValueScope();
|
---|
| 107 | void endValueScope();
|
---|
| 108 | void addValue(FieldActivator* const fieldActivator,
|
---|
| 109 | IC_Field* const field,
|
---|
| 110 | DatatypeValidator* const dv,
|
---|
| 111 | const XMLCh* const value);
|
---|
| 112 | bool contains(const FieldValueMap* const other);
|
---|
| 113 |
|
---|
| 114 | /**
|
---|
| 115 | * @deprecated
|
---|
| 116 | */
|
---|
| 117 | void addValue(IC_Field* const field, DatatypeValidator* const dv,
|
---|
| 118 | const XMLCh* const value);
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | // -----------------------------------------------------------------------
|
---|
| 122 | // Document handling methods
|
---|
| 123 | // -----------------------------------------------------------------------
|
---|
| 124 | void endDcocumentFragment(ValueStoreCache* const valueStoreCache);
|
---|
| 125 |
|
---|
| 126 | // -----------------------------------------------------------------------
|
---|
| 127 | // Error reporting methods
|
---|
| 128 | // -----------------------------------------------------------------------
|
---|
| 129 | void duplicateValue();
|
---|
| 130 | void reportNilError(IdentityConstraint* const ic);
|
---|
| 131 |
|
---|
| 132 | private:
|
---|
| 133 | // -----------------------------------------------------------------------
|
---|
| 134 | // Unimplemented contstructors and operators
|
---|
| 135 | // -----------------------------------------------------------------------
|
---|
| 136 | ValueStore(const ValueStore& other);
|
---|
| 137 | ValueStore& operator= (const ValueStore& other);
|
---|
| 138 |
|
---|
| 139 | // -----------------------------------------------------------------------
|
---|
| 140 | // Helper methods
|
---|
| 141 | // -----------------------------------------------------------------------
|
---|
| 142 | /**
|
---|
| 143 | * Returns whether a field associated <DatatypeValidator, String> value
|
---|
| 144 | * is a duplicate of another associated value.
|
---|
| 145 | * It is a duplicate only if either of these conditions are true:
|
---|
| 146 | * - The Datatypes are the same or related by derivation and the values
|
---|
| 147 | * are in the same valuespace.
|
---|
| 148 | * - The datatypes are unrelated and the values are Stringwise identical.
|
---|
| 149 | */
|
---|
| 150 | bool isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1,
|
---|
| 151 | DatatypeValidator* const dv2, const XMLCh* const val2);
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | // -----------------------------------------------------------------------
|
---|
| 155 | // Data
|
---|
| 156 | // -----------------------------------------------------------------------
|
---|
| 157 | bool fDoReportError;
|
---|
| 158 | int fValuesCount;
|
---|
| 159 | IdentityConstraint* fIdentityConstraint;
|
---|
| 160 | FieldValueMap fValues;
|
---|
| 161 | RefVectorOf<FieldValueMap>* fValueTuples;
|
---|
| 162 | ValueStore* fKeyValueStore;
|
---|
| 163 | XMLScanner* fScanner; // for error reporting - REVISIT
|
---|
| 164 | MemoryManager* fMemoryManager;
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 | // ---------------------------------------------------------------------------
|
---|
| 168 | // ValueStore: Getter methods
|
---|
| 169 | // ---------------------------------------------------------------------------
|
---|
| 170 | inline IdentityConstraint*
|
---|
| 171 | ValueStore::getIdentityConstraint() const {
|
---|
| 172 | return fIdentityConstraint;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | XERCES_CPP_NAMESPACE_END
|
---|
| 176 |
|
---|
| 177 | #endif
|
---|
| 178 |
|
---|
| 179 | /**
|
---|
| 180 | * End of file ValueStore.hpp
|
---|
| 181 | */
|
---|
| 182 |
|
---|