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: DTDAttDef.hpp 676911 2008-07-15 13:27:32Z amassari $
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_DTDATTDEF_HPP)
23 #define XERCESC_INCLUDE_GUARD_DTDATTDEF_HPP
24 
25 #include <xercesc/framework/XMLAttDef.hpp>
26 
27 XERCES_CPP_NAMESPACE_BEGIN
28 
29 //
30 //  This class is a derivative of the core XMLAttDef class. This class adds
31 //  any DTD specific data members and provides DTD specific implementations
32 //  of any underlying attribute def virtual methods.
33 //
34 //  In the DTD we don't do namespaces, so the attribute names are just the
35 //  QName literally from the DTD. This is what we return as the full name,
36 //  which is what is used to key these in any name keyed collections.
37 //
38 class VALIDATORS_EXPORT DTDAttDef : public XMLAttDef
39 {
40 public :
41     // -----------------------------------------------------------------------
42     //  Constructors and Destructors
43     // -----------------------------------------------------------------------
44     DTDAttDef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
45     DTDAttDef
46     (
47         const   XMLCh* const           attName
48         , const XMLAttDef::AttTypes    type = CData
49         , const XMLAttDef::DefAttTypes defType = Implied
50         , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
51     );
52     DTDAttDef
53     (
54         const   XMLCh* const           attName
55         , const XMLCh* const           attValue
56         , const XMLAttDef::AttTypes    type
57         , const XMLAttDef::DefAttTypes defType
58         , const XMLCh* const           enumValues = 0
59         , MemoryManager* const         manager = XMLPlatformUtils::fgMemoryManager
60     );
61     ~DTDAttDef();
62 
63 
64     // -----------------------------------------------------------------------
65     //  Implementation of the XMLAttDef interface
66     // -----------------------------------------------------------------------
67     virtual const XMLCh* getFullName() const;
68 
69     //does nothing currently
reset()70     virtual void reset() {};
71 
72     // -----------------------------------------------------------------------
73     //  Getter methods
74     // -----------------------------------------------------------------------
75     XMLSize_t getElemId() const;
76 
77     // -----------------------------------------------------------------------
78     //  Setter methods
79     // -----------------------------------------------------------------------
80     void setElemId(const XMLSize_t newId);
81     void setName(const XMLCh* const newName);
82 
83     /***
84      * Support for Serialization/De-serialization
85      ***/
86     DECL_XSERIALIZABLE(DTDAttDef)
87 
88 private :
89     // -----------------------------------------------------------------------
90     // Unimplemented constructors and operators
91     // -----------------------------------------------------------------------
92     DTDAttDef(const DTDAttDef &);
93     DTDAttDef& operator = (const  DTDAttDef&);
94 
95     // -----------------------------------------------------------------------
96     //  Private data members
97     //
98     //  fElemId
99     //      This is the id of the element (the id is into the element decl
100     //      pool) of the element this attribute def said it belonged to.
101     //      This is used later to link back to the element, mostly for
102     //      validation purposes.
103     //
104     //  fName
105     //      This is the name of the attribute. Since we don't do namespaces
106     //      in the DTD, its just the fully qualified name.
107     // -----------------------------------------------------------------------
108     XMLSize_t       fElemId;
109     XMLCh*          fName;
110 };
111 
112 
113 // ---------------------------------------------------------------------------
114 //  DTDAttDef: Implementation of the XMLAttDef interface
115 // ---------------------------------------------------------------------------
getFullName() const116 inline const XMLCh* DTDAttDef::getFullName() const
117 {
118     return fName;
119 }
120 
121 
122 // ---------------------------------------------------------------------------
123 //  DTDAttDef: Getter methods
124 // ---------------------------------------------------------------------------
getElemId() const125 inline XMLSize_t DTDAttDef::getElemId() const
126 {
127     return fElemId;
128 }
129 
130 // ---------------------------------------------------------------------------
131 //  DTDAttDef: Setter methods
132 // ---------------------------------------------------------------------------
setElemId(const XMLSize_t newId)133 inline void DTDAttDef::setElemId(const XMLSize_t newId)
134 {
135     fElemId = newId;
136 }
137 
138 
139 XERCES_CPP_NAMESPACE_END
140 
141 #endif
142