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$
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_CONTENTLEAFNAMETYPEVECTOR_HPP)
23 #define XERCESC_INCLUDE_GUARD_CONTENTLEAFNAMETYPEVECTOR_HPP
24 
25 #include <xercesc/validators/common/ContentSpecNode.hpp>
26 #include <xercesc/framework/MemoryManager.hpp>
27 
28 XERCES_CPP_NAMESPACE_BEGIN
29 
30 class XMLPARSER_EXPORT ContentLeafNameTypeVector : public XMemory
31 {
32 public :
33     // -----------------------------------------------------------------------
34     //  Class specific types
35     // -----------------------------------------------------------------------
36 
37 
38     // -----------------------------------------------------------------------
39     //  Constructors and Destructor
40     // -----------------------------------------------------------------------
41     ContentLeafNameTypeVector
42     (
43         MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
44     );
45     ContentLeafNameTypeVector
46     (
47         QName** const                     qName
48       , ContentSpecNode::NodeTypes* const types
49       , const XMLSize_t                   count
50       , MemoryManager* const              manager = XMLPlatformUtils::fgMemoryManager
51     );
52 
53     ~ContentLeafNameTypeVector();
54 
55     ContentLeafNameTypeVector(const ContentLeafNameTypeVector&);
56 
57     // -----------------------------------------------------------------------
58     //  Getter methods
59     // -----------------------------------------------------------------------
60     QName* getLeafNameAt(const XMLSize_t pos) const;
61 
62     ContentSpecNode::NodeTypes getLeafTypeAt(const XMLSize_t pos) const;
63     XMLSize_t getLeafCount() const;
64 
65     // -----------------------------------------------------------------------
66     //  Setter methods
67     // -----------------------------------------------------------------------
68     void setValues
69     (
70         QName** const                      qName
71       , ContentSpecNode::NodeTypes* const  types
72       , const XMLSize_t                    count
73     );
74 
75     // -----------------------------------------------------------------------
76     //  Miscellaneous
77     // -----------------------------------------------------------------------
78 
79 private :
80     // -----------------------------------------------------------------------
81     //  Unimplemented constructors and operators
82     // -----------------------------------------------------------------------
83     ContentLeafNameTypeVector& operator=(const ContentLeafNameTypeVector&);
84 
85     // -----------------------------------------------------------------------
86     //  helper methods
87     // -----------------------------------------------------------------------
88     void cleanUp();
89     void init(const XMLSize_t size);
90 
91     // -----------------------------------------------------------------------
92     //  Private Data Members
93     //
94     // -----------------------------------------------------------------------
95     MemoryManager*                fMemoryManager;
96     QName**                       fLeafNames;
97     ContentSpecNode::NodeTypes   *fLeafTypes;
98     XMLSize_t                     fLeafCount;
99 };
100 
cleanUp()101 inline void ContentLeafNameTypeVector::cleanUp()
102 {
103 	fMemoryManager->deallocate(fLeafNames); //delete [] fLeafNames;
104 	fMemoryManager->deallocate(fLeafTypes); //delete [] fLeafTypes;
105 }
106 
init(const XMLSize_t size)107 inline void ContentLeafNameTypeVector::init(const XMLSize_t size)
108 {
109     fLeafNames = (QName**) fMemoryManager->allocate(size * sizeof(QName*));//new QName*[size];
110     fLeafTypes = (ContentSpecNode::NodeTypes *) fMemoryManager->allocate
111     (
112         size * sizeof(ContentSpecNode::NodeTypes)
113     ); //new ContentSpecNode::NodeTypes [size];
114     fLeafCount = size;
115 }
116 
117 XERCES_CPP_NAMESPACE_END
118 
119 #endif
120