Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

ICUFormatNumberFunctor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680)
17 #define FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base header file. Must be first.
23 
24 
25 
27 
28 
29 
31 
32 
33 
35 
36 
37 
39 
40 
41 
42 #include <unicode/decimfmt.h>
43 
44 
45 
46 
47 XALAN_CPP_NAMESPACE_BEGIN
48 
50 
51 #if defined(XALAN_HAS_CPP_NAMESPACE)
52  typedef U_ICU_NAMESPACE::DecimalFormat DecimalFormatType;
53 #else
54  typedef DecimalFormat DecimalFormatType;
55 #endif
56 
58 {
60  MemoryManagerType& theManager,
61  const XalanDecimalFormatSymbols& theDFS,
62  DecimalFormatType* theFormatter) :
63 
64  m_DFS(theDFS, theManager),
65  m_formatter(theFormatter)
66  {
67  }
68 
70  m_DFS(theManager),
71  m_formatter(0)
72  {
73  }
74 
76  const DecimalFormatCacheStruct& other,
77  MemoryManagerType& theManager) :
78  m_DFS(other.m_DFS, theManager),
80  {
81  }
82 
83 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
84  bool
85  operator<(const DecimalFormatCacheStruct& theRHS) const
86  {
87  return this < &theRHS;
88  }
89 
90  bool
91  operator==(const DecimalFormatCacheStruct& theRHS) const
92  {
93  return this == &theRHS;
94  }
95 #endif
96 
98 
100 
102  {
103  public:
104 
105  DecimalFormatDeleteFunctor(MemoryManager& theManager) :
106  m_memoryManager(theManager)
107  {
108  }
109 
110  void
112  {
113  assert(theStruct.m_formatter != 0);
114 
115  XalanDestroy(
116  m_memoryManager,
117  *theStruct.m_formatter);
118  }
119 
120  private:
121 
122  // Not implemented...
124  operator=(const DecimalFormatDeleteFunctor&);
125 
126  // Data members.
127  MemoryManager& m_memoryManager;
128  };
129 
131  {
133  m_DFS(theDFS)
134  {
135  }
136 
137  bool
139  {
140  return theStruct.m_DFS == (*m_DFS);
141  }
142 
144  };
145 
146 private:
147 
150 };
151 
152 
154 
155 // Class that implements the XSLT function format-number using the ICU.
156 //
158 {
159 public:
160 
162 
163  static ICUFormatNumberFunctor*
164  create(MemoryManagerType& theManager);
165 
166  virtual
168 
169  virtual void
170  operator() (
171  XPathExecutionContext& executionContext,
172  double theNumber,
173  const XalanDOMString& thePattern,
174  const XalanDecimalFormatSymbols* theDFS,
175  XalanDOMString& theResult,
176  const XalanNode* context = 0,
177  const LocatorType* locator = 0) const;
178 
179 
181  {
182  public:
184  m_DFS(theDFS)
185  {
186  }
187 
189  operator()(
190  const XalanDOMString& thePattern,
191  XalanDOMString& theResult,
192  MemoryManager& theManager) const;
193 
194  private:
195 
196  const XalanDecimalFormatSymbols& m_DFS;
197  };
198 
200 
201 private:
202 
204  getCachedDecimalFormat(const XalanDecimalFormatSymbols &theDFS) const;
205 
206  bool
207  doFormat(
208  double theNumber,
209  const XalanDOMString& thePattern,
210  XalanDOMString& theResult,
211  const XalanDecimalFormatSymbols* theDFS = 0) const;
212 
213  bool
214  doICUFormat(
215  double theNumber,
216  const XalanDOMString& thePattern,
217  XalanDOMString& theResult,
218  DecimalFormatType* theFormatter = 0) const;
219 
220  void
221  cacheDecimalFormat(
222  DecimalFormatType* theFormatter,
223  const XalanDecimalFormatSymbols& theDFS) const;
224 
225  static DecimalFormat*
226  createDecimalFormat(
227  const XalanDecimalFormatSymbols& theXalanDFS,
228  MemoryManager& theManager);
229 
230  static DecimalFormat*
231  createDecimalFormat(MemoryManager& theManager)
232  {
233  const XalanDecimalFormatSymbols theDFS(theManager);
234 
235  return createDecimalFormat(theDFS, theManager);
236  }
237 
238  enum { eCacheMax = 10u };
239 
240 private:
241 
242  // These are not implemented...
244  operator=(const ICUFormatNumberFunctor&);
245 
246  bool
247  operator==(const ICUFormatNumberFunctor&) const;
248 
249  typedef XalanMemMgrAutoPtr<DecimalFormatType> DFAutoPtrType;
250 
251  // Data members...
252  mutable DecimalFormatCacheListType m_decimalFormatCache;
253 
254  const DFAutoPtrType m_defaultDecimalFormat;
255 
256  MemoryManagerType& m_memoryManager;
257 };
258 
259 
260 
261 XALAN_CPP_NAMESPACE_END
262 
263 
264 
265 #endif // FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
DecimalFormatCacheStruct(MemoryManagerType &theManager, const XalanDecimalFormatSymbols &theDFS, DecimalFormatType *theFormatter)
Definition: ICUFormatNumberFunctor.hpp:59
Definition: XalanNode.hpp:44
XalanDecimalFormatSymbols m_DFS
Definition: ICUFormatNumberFunctor.hpp:97
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
Definition: ICUFormatNumberFunctor.hpp:101
Definition: ICUFormatNumberFunctor.hpp:130
UnlocalizePatternFunctor(const XalanDecimalFormatSymbols &theDFS)
Definition: ICUFormatNumberFunctor.hpp:183
void operator()(DecimalFormatCacheStruct &theStruct) const
Definition: ICUFormatNumberFunctor.hpp:111
Definition: StylesheetExecutionContextDefault.hpp:729
Definition: XalanDecimalFormatSymbols.hpp:38
DecimalFormatFindFunctor(const XalanDecimalFormatSymbols *theDFS)
Definition: ICUFormatNumberFunctor.hpp:132
Definition: XPathExecutionContext.hpp:72
const XalanDecimalFormatSymbols *const m_DFS
Definition: ICUFormatNumberFunctor.hpp:143
DecimalFormatDeleteFunctor(MemoryManager &theManager)
Definition: ICUFormatNumberFunctor.hpp:105
Definition: ICUFormatNumberFunctor.hpp:180
DecimalFormat DecimalFormatType
Definition: ICUFormatNumberFunctor.hpp:54
Definition: ICUFormatNumberFunctor.hpp:157
bool operator<(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1144
XalanList< DecimalFormatCacheStruct > DecimalFormatCacheListType
Definition: ICUFormatNumberFunctor.hpp:199
void XalanDestroy(Type &theArg)
Definition: XalanMemoryManagement.hpp:102
XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType
Definition: FormatterListener.hpp:47
Definition: XalanMemMgrAutoPtr.hpp:46
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:468
DecimalFormatType * m_formatter
Definition: ICUFormatNumberFunctor.hpp:99
Definition: XalanDOMString.hpp:42
bool operator()(DecimalFormatCacheStruct &theStruct) const
Definition: ICUFormatNumberFunctor.hpp:138
DecimalFormatCacheStruct(MemoryManagerType &theManager)
Definition: ICUFormatNumberFunctor.hpp:69
DecimalFormatCacheStruct(const DecimalFormatCacheStruct &other, MemoryManagerType &theManager)
Definition: ICUFormatNumberFunctor.hpp:75
XALAN_CPP_NAMESPACE_BEGIN typedef StylesheetExecutionContextDefault::FormatNumberFunctor FormatNumberFunctor
Definition: ICUFormatNumberFunctor.hpp:49
Definition: ICUFormatNumberFunctor.hpp:57
#define XALAN_ICUBRIDGE_EXPORT
Definition: ICUBridgeDefinitions.hpp:33

Interpreting class diagrams

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

dot

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

Apache Logo