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

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 <list>
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 
00043 class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl : public XalanCollationServices::CollationCompareFunctor
00044 {
00045 public:
00046 
00052     ICUBridgeCollationCompareFunctorImpl(bool   fCacheCollators = false);
00053 
00054     ~ICUBridgeCollationCompareFunctorImpl();
00055 
00056     int
00057     operator()(
00058             const XalanDOMChar*                 theLHS,
00059             const XalanDOMChar*                 theRHS,
00060             XalanCollationServices::eCaseOrder  theCaseOrder = XalanCollationServices::eDefault) const;
00061 
00062     int
00063     operator()(
00064             const XalanDOMChar*                 theLHS,
00065             const XalanDOMChar*                 theRHS,
00066             const XalanDOMChar*                 theLocale,
00067             XalanCollationServices::eCaseOrder  theCaseOrder = XalanCollationServices::eDefault) const;
00068 
00069     bool
00070     isValid() const
00071     {
00072         return m_isValid;
00073     }
00074 
00075 #if defined(XALAN_HAS_CPP_NAMESPACE)
00076     typedef U_ICU_NAMESPACE::Collator   CollatorType;
00077 #else
00078     typedef Collator                    CollatorType;
00079 #endif
00080 
00081     struct CollationCacheStruct
00082     {
00083         CollationCacheStruct(
00084                 const XalanDOMString&   theLocale,
00085                 CollatorType*           theCollator) :
00086             m_locale(theLocale),
00087             m_collator(theCollator)
00088         {
00089         }
00090 
00091         CollationCacheStruct() :
00092             m_locale(),
00093             m_collator(0)
00094         {
00095         }
00096 
00097         void
00098         swap(CollationCacheStruct&  theOther)
00099         {
00100             m_locale.swap(theOther.m_locale);
00101 
00102             CollatorType* const     theTemp = m_collator;
00103 
00104             m_collator = theOther.m_collator;
00105 
00106             theOther.m_collator = theTemp;
00107         }
00108 
00109 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
00110         bool
00111         operator<(const CollationCacheStruct&  theRHS) const
00112         {
00113             return this < &theRHS;
00114         }
00115 
00116         bool
00117         operator==(const CollationCacheStruct&  theRHS) const
00118         {
00119             return this == &theRHS;
00120         }
00121 #endif
00122 
00123         XalanDOMString  m_locale;
00124 
00125         CollatorType*   m_collator;
00126 
00127         struct CollatorDeleteFunctor
00128         {
00129             void
00130             operator()(CollationCacheStruct&    theStruct) const
00131             {
00132                 delete theStruct.m_collator;
00133             }
00134         };
00135 
00136         struct CollatorFindFunctor
00137         {
00138             CollatorFindFunctor(const XalanDOMChar* theLocale) :
00139                 m_locale(theLocale)
00140             {
00141             }
00142 
00143             bool
00144             operator()(CollationCacheStruct&    theStruct) const
00145             {
00146                 return XalanDOMString::equals(theStruct.m_locale ,m_locale);
00147             }
00148 
00149             const XalanDOMChar* const   m_locale;
00150         };
00151     };
00152 
00153 #if defined(XALAN_NO_STD_NAMESPACE)
00154     typedef list<CollationCacheStruct>          CollatorCacheListType;
00155 #else
00156     typedef std::list<CollationCacheStruct>     CollatorCacheListType;
00157 #endif
00158 
00159     enum { eCacheMax = 10 };
00160 
00161 private:
00162 
00163     int
00164     doDefaultCompare(
00165             const XalanDOMChar*     theLHS,
00166             const XalanDOMChar*     theRHS) const;
00167 
00168     int
00169     doCompare(
00170             const XalanDOMChar*                 theLHS,
00171             const XalanDOMChar*                 theRHS,
00172             const XalanDOMChar*                 theLocale,
00173             XalanCollationServices::eCaseOrder  theCaseOrder) const;
00174 
00175     int
00176     doCompareCached(
00177             const XalanDOMChar*                 theLHS,
00178             const XalanDOMChar*                 theRHS,
00179             const XalanDOMChar*                 theLocale,
00180             XalanCollationServices::eCaseOrder  theCaseOrder) const;
00181 
00182     int
00183     doCompare(
00184             const CollatorType&     theCollator,
00185             const XalanDOMChar*     theLHS,
00186             const XalanDOMChar*     theRHS) const;
00187 
00188     int
00189     doCompare(
00190             CollatorType&                       theCollator,
00191             const XalanDOMChar*                 theLHS,
00192             const XalanDOMChar*                 theRHS,
00193             XalanCollationServices::eCaseOrder  theCaseOrder) const;
00194 
00195     CollatorType*
00196     getCachedCollator(const XalanDOMChar*   theLocale) const;
00197 
00198     void
00199     cacheCollator(
00200             CollatorType*           theCollator,
00201             const XalanDOMChar*     theLocale) const;
00202 
00203 
00204     // Data members...
00205     bool                            m_isValid;
00206 
00207     CollatorType*                   m_defaultCollator;
00208 
00209     XalanDOMString                  m_defaultCollatorLocaleName;
00210 
00211     bool                            m_cacheCollators;
00212 
00213     mutable CollatorCacheListType   m_collatorCache;
00214 
00215     static const StylesheetExecutionContextDefault::DefaultCollationCompareFunctor  s_defaultFunctor;
00216 };
00217 
00218 
00219 
00220 XALAN_CPP_NAMESPACE_END
00221 
00222 
00223 
00224 #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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.