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

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

Additional files for icXML 0.9

File size: 4.8 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//    delete fEnum;
51    (getMemoryManager())->deallocate(fArray);
52}
53
54
55// ---------------------------------------------------------------------------
56//  SchemaAttDefList: Implementation of the virtual interface
57// ---------------------------------------------------------------------------
58
59bool SchemaAttDefList::isEmpty() const
60{
61    //return fList->isEmpty();
62    return (fCount == 0);
63}
64
65
66XMLAttDef* SchemaAttDefList::findAttDef(const  unsigned int uriID
67                                    , const XMLCh* const    attName)
68{
69   const int colonInd = XMLString::indexOf(attName, chColon);
70
71   // An index of 0 is really an error, but the QName class doesn't check for
72   // that case either...
73   const XMLCh* const localPart = colonInd >= 0 ? attName + colonInd + 1 : attName;
74
75   return findAttDefLocalPart(uriID, localPart);
76}
77
78
79const XMLAttDef*
80SchemaAttDefList::findAttDef( const   unsigned int   uriID
81                            , const XMLCh* const    attName) const
82{
83   const int colonInd = XMLString::indexOf(attName, chColon);
84
85   // An index of 0 is really an error, but the QName class doesn't check for
86   // that case either...
87   const XMLCh* const localPart = colonInd >= 0 ? attName + colonInd + 1 : attName;
88
89   return findAttDefLocalPart(uriID, localPart);
90}
91
92
93XMLAttDef* SchemaAttDefList::findAttDef(   const   XMLCh* const
94                                        , const XMLCh* const)
95{
96   //need numeric URI id to locate the attribute, that's how it was stored
97   ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager());
98   return 0;
99}
100
101
102const XMLAttDef*
103SchemaAttDefList::findAttDef( const   XMLCh* const
104                            , const XMLCh* const) const
105{
106   //need numeric URI id to locate the attribute, that's how it was stored
107   ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Pool_InvalidId, getMemoryManager());
108   return 0;
109}
110
111/**
112 * return total number of attributes in this list
113 */
114XMLSize_t SchemaAttDefList::getAttDefCount() const
115{
116    return fCount;
117}
118
119/**
120 * return attribute at the index-th position in the list.
121 */
122XMLAttDef &SchemaAttDefList::getAttDef(XMLSize_t index)
123{
124    if(index >= fCount)
125        ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager());
126    return *(fArray[index]);
127}
128
129/**
130 * return attribute at the index-th position in the list.
131 */
132const XMLAttDef &SchemaAttDefList::getAttDef(XMLSize_t index) const
133{
134    if(index >= fCount)
135        ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::AttrList_BadIndex, getMemoryManager());
136    return *(fArray[index]);
137}
138
139/***
140 * Support for Serialization/De-serialization
141 ***/
142
143IMPL_XSERIALIZABLE_TOCREATE(SchemaAttDefList)
144
145void SchemaAttDefList::serialize(XSerializeEngine& serEng)
146{
147    DEPRECATED_FEATURE_IN_ICXML;
148}
149
150SchemaAttDefList::SchemaAttDefList(MemoryManager* const manager)
151: XMLAttDefList(manager)
152//,fEnum(0)
153//,fList(0)
154,fArray(0)
155,fSize(0)
156,fCount(0)
157{
158}
159
160XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.