|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 /* |
|
18 * Licensed to the Apache Software Foundation (ASF) under one or more |
|
19 * contributor license agreements. See the NOTICE file distributed with |
|
20 * this work for additional information regarding copyright ownership. |
|
21 * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
22 * (the "License"); you may not use this file except in compliance with |
|
23 * the License. You may obtain a copy of the License at |
|
24 * |
|
25 * http://www.apache.org/licenses/LICENSE-2.0 |
|
26 * |
|
27 * Unless required by applicable law or agreed to in writing, software |
|
28 * distributed under the License is distributed on an "AS IS" BASIS, |
|
29 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
30 * See the License for the specific language governing permissions and |
|
31 * limitations under the License. |
|
32 */ |
|
33 |
|
34 /* |
|
35 * $Id: ValueStore.hpp 568078 2007-08-21 11:43:25Z amassari $ |
|
36 */ |
|
37 |
|
38 #if !defined(VALUESTORE_HPP) |
|
39 #define VALUESTORE_HPP |
|
40 |
|
41 /** |
|
42 * This class stores values associated to an identity constraint. |
|
43 * Each value stored corresponds to a field declared for the identity |
|
44 * constraint. |
|
45 */ |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Includes |
|
49 // --------------------------------------------------------------------------- |
|
50 #include <xercesc/validators/schema/identity/FieldValueMap.hpp> |
|
51 #include <xercesc/util/RefVectorOf.hpp> |
|
52 |
|
53 XERCES_CPP_NAMESPACE_BEGIN |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Forward Declaration |
|
57 // --------------------------------------------------------------------------- |
|
58 class FieldActivator; |
|
59 class IdentityConstraint; |
|
60 class XMLScanner; |
|
61 class ValueStoreCache; |
|
62 |
|
63 |
|
64 class VALIDATORS_EXPORT ValueStore : public XMemory |
|
65 { |
|
66 public: |
|
67 // ----------------------------------------------------------------------- |
|
68 // Constructors/Destructor |
|
69 // ----------------------------------------------------------------------- |
|
70 ValueStore(IdentityConstraint* const ic, |
|
71 XMLScanner* const scanner, |
|
72 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
|
73 ~ValueStore(); |
|
74 |
|
75 // ----------------------------------------------------------------------- |
|
76 // Getter methods |
|
77 // ----------------------------------------------------------------------- |
|
78 IdentityConstraint* getIdentityConstraint() const; |
|
79 |
|
80 // ----------------------------------------------------------------------- |
|
81 // Helper methods |
|
82 // ----------------------------------------------------------------------- |
|
83 void append(const ValueStore* const other); |
|
84 void startValueScope(); |
|
85 void endValueScope(); |
|
86 void addValue(FieldActivator* const fieldActivator, |
|
87 IC_Field* const field, |
|
88 DatatypeValidator* const dv, |
|
89 const XMLCh* const value); |
|
90 bool contains(const FieldValueMap* const other); |
|
91 |
|
92 /** |
|
93 * @deprecated |
|
94 */ |
|
95 void addValue(IC_Field* const field, DatatypeValidator* const dv, |
|
96 const XMLCh* const value); |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------- |
|
100 // Document handling methods |
|
101 // ----------------------------------------------------------------------- |
|
102 void endDcocumentFragment(ValueStoreCache* const valueStoreCache); |
|
103 |
|
104 // ----------------------------------------------------------------------- |
|
105 // Error reporting methods |
|
106 // ----------------------------------------------------------------------- |
|
107 void duplicateValue(); |
|
108 void reportNilError(IdentityConstraint* const ic); |
|
109 |
|
110 private: |
|
111 // ----------------------------------------------------------------------- |
|
112 // Unimplemented contstructors and operators |
|
113 // ----------------------------------------------------------------------- |
|
114 ValueStore(const ValueStore& other); |
|
115 ValueStore& operator= (const ValueStore& other); |
|
116 |
|
117 // ----------------------------------------------------------------------- |
|
118 // Helper methods |
|
119 // ----------------------------------------------------------------------- |
|
120 /** |
|
121 * Returns whether a field associated <DatatypeValidator, String> value |
|
122 * is a duplicate of another associated value. |
|
123 * It is a duplicate only if either of these conditions are true: |
|
124 * - The Datatypes are the same or related by derivation and the values |
|
125 * are in the same valuespace. |
|
126 * - The datatypes are unrelated and the values are Stringwise identical. |
|
127 */ |
|
128 bool isDuplicateOf(DatatypeValidator* const dv1, const XMLCh* const val1, |
|
129 DatatypeValidator* const dv2, const XMLCh* const val2); |
|
130 |
|
131 |
|
132 // ----------------------------------------------------------------------- |
|
133 // Data |
|
134 // ----------------------------------------------------------------------- |
|
135 bool fDoReportError; |
|
136 int fValuesCount; |
|
137 IdentityConstraint* fIdentityConstraint; |
|
138 FieldValueMap fValues; |
|
139 RefVectorOf<FieldValueMap>* fValueTuples; |
|
140 ValueStore* fKeyValueStore; |
|
141 XMLScanner* fScanner; // for error reporting - REVISIT |
|
142 MemoryManager* fMemoryManager; |
|
143 }; |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // ValueStore: Getter methods |
|
147 // --------------------------------------------------------------------------- |
|
148 inline IdentityConstraint* |
|
149 ValueStore::getIdentityConstraint() const { |
|
150 return fIdentityConstraint; |
|
151 } |
|
152 |
|
153 XERCES_CPP_NAMESPACE_END |
|
154 |
|
155 #endif |
|
156 |
|
157 /** |
|
158 * End of file ValueStore.hpp |
|
159 */ |
|
160 |