source: icXML/icXML-devel/src/xercesc/validators/schema/XercesAttGroupInfo.cpp @ 3565

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

Updates to xercesc sources

File size: 4.9 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: XercesAttGroupInfo.cpp 676911 2008-07-15 13:27:32Z amassari $
20 */
21
22// ---------------------------------------------------------------------------
23//  Includes
24// ---------------------------------------------------------------------------
25#include <xercesc/validators/schema/XercesAttGroupInfo.hpp>
26#include <icxercesc/util/QName.hpp>
27
28#include <xercesc/internal/XTemplateSerializer.hpp>
29
30XERCES_CPP_NAMESPACE_BEGIN
31
32// ---------------------------------------------------------------------------
33//  XercesAttGroupInfo: Constructors and Destructor
34// ---------------------------------------------------------------------------
35XercesAttGroupInfo::XercesAttGroupInfo(MemoryManager* const manager)
36    : fTypeWithId(false)
37    , fNameId(0)
38    , fNamespaceId(0)
39    , fAttributes(0)
40    , fAnyAttributes(0)
41    , fCompleteWildCard(0)
42    , fMemoryManager(manager)
43{
44
45}
46
47XercesAttGroupInfo::XercesAttGroupInfo(unsigned int attGroupNameId,
48                                       unsigned int attGroupNamespaceId,
49                                       MemoryManager* const manager)
50    : fTypeWithId(false)
51    , fNameId(attGroupNameId)
52    , fNamespaceId(attGroupNamespaceId)
53    , fAttributes(0)
54    , fAnyAttributes(0)
55    , fCompleteWildCard(0)
56    , fMemoryManager(manager)
57{
58    DEBUG_MESSAGE("XercesAttGroupInfo::XercesAttGroupInfo(" << attGroupNameId << ',' << attGroupNamespaceId << ')')
59}
60
61XercesAttGroupInfo::~XercesAttGroupInfo()
62{
63    delete fAttributes;
64    delete fAnyAttributes;
65    delete fCompleteWildCard;
66}
67
68bool XercesAttGroupInfo::containsAttribute(const XMLCh* const name, const unsigned int uri)
69{
70    if (fAttributes)
71    {
72        XMLSize_t attCount = fAttributes->size();
73
74        if (attCount)
75        {
76            for (XMLSize_t i=0; i < attCount; i++)
77            {
78                QName* attName = fAttributes->elementAt(i)->getAttName();
79                if (attName->getURI() == uri && attName->getLocalPart() == name)
80                {
81                    return true;
82                }
83            }
84        }
85    }
86
87    return false;
88}
89
90// ---------------------------------------------------------------------------
91//  XercesAttGroupInfo: Getter methods
92// ---------------------------------------------------------------------------
93const SchemaAttDef* XercesAttGroupInfo::getAttDef(const XMLCh* const baseName,
94                                                  const int uriId) const {
95
96    // If no list, then return a null
97    if (!fAttributes)
98        return 0;
99
100    XMLSize_t attSize = fAttributes->size();
101
102    for (XMLSize_t i=0; i<attSize; i++) {
103
104        const SchemaAttDef* attDef = fAttributes->elementAt(i);
105        QName* attName = attDef->getAttName();
106
107        if (uriId == (int) attName->getURI() &&
108                        XMLString::equals(baseName, attName->getLocalPart())) {
109
110            return attDef;
111        }
112    }
113
114    return 0;
115}
116
117/***
118 * Support for Serialization/De-serialization
119 ***/
120
121IMPL_XSERIALIZABLE_TOCREATE(XercesAttGroupInfo)
122
123void XercesAttGroupInfo::serialize(XSerializeEngine& serEng)
124{
125
126    if (serEng.isStoring())
127    {
128        serEng<<fTypeWithId;
129        serEng<<fNameId;
130        serEng<<fNamespaceId;
131
132        /***
133         *
134         * Serialize RefVectorOf<SchemaAttDef>* fAttributes;
135         *
136         ***/
137        XTemplateSerializer::storeObject(fAttributes, serEng);
138
139        /***
140         *
141         * Serialize RefVectorOf<SchemaAttDef>* fAnyAttributes;
142         *
143         ***/
144        XTemplateSerializer::storeObject(fAnyAttributes, serEng);
145
146        serEng<<fCompleteWildCard;
147    }
148    else
149    {
150        serEng>>fTypeWithId;
151        serEng>>fNameId;
152        serEng>>fNamespaceId;
153
154        /***
155         *
156         * Deserialize RefVectorOf<SchemaAttDef>* fAttributes;
157         *
158         ***/
159        XTemplateSerializer::loadObject(&fAttributes, 4, true, serEng);
160
161        /***
162         *
163         * Deserialize RefVectorOf<SchemaAttDef>* fAnyAttributes;
164         *
165         ***/
166
167        XTemplateSerializer::loadObject(&fAnyAttributes, 2, true, serEng);
168
169        serEng>>fCompleteWildCard;
170    }
171
172}
173
174XERCES_CPP_NAMESPACE_END
175
176/**
177  * End of file XercesAttGroupInfo.cpp
178  */
179
180
Note: See TracBrowser for help on using the repository browser.