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

Last change on this file since 3565 was 3157, checked in by cameron, 6 years ago

Fixes for icXML 0.9

File size: 5.4 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: FieldValueMap.hpp 708224 2008-10-27 16:02:26Z amassari $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_FIELDVALUEMAP_HPP)
23#define XERCESC_INCLUDE_GUARD_FIELDVALUEMAP_HPP
24
25/**
26  * This class maps values associated with fields of an identity constraint
27  * that have successfully matched some string in an instance document.
28  */
29
30// ---------------------------------------------------------------------------
31//  Includes
32// ---------------------------------------------------------------------------
33#include <icxercesc/util/XMLString.hpp>
34#include <xercesc/util/ValueVectorOf.hpp>
35#include <xercesc/util/RefArrayVectorOf.hpp>
36
37XERCES_CPP_NAMESPACE_BEGIN
38
39// ---------------------------------------------------------------------------
40//  Forward Declaration
41// ---------------------------------------------------------------------------
42class IC_Field;
43class DatatypeValidator;
44
45
46class VALIDATORS_EXPORT FieldValueMap : public XMemory
47{
48public:
49    // -----------------------------------------------------------------------
50    //  Constructors/Destructor
51    // -----------------------------------------------------------------------
52    FieldValueMap(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
53    FieldValueMap(const FieldValueMap& other);
54        ~FieldValueMap();
55
56        // -----------------------------------------------------------------------
57    //  Getter methods
58    // -----------------------------------------------------------------------
59    DatatypeValidator* getDatatypeValidatorAt(const XMLSize_t index) const;
60    DatatypeValidator* getDatatypeValidatorFor(const IC_Field* const key) const;
61    XMLCh* getValueAt(const XMLSize_t index) const;
62    XMLCh* getValueFor(const IC_Field* const key) const;
63    IC_Field* keyAt(const XMLSize_t index) const;
64
65        // -----------------------------------------------------------------------
66    //  Setter methods
67    // -----------------------------------------------------------------------
68    void put(IC_Field* const key, DatatypeValidator* const dv,
69             const XMLCh* const value);
70
71        // -----------------------------------------------------------------------
72    //  Helper methods
73    // -----------------------------------------------------------------------
74    XMLSize_t size() const;
75    bool indexOf(const IC_Field* const key, XMLSize_t& location) const;
76    void clear();
77
78private:
79    // -----------------------------------------------------------------------
80    //  Private helper methods
81    // -----------------------------------------------------------------------
82    void cleanUp();
83
84    // -----------------------------------------------------------------------
85    //  Unimplemented operators
86    // -----------------------------------------------------------------------
87    FieldValueMap& operator= (const FieldValueMap& other);
88
89    // -----------------------------------------------------------------------
90    //  Data
91    // -----------------------------------------------------------------------
92    ValueVectorOf<IC_Field*>*          fFields;
93    ValueVectorOf<DatatypeValidator*>* fValidators;
94    RefArrayVectorOf<XMLCh>*           fValues;
95    MemoryManager*                     fMemoryManager;
96};
97
98
99// ---------------------------------------------------------------------------
100//  FieldValueMap: Getter methods
101// ---------------------------------------------------------------------------
102inline DatatypeValidator*
103FieldValueMap::getDatatypeValidatorAt(const XMLSize_t index) const {
104
105    if (fValidators) {
106        return fValidators->elementAt(index);
107    }
108
109    return 0;
110}
111
112inline DatatypeValidator*
113FieldValueMap::getDatatypeValidatorFor(const IC_Field* const key) const {
114
115    XMLSize_t location;
116    if (fValidators && indexOf(key, location)) {
117        return fValidators->elementAt(location);
118    }
119
120    return 0;
121}
122
123inline XMLCh* FieldValueMap::getValueAt(const XMLSize_t index) const {
124
125    if (fValues) {
126        return fValues->elementAt(index);
127    }
128
129    return 0;
130}
131
132inline XMLCh* FieldValueMap::getValueFor(const IC_Field* const key) const {
133
134    XMLSize_t location;
135    if (fValues && indexOf(key, location)) {
136        return fValues->elementAt(location);
137    }
138
139    return 0;
140}
141
142inline IC_Field* FieldValueMap::keyAt(const XMLSize_t index) const {
143
144    if (fFields) {
145        return fFields->elementAt(index);
146    }
147
148    return 0;
149}
150
151// ---------------------------------------------------------------------------
152//  FieldValueMap: Helper methods
153// ---------------------------------------------------------------------------
154inline XMLSize_t FieldValueMap::size() const {
155
156    if (fFields) {
157        return fFields->size();
158    }
159
160    return 0;
161}
162
163XERCES_CPP_NAMESPACE_END
164
165#endif
166
167/**
168  * End of file FieldValueMap.hpp
169  */
170
Note: See TracBrowser for help on using the repository browser.