source: icXML/icXML-devel/src/icxercesc/validators/schema/SchemaAttDefList.cpp @ 3157

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

Fixes for icXML 0.9

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: SchemaAttDefList.cpp 679359 2008-07-24 11:15:19Z borisk $
20 */
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <icxercesc/validators/schema/SchemaAttDefList.hpp>
27
28#include <xercesc/internal/XTemplateSerializer.hpp>
29#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
30#include <icxmlc/XMLConfig.hpp>
31
32XERCES_CPP_NAMESPACE_BEGIN
33
34// ---------------------------------------------------------------------------
35//  SchemaAttDefList: Constructors and Destructor
36// ---------------------------------------------------------------------------
37SchemaAttDefList::SchemaAttDefList(RefHash2KeysTableOf<SchemaAttDef>* const listToUse, MemoryManager* const manager)
38: XMLAttDefList(manager)
39// ,fEnum(0)
40// ,fList(listToUse)
41,fArray((SchemaAttDef **)((getMemoryManager())->allocate( sizeof(SchemaAttDef*) * 4)))
42,fSize(4)
43,fCount(0)
44{
45//    fEnum = new (getMemoryManager()) RefHash2KeysTableOfEnumerator<SchemaAttDef>(listToUse, false, getMemoryManager());
46}
47
48SchemaAttDefList::~SchemaAttDefList()
49{
50    for (XMLSize_t i = 0; i < fCount; i++)
51    {
52        delete fArray[i];
53    }
54    (getMemoryManager())->deallocate(fArray);
55}
56
57
58// ---------------------------------------------------------------------------
59//  SchemaAttDefList: Implementation of the virtual interface
60// ---------------------------------------------------------------------------
61
62bool SchemaAttDefList::isEmpty() const
63{
64    //return fList->isEmpty();
65    return (fCount == 0);
66}
67
68
69XMLAttDef* SchemaAttDefList::findAttDef(const  unsigned int uriID
70                                    , const XMLCh* const    attName)
71{
72   const int colonInd = XMLString::indexOf(attName, chColon);
73
74   // An index of 0 is really an error, but the QName class doesn't check for
75   // that case either...
76   const XMLCh* const localPart = colonInd >= 0 ? attName + colonInd + 1 : attName;
77
78   return findAttDefLocalPart(uriID, localPart);
79}
80
81
82const XMLAttDef*
83SchemaAttDefList::findAttDef( const   unsigned int   uriID
84                            , const XMLCh* const    attName) const
85{
86   const int colonInd = XMLString::indexOf(attName, chColon);
87
88   // An index of 0 is really an error, but the QName class doesn't check for
89   // that case either...
90   const XMLCh* const localPart = colonInd >= 0 ? attName + colonInd + 1 : attName;
91
92   return findAttDefLocalPart(uriID, localPart);
93}
94
95
96XMLAttDef* SchemaAttDefList::findAttDef(   const   XMLCh* const
97                                        , const XMLCh* const)
98{
99   //need numeric URI id to locate the attribute, that's how it was stored
100   ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager());
101   return 0;
102}
103
104
105const XMLAttDef*
106SchemaAttDefList::findAttDef( const   XMLCh* const
107                            , const XMLCh* const) const
108{
109   //need numeric URI id to locate the attribute, that's how it was stored
110   ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager());
111   return 0;
112}
113
114/**
115 * return total number of attributes in this list
116 */
117XMLSize_t SchemaAttDefList::getAttDefCount() const
118{
119    return fCount;
120}
121
122/**
123 * return attribute at the index-th position in the list.
124 */
125XMLAttDef &SchemaAttDefList::getAttDef(XMLSize_t index)
126{
127    if(index >= fCount)
128        ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager());
129    return *(fArray[index]);
130}
131
132/**
133 * return attribute at the index-th position in the list.
134 */
135const XMLAttDef &SchemaAttDefList::getAttDef(XMLSize_t index) const
136{
137    if(index >= fCount)
138        ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager());
139    return *(fArray[index]);
140}
141
142/***
143 * Support for Serialization/De-serialization
144 ***/
145
146IMPL_XSERIALIZABLE_TOCREATE(SchemaAttDefList)
147
148void SchemaAttDefList::serialize(XSerializeEngine& serEng)
149{
150    DEPRECATED_FEATURE_IN_ICXML;
151}
152
153SchemaAttDefList::SchemaAttDefList(MemoryManager* const manager)
154: XMLAttDefList(manager)
155//,fEnum(0)
156//,fList(0)
157,fArray(0)
158,fSize(0)
159,fCount(0)
160{
161}
162
163XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.