Xalan-C++ API Reference  1.12.0
XPathConstructionContext.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(XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680)
19 #define XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
36 namespace XERCES_CPP_NAMESPACE
37 {
38  class Locator;
39 }
40 
41 
42 
43 namespace XALAN_CPP_NAMESPACE {
44 
45 
46 
47 typedef xercesc::Locator LocatorType;
48 using xercesc::Locator;
49 
50 
51 
52 class XalanNode;
53 
54 
55 
56 //
57 // An abstract class which provides support for constructing the internal
58 // representation of a stylesheet.
59 //
61 {
62 public:
63 
64  XPathConstructionContext(MemoryManager& theManager);
65 
66  virtual
68 
69 
70  // These interfaces are inherited from ProblemListenerBase...
71  virtual void
73  eSource source,
74  eClassification classification,
75  const XalanDOMString& msg,
76  const Locator* locator,
77  const XalanNode* sourceNode) = 0;
78 
79  virtual void
81  eSource source,
82  eClassification classification,
83  const XalanDOMString& msg,
84  const XalanNode* sourceNode) = 0;
85 
86 
87  // These interfaces are new...
88  /**
89  * Reset the instance. Any existing objects
90  * created by the instance will be destroyed.
91  */
92  virtual void
93  reset() = 0;
94 
95  /**
96  * Get a pooled string given the source string. If
97  * the string already exists in the pool, no copy
98  * will be made. If not, a copy will be made and
99  * kept for later use.
100  *
101  * @param theString The source string
102  * @return a const reference to a pooled string.
103  */
104  virtual const XalanDOMString&
105  getPooledString(const XalanDOMString& theString) = 0;
106 
107  /**
108  * Get a pooled string given the source character
109  * array. If the string already exists in the pool,
110  * no copy will be made. If not, a copy will be made
111  * and kept for later use.
112  *
113  * @param theString The source character array
114  * @param theLength The length of the character array
115  * @return a const reference to a pooled string.
116  */
117  virtual const XalanDOMString&
119  const XalanDOMChar* theString,
120  XalanDOMString::size_type theLength = XalanDOMString::npos) = 0;
121 
122  /**
123  * Get a cached string for temporary use.
124  *
125  * @return A reference to the string
126  */
127  virtual XalanDOMString&
129 
130  /**
131  * Return a cached string.
132  *
133  * @param theString The string to release.
134  *
135  * @return true if the string was released successfully.
136  */
137  virtual bool
139 
141  {
142  public:
143 
144  GetCachedString(XPathConstructionContext& theConstructionContext) :
145  m_constructionContext(&theConstructionContext),
146  m_string(&theConstructionContext.getCachedString())
147  {
148  }
149 
151  {
152  assert(m_string != 0);
153 
154  m_constructionContext->releaseCachedString(*m_string);
155  }
156 
158  get() const
159  {
160  assert(m_string != 0);
161 
162  return *m_string;
163  }
164 
167  {
168  assert(m_constructionContext != 0);
169 
170  return *m_constructionContext;
171  }
172 
173  private:
174 
175  // Not implemented...
176  GetCachedString();
177 
179 
181  operator=(const GetCachedString&);
182 
183 
184  // Data members...
185  XPathConstructionContext* m_constructionContext;
186 
187  XalanDOMString* m_string;
188  };
189 
191 
192  MemoryManager&
194  {
195  return m_memoryManager;
196  }
197 
198  MemoryManager&
200  {
201  return m_memoryManager;
202  }
203 
204 private:
205 
206  MemoryManager& m_memoryManager;
207 };
208 
209 
210 
211 }
212 
213 
214 
215 #endif // XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
#define XALAN_XPATH_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
This is the abstract class that is used when reporting a problem some kind, that requires a message,...
GetCachedString(XPathConstructionContext &theConstructionContext)
virtual bool releaseCachedString(XalanDOMString &theString)=0
Return a cached string.
virtual const XalanDOMString & getPooledString(const XalanDOMString &theString)=0
Get a pooled string given the source string.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const XalanNode *sourceNode)=0
Function that is called when a problem event occurs.
virtual void reset()=0
Reset the instance.
virtual XalanDOMString & getCachedString()=0
Get a cached string for temporary use.
virtual void problem(eSource source, eClassification classification, const XalanDOMString &msg, const Locator *locator, const XalanNode *sourceNode)=0
Function that is called when a problem event occurs.
XPathConstructionContext(MemoryManager &theManager)
virtual const XalanDOMString & getPooledString(const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos)=0
Get a pooled string given the source character array.
xercesc::Locator LocatorType