Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


ICUFormatNumberFunctor.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(FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680)
19 #define FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base header file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
37 
38 
39 
41 
42 
43 
44 #include <unicode/decimfmt.h>
45 
46 
47 
48 
49 XALAN_CPP_NAMESPACE_BEGIN
50 
52 
53 #if defined(XALAN_HAS_CPP_NAMESPACE)
54  typedef U_ICU_NAMESPACE::DecimalFormat DecimalFormatType;
55 #else
56  typedef DecimalFormat DecimalFormatType;
57 #endif
58 
60 {
62  MemoryManager& theManager,
63  const XalanDecimalFormatSymbols& theDFS,
64  DecimalFormatType* theFormatter) :
65 
66  m_DFS(theDFS, theManager),
67  m_formatter(theFormatter)
68  {
69  }
70 
71  DecimalFormatCacheStruct(MemoryManager& theManager) :
72  m_DFS(theManager),
73  m_formatter(0)
74  {
75  }
76 
78  const DecimalFormatCacheStruct& other,
79  MemoryManager& theManager) :
80  m_DFS(other.m_DFS, theManager),
82  {
83  }
84 
85 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
86  bool
87  operator<(const DecimalFormatCacheStruct& theRHS) const
88  {
89  return this < &theRHS;
90  }
91 
92  bool
93  operator==(const DecimalFormatCacheStruct& theRHS) const
94  {
95  return this == &theRHS;
96  }
97 #endif
98 
100 
102 
104  {
105  public:
106 
107  DecimalFormatDeleteFunctor(MemoryManager& theManager) :
108  m_memoryManager(theManager)
109  {
110  }
111 
112  void
114  {
115  assert(theStruct.m_formatter != 0);
116 
117  XalanDestroy(
118  m_memoryManager,
119  *theStruct.m_formatter);
120  }
121 
122  private:
123 
124  // Not implemented...
126  operator=(const DecimalFormatDeleteFunctor&);
127 
128  // Data members.
129  MemoryManager& m_memoryManager;
130  };
131 
133  {
135  m_DFS(theDFS)
136  {
137  }
138 
139  bool
141  {
142  return theStruct.m_DFS == (*m_DFS);
143  }
144 
146  };
147 
148 private:
149 
152 };
153 
154 
156 
157 // Class that implements the XSLT function format-number using the ICU.
158 //
160 {
161 public:
162 
163  ICUFormatNumberFunctor(MemoryManager& theManager);
164 
165  static ICUFormatNumberFunctor*
166  create(MemoryManager& theManager);
167 
168  virtual
170 
171  virtual void
172  operator() (
173  XPathExecutionContext& executionContext,
174  double theNumber,
175  const XalanDOMString& thePattern,
176  const XalanDecimalFormatSymbols* theDFS,
177  XalanDOMString& theResult,
178  const XalanNode* context = 0,
179  const Locator* locator = 0) const;
180 
181 
183  {
184  public:
186  m_DFS(theDFS)
187  {
188  }
189 
191  operator()(
192  const XalanDOMString& thePattern,
193  XalanDOMString& theResult,
194  MemoryManager& theManager) const;
195 
196  private:
197 
199  };
200 
202 
203 private:
204 
206  getCachedDecimalFormat(const XalanDecimalFormatSymbols &theDFS) const;
207 
208  bool
209  doFormat(
210  double theNumber,
211  const XalanDOMString& thePattern,
212  XalanDOMString& theResult,
213  const XalanDecimalFormatSymbols* theDFS = 0) const;
214 
215  bool
216  doICUFormat(
217  double theNumber,
218  const XalanDOMString& thePattern,
219  XalanDOMString& theResult,
220  DecimalFormatType* theFormatter = 0) const;
221 
222  void
223  cacheDecimalFormat(
224  DecimalFormatType* theFormatter,
225  const XalanDecimalFormatSymbols& theDFS) const;
226 
227  static DecimalFormat*
228  createDecimalFormat(
229  const XalanDecimalFormatSymbols& theXalanDFS,
230  MemoryManager& theManager);
231 
232  static DecimalFormat*
233  createDecimalFormat(MemoryManager& theManager)
234  {
235  const XalanDecimalFormatSymbols theDFS(theManager);
236 
237  return createDecimalFormat(theDFS, theManager);
238  }
239 
240  enum { eCacheMax = 10u };
241 
242 private:
243 
244  // These are not implemented...
246  operator=(const ICUFormatNumberFunctor&);
247 
248  bool
249  operator==(const ICUFormatNumberFunctor&) const;
250 
252 
253  // Data members...
254  mutable DecimalFormatCacheListType m_decimalFormatCache;
255 
256  const DFAutoPtrType m_defaultDecimalFormat;
257 
258  MemoryManager& m_memoryManager;
259 };
260 
261 
262 
263 XALAN_CPP_NAMESPACE_END
264 
265 
266 
267 #endif // FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
XalanDecimalFormatSymbols m_DFS
DecimalFormatCacheStruct(MemoryManager &theManager)
bool operator()(DecimalFormatCacheStruct &theStruct) const
UnlocalizePatternFunctor(const XalanDecimalFormatSymbols &theDFS)
DecimalFormatFindFunctor(const XalanDecimalFormatSymbols *theDFS)
void operator()(DecimalFormatCacheStruct &theStruct) const
DecimalFormat DecimalFormatType
XalanList< DecimalFormatCacheStruct > DecimalFormatCacheListType
void XalanDestroy(Type &theArg)
bool operator<(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
#define XALAN_USES_MEMORY_MANAGER(Type)
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
XALAN_CPP_NAMESPACE_BEGIN typedef StylesheetExecutionContextDefault::FormatNumberFunctor FormatNumberFunctor
DecimalFormatCacheStruct(MemoryManager &theManager, const XalanDecimalFormatSymbols &theDFS, DecimalFormatType *theFormatter)
DecimalFormatCacheStruct(const DecimalFormatCacheStruct &other, MemoryManager &theManager)
#define XALAN_ICUBRIDGE_EXPORT

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo