Xalan-C++ API Reference  1.12.0
XalanHTMLElementsProperties.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XALANHTMLELEMENTSPROPERTIES_HEADER_GUARD_1357924680)
19 #define XALANHTMLELEMENTSPROPERTIES_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 namespace XALAN_CPP_NAMESPACE {
33 
34 
35 
37 {
38 public:
39 
40  enum { eMaxAttributes = 6, eMaxAttributeName = 8, eMaxElementName = 10 };
41 
42  enum eFlags
43  {
44  EMPTY = (1 << 1),
45  FLOW = (1 << 2),
46  BLOCK = (1 << 3),
47  BLOCKFORM = (1 << 4),
48  BLOCKFORMFIELDSET = (1 << 5),
49  CDATA = (1 << 6),
50  PCDATA = (1 << 7),
51  RAW = (1 << 8),
52  INLINE = (1 << 9),
53  INLINEA = (1 << 10),
54  INLINELABEL = (1 << 11),
55  FONTSTYLE = (1 << 12),
56  PHRASE = (1 << 13),
57  FORMCTRL = (1 << 14),
58  SPECIAL = (1 << 15),
59  ASPECIAL = (1 << 16),
60  HEADMISC = (1 << 17),
61  HEAD = (1 << 18),
62  LIST = (1 << 19),
63  PREFORMATTED = (1 << 20),
64  WHITESPACESENSITIVE = (1 << 21),
65  HEADELEM = (1 << 22),
66  STYLEELEM = (1 << 23),
67  SCRIPTELEM = (1 << 24),
68 
69  ATTRURL = (1 << 1),
70  ATTREMPTY = (1 << 2)
71  };
72 
74  {
75  typedef unsigned char FlagsType;
76 
77  XalanDOMChar m_name[eMaxAttributeName + 1];
78 
80 
81  /**
82  * Check if particular properties are set for this
83  * instance. See the eFlag enum for the valid
84  * properties.
85  *
86  * @param theFlags The properties to check.
87  * @return true if the property is set, false if not
88  */
89  bool
90  is(FlagsType theFlags) const
91  {
92  return m_flags & theFlags ? true : false;
93  }
94  };
95 
97  {
99  typedef unsigned int FlagsType;
100 
101  /**
102  * Check if particular attribute properties are set
103  * for this instance. See the eFlag enum for the valid
104  * properties.
105  *
106  * @param theAttributeName The attribute name.
107  * @param theFlags The properties to check.
108  * @return true if the property is set, false if not
109  */
110  bool
111  isAttribute(
112  const XalanDOMChar* theAttributeName,
113  AttributeFlagsType theFlags) const;
114 
115  /**
116  * Check if particular properties are set for this
117  * instance. See the eFlag enum for the valid
118  * properties.
119  *
120  * @param theFlags The properties to check.
121  * @return true if the property is set, false if not
122  */
123  bool
124  is(FlagsType theFlags) const
125  {
126  return m_flags & theFlags ? true : false;
127  }
128 
129  // Data members...
130  XalanDOMChar m_name[eMaxElementName + 1];
131 
133 
134  InternalAttributeProperties m_attributes[eMaxAttributes + 1];
135 
136  /**
137  * Find an instance with the given attribute name.
138  *
139  * @param theAttributeName The attribute name.
140  * @return A reference to an instance.
141  */
143  findProperties(const XalanDOMChar* theAttributeName) const;
144 
146  };
147 
148  /**
149  * This class acts as a proxy for an InternalElementProperties
150  * instance.
151  */
153  {
154  public:
155 
158 
159  /**
160  * Constructor
161  * @param theProperties The instance for which this one is a proxy.
162  */
163  ElementProperties(const InternalElementProperties* theProperties = 0) :
164  m_properties(theProperties)
165  {
166  }
167 
168  /**
169  * Copy constructor
170  * @param theSource The source instance for the copy.
171  */
173  m_properties(theSource.m_properties)
174  {
175  }
176 
177  /**
178  * Determine if this is a non-null instance. You
179  * must call this before calling any member functions,
180  * if you think the instance may be null.
181  *
182  * @return true if the instance is null, false if not
183  */
184  bool
185  null() const
186  {
187  return m_properties == 0 ? true : false;
188  }
189 
190  /**
191  * Check if particular properties are set for this
192  * instance. See the eFlag enum for the valid
193  * properties.
194  *
195  * @param theFlags The properties to check.
196  * @return true if the property is set, false if not
197  */
198  bool
199  is(FlagsType theFlags) const
200  {
201  return m_properties->is(theFlags);
202  }
203 
204  /**
205  * Check if particular attribute properties are set
206  * for this instance. See the eFlag enum for the valid
207  * properties.
208  *
209  * @param theAttributeName The attribute name.
210  * @param theFlags The properties to check.
211  * @return true if the property is set, false if not
212  */
213  bool
215  const XalanDOMChar* theAttributeName,
216  AttributeFlagsType theFlags) const
217  {
218  return m_properties->isAttribute(theAttributeName, theFlags);
219  }
220 
221  /**
222  * Get the name of the element.
223  *
224  * @return The name of the element.
225  */
226  const XalanDOMChar*
227  getName() const
228  {
229  return m_properties->m_name;
230  }
231 
232  private:
233 
234  const InternalElementProperties* m_properties;
235  };
236 
237  /**
238  * Find an instance with the given name.
239  *
240  * @param theElementName The element name.
241  * @return A reference to an instance.
242  */
243  static ElementProperties
244  find(const XalanDOMChar* theElementName);
245 
246 private:
247 
248  /**
249  * Find an instance with the given name.
250  *
251  * @param theElementName The element name.
252  * @return A reference to an instance.
253  */
254  static const InternalElementProperties&
255  findProperties(const XalanDOMChar* theElementName);
256 
257  // The order of these is significant!!!
258 
259  // The array of properties...
260  static const InternalElementProperties s_elementProperties[];
261 
262  // This point to the last of the real propeties in the array.
263  static const InternalElementProperties* const s_lastProperties;
264 
265  // This point to the last of the properties in the array, which is
266  // a dummy instance we return when an instance that matches the
267  // element name cannot be found.
268  static const InternalElementProperties* const s_dummyProperties;
269 
270 
271  // These are undefined...
273 
275 
277  operator=(const XalanHTMLElementsProperties&);
278 
279 };
280 
281 
282 
283 }
284 
285 
286 
287 #endif // XALANHTMLELEMENTSPROPERTIES_HEADER_GUARD_1357924680
xalanc::XalanHTMLElementsProperties::ElementProperties
This class acts as a proxy for an InternalElementProperties instance.
Definition: XalanHTMLElementsProperties.hpp:152
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanHTMLElementsProperties::ElementProperties::isAttribute
bool isAttribute(const XalanDOMChar *theAttributeName, AttributeFlagsType theFlags) const
Check if particular attribute properties are set for this instance.
Definition: XalanHTMLElementsProperties.hpp:214
xalanc::XalanHTMLElementsProperties::InternalElementProperties::s_dummyProperties
static const InternalAttributeProperties s_dummyProperties
Definition: XalanHTMLElementsProperties.hpp:145
xalanc::XalanHTMLElementsProperties::ElementProperties::getName
const XalanDOMChar * getName() const
Get the name of the element.
Definition: XalanHTMLElementsProperties.hpp:227
XalanDOMString.hpp
xalanc::XalanHTMLElementsProperties::ElementProperties::ElementProperties
ElementProperties(const InternalElementProperties *theProperties=0)
Constructor.
Definition: XalanHTMLElementsProperties.hpp:163
xalanc::XalanHTMLElementsProperties::ElementProperties::ElementProperties
ElementProperties(const ElementProperties &theSource)
Copy constructor.
Definition: XalanHTMLElementsProperties.hpp:172
xalanc::XalanHTMLElementsProperties::eFlags
eFlags
Definition: XalanHTMLElementsProperties.hpp:42
xalanc::XalanHTMLElementsProperties::ElementProperties::AttributeFlagsType
InternalElementProperties::AttributeFlagsType AttributeFlagsType
Definition: XalanHTMLElementsProperties.hpp:156
xalanc::XalanHTMLElementsProperties
Definition: XalanHTMLElementsProperties.hpp:36
xalanc::XalanHTMLElementsProperties::InternalElementProperties::is
bool is(FlagsType theFlags) const
Check if particular properties are set for this instance.
Definition: XalanHTMLElementsProperties.hpp:124
xalanc::XalanHTMLElementsProperties::InternalAttributeProperties::FlagsType
unsigned char FlagsType
Definition: XalanHTMLElementsProperties.hpp:75
xalanc::XalanHTMLElementsProperties::ElementProperties::FlagsType
InternalElementProperties::FlagsType FlagsType
Definition: XalanHTMLElementsProperties.hpp:157
xalanc::XalanHTMLElementsProperties::InternalAttributeProperties::is
bool is(FlagsType theFlags) const
Check if particular properties are set for this instance.
Definition: XalanHTMLElementsProperties.hpp:90
xalanc::XalanHTMLElementsProperties::InternalElementProperties::AttributeFlagsType
InternalAttributeProperties::FlagsType AttributeFlagsType
Definition: XalanHTMLElementsProperties.hpp:98
xalanc::XalanHTMLElementsProperties::InternalAttributeProperties::m_flags
FlagsType m_flags
Definition: XalanHTMLElementsProperties.hpp:79
xalanc::XalanHTMLElementsProperties::InternalElementProperties::m_flags
FlagsType m_flags
Definition: XalanHTMLElementsProperties.hpp:132
xalanc::XalanHTMLElementsProperties::InternalElementProperties
Definition: XalanHTMLElementsProperties.hpp:96
xalanc::XalanHTMLElementsProperties::ElementProperties::is
bool is(FlagsType theFlags) const
Check if particular properties are set for this instance.
Definition: XalanHTMLElementsProperties.hpp:199
xalanc::XalanHTMLElementsProperties::InternalElementProperties::FlagsType
unsigned int FlagsType
Definition: XalanHTMLElementsProperties.hpp:99
xalanc::XalanHTMLElementsProperties::InternalAttributeProperties
Definition: XalanHTMLElementsProperties.hpp:73
XMLSupportDefinitions.hpp
XALAN_XMLSUPPORT_EXPORT
#define XALAN_XMLSUPPORT_EXPORT
Definition: XMLSupportDefinitions.hpp:35