Xalan-C++ API Reference  1.12.0
AVT.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(XALAN_AVT_HEADER_GUARD)
19 #define XALAN_AVT_HEADER_GUARD
20 
21 // Base include file. Must be first.
23 
24 
25 
27 
28 
29 
30 namespace XERCES_CPP_NAMESPACE
31 {
32  class Locator;
33 }
34 
35 
36 
37 namespace XALAN_CPP_NAMESPACE {
38 
39 
40 
41 typedef xercesc::Locator LocatorType;
42 using xercesc::Locator;
43 
44 
45 
46 class AVTPart;
47 class PrefixResolver;
48 class XPathExecutionContext;
49 class XalanNode;
50 class StringTokenizer;
51 class StylesheetConstructionContext;
52 
53 
54 
55 /**
56  * Class to hold an Attribute Value Template.
57  */
58 class AVT
59 {
60 public:
61 
62  typedef std::size_t size_type;
63 
64  /**
65  * Construct an Attribute Value Template(AVT) by parsing the string, and
66  * either constructing a vector of AVTParts, or simply hold on to the
67  * string if the AVT is simple.
68  *
69  * @param constructionContext context for construction of AVT
70  * @param locator the Locator for the AVT. May be null.
71  * @param name name of AVT
72  * @param stringedValue string value to parse
73  * @param resolver resolver for namespace resolution
74  */
75  AVT(
76  StylesheetConstructionContext& constructionContext,
77  const Locator* locator,
78  const XalanDOMChar* name,
79  const XalanDOMChar* stringedValue,
80  const PrefixResolver& resolver);
81 
82  virtual
83  ~AVT();
84 
85  /**
86  * Retrieve the name of the Attribute Value Template
87  *
88  * @return name of AVT
89  */
90  const XalanDOMString&
91  getName() const
92  {
93  return m_name;
94  }
95 
96  /**
97  * Append the value to the buffer.
98  *
99  * @param buf buffer to write into
100  * @param contextNode current context node
101  * @param prefixResolver prefix resolver to use
102  * @param executionContext execution context
103  */
104  void
106  XalanDOMString& buf,
107  XalanNode* contextNode,
108  const PrefixResolver& prefixResolver,
109  XPathExecutionContext& executionContext) const
110  {
111  if(m_simpleString != 0)
112  {
113  buf.assign(m_simpleString, m_simpleStringLength);
114  }
115  else
116  {
117  doEvaluate(buf, contextNode, prefixResolver, executionContext);
118  }
119  }
120 
121  /**
122  * Append the value to the buffer.
123  *
124  * @param buf buffer to write into
125  * @param prefixResolver prefix resolver to use
126  * @param executionContext execution context
127  */
128  void
130  XalanDOMString& buf,
131  const PrefixResolver& prefixResolver,
132  XPathExecutionContext& executionContext) const
133  {
134  if(m_simpleString != 0)
135  {
136  buf.assign(m_simpleString, m_simpleStringLength);
137  }
138  else
139  {
140  doEvaluate(buf, prefixResolver, executionContext);
141  }
142  }
143 
144 private:
145 
146  void
147  doEvaluate(
148  XalanDOMString& buf,
149  const PrefixResolver& prefixResolver,
150  XPathExecutionContext& executionContext) const;
151 
152  void
153  doEvaluate(
154  XalanDOMString& buf,
155  XalanNode* contextNode,
156  const PrefixResolver& prefixResolver,
157  XPathExecutionContext& executionContext) const;
158 
159  void
160  nextToken(
161  StylesheetConstructionContext& constructionContext,
162  const Locator* locator,
163  StringTokenizer& tokenizer,
164  XalanDOMString& token);
165 
166  // not implemented
167  AVT(const AVT&);
168 
169  AVT&
170  operator=(const AVT&);
171 
172  bool
173  operator==(const AVT&) const;
174 
175 
176  // Data members...
177  const AVTPart** m_parts;
178 
179  size_type m_partsSize;
180 
181  const XalanDOMChar* m_simpleString;
182 
183  XalanDOMString::size_type m_simpleStringLength;
184 
185  const XalanDOMString& m_name;
186 
187  static const XalanDOMString s_emptyString;
188 };
189 
190 
191 
192 }
193 
194 
195 
196 #endif // XALAN_AVT_HEADER_GUARD
xalanc::XalanDOMString::assign
XalanDOMString & assign(const XalanDOMChar *theSource)
Definition: XalanDOMString.hpp:390
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanNode
Definition: XalanNode.hpp:38
XalanDOMString.hpp
xalanc::AVT::evaluate
void evaluate(XalanDOMString &buf, const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext) const
Append the value to the buffer.
Definition: AVT.hpp:129
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
xalanc::AVT::getName
const XalanDOMString & getName() const
Retrieve the name of the Attribute Value Template.
Definition: AVT.hpp:91
xalanc::StylesheetConstructionContext
Definition: StylesheetConstructionContext.hpp:83
xalanc::PrefixResolver
This class defines an interface for classes that resolve namespace prefixes to their URIs.
Definition: PrefixResolver.hpp:39
xalanc::StringTokenizer
Definition: StringTokenizer.hpp:40
xalanc::AVTPart
Class to hold a part, either a string or XPath, of an Attribute Value Template.
Definition: AVTPart.hpp:43
xalanc::AVT::size_type
std::size_t size_type
Definition: AVT.hpp:62
xalanc::AVT::evaluate
void evaluate(XalanDOMString &buf, XalanNode *contextNode, const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext) const
Append the value to the buffer.
Definition: AVT.hpp:105
XSLTDefinitions.hpp
xalanc::XPathExecutionContext
Definition: XPathExecutionContext.hpp:82
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::AVT
Class to hold an Attribute Value Template.
Definition: AVT.hpp:58
xalanc::LocatorType
xercesc::Locator LocatorType
Definition: ExecutionContext.hpp:47