Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ICUFormatNumberFunctor.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680)
00017 #define FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base header file.  Must be first.
00022 #include <xalanc/ICUBridge/ICUBridgeDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/PlatformSupport/XalanDecimalFormatSymbols.hpp>
00027 
00028 
00029 
00030 #include <xalanc/XSLT/StylesheetExecutionContextDefault.hpp>
00031 
00032 
00033 
00034 #include <xalanc/XPath/XPathExecutionContext.hpp>
00035 
00036 
00037 
00038 #include <unicode/decimfmt.h>
00039 
00040 
00041 
00042 #include <list>
00043 
00044 
00045 
00046 XALAN_CPP_NAMESPACE_BEGIN
00047 
00048 typedef StylesheetExecutionContextDefault::FormatNumberFunctor FormatNumberFunctor;
00049 // Class that implements the XSLT function format-number using the ICU.
00050 //
00051 class XALAN_ICUBRIDGE_EXPORT ICUFormatNumberFunctor : public FormatNumberFunctor
00052 {
00053 public:
00054 
00055     ICUFormatNumberFunctor();
00056 
00057     virtual
00058     ~ICUFormatNumberFunctor();
00059 
00060     virtual void
00061         operator() (
00062         XPathExecutionContext&              executionContext,
00063         double                              theNumber,
00064         const XalanDOMString&               thePattern,
00065         const XalanDecimalFormatSymbols*    theDFS,
00066         XalanDOMString&                     theResult,
00067         const XalanNode*                    context = 0,
00068         const LocatorType*                  locator = 0) const;
00069     
00070 #if defined(XALAN_HAS_CPP_NAMESPACE)
00071     typedef U_ICU_NAMESPACE::DecimalFormat  DecimalFormatType;
00072 #else
00073     typedef DecimalFormat                   DecimalFormatType;
00074 #endif
00075 
00076     class UnlocalizePatternFunctor
00077     {
00078     public:
00079         UnlocalizePatternFunctor(const XalanDecimalFormatSymbols&   theDFS):
00080             m_DFS(theDFS)
00081         {
00082         }
00083 
00084         XalanDOMString
00085         operator()(const XalanDOMString&    thePattern) const;
00086 
00087     private:
00088         const XalanDecimalFormatSymbols& m_DFS;
00089     };
00090 
00091     struct DecimalFormatCacheStruct
00092     {
00093         DecimalFormatCacheStruct(
00094                 const XalanDecimalFormatSymbols&    theDFS,
00095                 DecimalFormatType*                  theFormatter):
00096             m_DFS(theDFS),
00097             m_formatter(theFormatter)
00098         {
00099         }
00100 
00101         DecimalFormatCacheStruct() :
00102             m_DFS(),
00103             m_formatter(0)
00104         {
00105         }
00106 
00107 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
00108         bool
00109         operator<(const DecimalFormatCacheStruct&  theRHS) const
00110         {
00111             return this < &theRHS;
00112         }
00113 
00114         bool
00115         operator==(const DecimalFormatCacheStruct&  theRHS) const
00116         {
00117             return this == &theRHS;
00118         }
00119 #endif
00120 
00121         XalanDecimalFormatSymbols   m_DFS;
00122 
00123         DecimalFormatType * m_formatter;
00124 
00125         struct DecimalFormatDeleteFunctor
00126         {
00127             void
00128             operator()(DecimalFormatCacheStruct&    theStruct) const
00129             {
00130                 delete theStruct.m_formatter;
00131             }
00132         };
00133 
00134         struct DecimalFormatFindFunctor
00135         {
00136             DecimalFormatFindFunctor(const XalanDecimalFormatSymbols*   theDFS) :
00137                 m_DFS(theDFS)
00138             {
00139             }
00140 
00141             bool
00142             operator()(DecimalFormatCacheStruct&    theStruct) const
00143             {
00144                 return theStruct.m_DFS == (*m_DFS);
00145             }
00146 
00147             const XalanDecimalFormatSymbols * const m_DFS;
00148         };
00149     };
00150 
00151 #if defined(XALAN_NO_STD_NAMESPACE)
00152     typedef list<DecimalFormatCacheStruct>          DecimalFormatCacheListType;
00153 #else
00154     typedef std::list<DecimalFormatCacheStruct>     DecimalFormatCacheListType;
00155 #endif
00156 
00157     DecimalFormatType * getCachedDecimalFormat(const XalanDecimalFormatSymbols &theDFS) const;
00158 
00159     bool
00160     doFormat(   
00161         double                              theNumber,
00162         const XalanDOMString&               thePattern,
00163         XalanDOMString&                     theResult,
00164         const XalanDecimalFormatSymbols*    theDFS = 0) const;
00165 
00166     bool
00167     doICUFormat(
00168         double                              theNumber,
00169         const XalanDOMString&               thePattern,
00170         XalanDOMString&                     theResult,
00171         DecimalFormatType*                  theFormatter = 0) const;
00172 
00173     void
00174     cacheDecimalFormat(
00175         DecimalFormatType*                  theFormatter,
00176         const XalanDecimalFormatSymbols&    theDFS) const;
00177 
00178     DecimalFormat *
00179     createDecimalFormat(
00180         const XalanDecimalFormatSymbols&    theXalanDFS) const;
00181 
00182     enum { eCacheMax = 10 };
00183 
00184     DecimalFormatType * m_defaultDecimalFormat;
00185     
00186     mutable DecimalFormatCacheListType m_decimalFormatCache;
00187 
00188     ICUFormatNumberFunctor&
00189     operator=(const ICUFormatNumberFunctor&);
00190 
00191     bool
00192     operator==(const ICUFormatNumberFunctor&) const;
00193 
00194 };
00195 
00196 XALAN_CPP_NAMESPACE_END
00197 
00198 #endif  // FUNCTIONICUFORMATNUMBERFUNCTOR_HEADER_GUARD_1357924680

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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.