## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.9

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

# ICUBridgeCollationCompareFunctorImpl.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
    00017 #if !defined(ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680)
    00018 #define ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680
    00019
    00020
    00021
    00022 #include <xalanc/ICUBridge/ICUBridgeDefinitions.hpp>
    00023
    00024
    00025
    00026 #include <xalanc/Include/XalanList.hpp>
    00027
    00028
    00029
    00030 #include <xalanc/XSLT/StylesheetExecutionContextDefault.hpp>
    00031
    00032
    00033
    00034 #include <unicode/coll.h>
    00035
    00036
    00037
    00038
    00039 XALAN_CPP_NAMESPACE_BEGIN
    00040
    00041
    00042 #if defined(XALAN_HAS_CPP_NAMESPACE)
    00043 typedef U_ICU_NAMESPACE::Collator   CollatorType;
    00044 #else
    00045 typedef Collator                    CollatorType;
    00046 #endif
    00047
    00048 struct CollationCacheStruct
    00049 {
    00050     CollationCacheStruct(
    00051         MemoryManagerType&      theManager,
    00052         const XalanDOMString&   theLocale,
    00053         CollatorType*           theCollator) :
    00054     m_locale(theLocale, theManager),
    00055         m_collator(theCollator)
    00056     {
    00057     }
    00058
    00059     CollationCacheStruct(MemoryManagerType& theManager) :
    00060     m_locale(theManager),
    00061         m_collator(0)
    00062     {
    00063     }
    00064
    00065     CollationCacheStruct(   const CollationCacheStruct& other,
    00066                             MemoryManagerType&          theManager) :
    00067     m_locale(other.m_locale,theManager),
    00068     m_collator(other.m_collator)
    00069     {
    00070     }
    00071     void
    00072         swap(CollationCacheStruct&  theOther)
    00073     {
    00074         m_locale.swap(theOther.m_locale);
    00075
    00076         CollatorType* const     theTemp = m_collator;
    00077
    00078         m_collator = theOther.m_collator;
    00079
    00080         theOther.m_collator = theTemp;
    00081     }
    00082
    00083 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
    00084     bool
    00085         operator<(const CollationCacheStruct&  theRHS) const
    00086     {
    00087         return this < &theRHS;
    00088     }
    00089
    00090     bool
    00091         operator==(const CollationCacheStruct&  theRHS) const
    00092     {
    00093         return this == &theRHS;
    00094     }
    00095 #endif
    00096
    00097     XalanDOMString  m_locale;
    00098
    00099     CollatorType*   m_collator;
    00100
    00101     struct CollatorDeleteFunctor
    00102     {
    00103      CollatorDeleteFunctor(MemoryManagerType& theManager):
    00104         m_memoryManager(theManager)
    00105     {
    00106     }
    00107
    00108     void
    00109         operator()(CollationCacheStruct&    theStruct) const
    00110     {
    00111         delete theStruct.m_collator;
    00112     }
    00113     private:
    00114         MemoryManagerType& m_memoryManager;
    00115     };
    00116
    00117     struct CollatorFindFunctor
    00118     {
    00119         CollatorFindFunctor(const XalanDOMChar* theLocale) :
    00120     m_locale(theLocale)
    00121     {
    00122     }
    00123
    00124     bool
    00125         operator()(CollationCacheStruct&    theStruct) const
    00126     {
    00127         return XalanDOMString::equals(theStruct.m_locale ,m_locale);
    00128     }
    00129
    00130     const XalanDOMChar* const   m_locale;
    00131     };
    00132 };
    00133
    00134 XALAN_USES_MEMORY_MANAGER(CollationCacheStruct)
    00135
    00136 class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl : public XalanCollationServices::CollationCompareFunctor
    00137 {
    00138 public:
    00139
    00145     ICUBridgeCollationCompareFunctorImpl(   MemoryManagerType&  theManager ,
    00146                                             bool                fCacheCollators = false);
    00147
    00148     static ICUBridgeCollationCompareFunctorImpl*
    00149     create( MemoryManagerType&  theManager,
    00150             bool                fCacheCollators = false);
    00151
    00152
    00153     ~ICUBridgeCollationCompareFunctorImpl();
    00154
    00155     MemoryManagerType&
    00156     getMemoryManager()const
    00157     {
    00158         return m_collatorCache.getMemoryManager();
    00159     }
    00160
    00161     int
    00162     operator()(
    00163             const XalanDOMChar*                 theLHS,
    00164             const XalanDOMChar*                 theRHS,
    00165             XalanCollationServices::eCaseOrder  theCaseOrder = XalanCollationServices::eDefault) const;
    00166
    00167     int
    00168     operator()(
    00169             const XalanDOMChar*                 theLHS,
    00170             const XalanDOMChar*                 theRHS,
    00171             const XalanDOMChar*                 theLocale,
    00172             XalanCollationServices::eCaseOrder  theCaseOrder = XalanCollationServices::eDefault) const;
    00173
    00174     bool
    00175     isValid() const
    00176     {
    00177         return m_isValid;
    00178     }
    00179
    00180
    00181     typedef XalanList<CollationCacheStruct>         CollatorCacheListType;
    00182
    00183     enum { eCacheMax = 10 };
    00184
    00185 private:
    00186
    00187     int
    00188     doDefaultCompare(
    00189             const XalanDOMChar*     theLHS,
    00190             const XalanDOMChar*     theRHS) const;
    00191
    00192     int
    00193     doCompare(
    00194             const XalanDOMChar*                 theLHS,
    00195             const XalanDOMChar*                 theRHS,
    00196             const XalanDOMChar*                 theLocale,
    00197             XalanCollationServices::eCaseOrder  theCaseOrder) const;
    00198
    00199     int
    00200     doCompareCached(
    00201             const XalanDOMChar*                 theLHS,
    00202             const XalanDOMChar*                 theRHS,
    00203             const XalanDOMChar*                 theLocale,
    00204             XalanCollationServices::eCaseOrder  theCaseOrder) const;
    00205
    00206     int
    00207     doCompare(
    00208             const CollatorType&     theCollator,
    00209             const XalanDOMChar*     theLHS,
    00210             const XalanDOMChar*     theRHS) const;
    00211
    00212     int
    00213     doCompare(
    00214             CollatorType&                       theCollator,
    00215             const XalanDOMChar*                 theLHS,
    00216             const XalanDOMChar*                 theRHS,
    00217             XalanCollationServices::eCaseOrder  theCaseOrder) const;
    00218
    00219     CollatorType*
    00220     getCachedCollator(const XalanDOMChar*   theLocale) const;
    00221
    00222     void
    00223     cacheCollator(
    00224             CollatorType*           theCollator,
    00225             const XalanDOMChar*     theLocale) const;
    00226
    00227
    00228     // Data members...
    00229     bool                            m_isValid;
    00230
    00231     CollatorType*                   m_defaultCollator;
    00232
    00233     XalanDOMString                  m_defaultCollatorLocaleName;
    00234
    00235     bool                            m_cacheCollators;
    00236
    00237     mutable CollatorCacheListType   m_collatorCache;
    00238
    00239     static const StylesheetExecutionContextDefault::DefaultCollationCompareFunctor  s_defaultFunctor;
    00240 };
    00241
    00242
    00243
    00244 XALAN_CPP_NAMESPACE_END
    00245
    00246
    00247
    00248 #endif  // ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_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.9 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.