00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000-2002 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 00058 #if !defined(ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680) 00059 #define ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680 00060 00061 00062 00063 #include <ICUBridge/ICUBridgeDefinitions.hpp> 00064 00065 00066 00067 #include <list> 00068 00069 00070 00071 #include <XSLT/StylesheetExecutionContextDefault.hpp> 00072 00073 00074 00075 #include <unicode/coll.h> 00076 00077 00078 00079 00080 class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl : public StylesheetExecutionContextDefault::CollationCompareFunctor 00081 { 00082 public: 00083 00084 typedef StylesheetExecutionContextDefault::eCaseOrder eCaseOrder; 00085 00086 00092 ICUBridgeCollationCompareFunctorImpl(bool fCacheCollators = false); 00093 00094 ~ICUBridgeCollationCompareFunctorImpl(); 00095 00096 int 00097 operator()( 00098 const XalanDOMChar* theLHS, 00099 const XalanDOMChar* theRHS, 00100 eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const; 00101 00102 int 00103 operator()( 00104 const XalanDOMChar* theLHS, 00105 const XalanDOMChar* theRHS, 00106 const XalanDOMChar* theLocale, 00107 eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const; 00108 00109 bool 00110 isValid() const 00111 { 00112 return m_isValid; 00113 } 00114 00115 #if defined(XALAN_NO_NAMESPACES) 00116 typedef Collator CollatorType; 00117 #else 00118 typedef U_ICU_NAMESPACE::Collator CollatorType; 00119 #endif 00120 00121 struct CollationCacheStruct 00122 { 00123 CollationCacheStruct( 00124 const XalanDOMString& theLocale, 00125 CollatorType* theCollator) : 00126 m_locale(theLocale), 00127 m_collator(theCollator) 00128 { 00129 } 00130 00131 CollationCacheStruct() : 00132 m_locale(), 00133 m_collator(0) 00134 { 00135 } 00136 00137 void 00138 swap(CollationCacheStruct& theOther) 00139 { 00140 m_locale.swap(theOther.m_locale); 00141 00142 CollatorType* const theTemp = m_collator; 00143 00144 m_collator = theOther.m_collator; 00145 00146 theOther.m_collator = theTemp; 00147 } 00148 00149 XalanDOMString m_locale; 00150 00151 CollatorType* m_collator; 00152 00153 struct CollatorDeleteFunctor 00154 { 00155 void 00156 operator()(CollationCacheStruct& theStruct) const 00157 { 00158 delete theStruct.m_collator; 00159 } 00160 }; 00161 00162 struct CollatorFindFunctor 00163 { 00164 CollatorFindFunctor(const XalanDOMChar* theLocale) : 00165 m_locale(theLocale) 00166 { 00167 } 00168 00169 bool 00170 operator()(CollationCacheStruct& theStruct) const 00171 { 00172 return XalanDOMString::equals(theStruct.m_locale ,m_locale); 00173 } 00174 00175 const XalanDOMChar* const m_locale; 00176 }; 00177 }; 00178 00179 #if defined(XALAN_NO_NAMESPACES) 00180 typedef list<CollationCacheStruct> CollatorCacheListType; 00181 #else 00182 typedef std::list<CollationCacheStruct> CollatorCacheListType; 00183 #endif 00184 00185 enum { eCacheMax = 10 }; 00186 00187 private: 00188 00189 int 00190 doDefaultCompare( 00191 const XalanDOMChar* theLHS, 00192 const XalanDOMChar* theRHS) const; 00193 00194 int 00195 doCompare( 00196 const XalanDOMChar* theLHS, 00197 const XalanDOMChar* theRHS, 00198 const XalanDOMChar* theLocale, 00199 eCaseOrder theCaseOrder) const; 00200 00201 int 00202 doCompareCached( 00203 const XalanDOMChar* theLHS, 00204 const XalanDOMChar* theRHS, 00205 const XalanDOMChar* theLocale, 00206 eCaseOrder theCaseOrder) const; 00207 00208 int 00209 doCompare( 00210 const CollatorType& theCollator, 00211 const XalanDOMChar* theLHS, 00212 const XalanDOMChar* theRHS) const; 00213 00214 int 00215 doCompare( 00216 CollatorType& theCollator, 00217 const XalanDOMChar* theLHS, 00218 const XalanDOMChar* theRHS, 00219 eCaseOrder theCaseOrder) const; 00220 00221 CollatorType* 00222 getCachedCollator(const XalanDOMChar* theLocale) const; 00223 00224 void 00225 cacheCollator( 00226 CollatorType* theCollator, 00227 const XalanDOMChar* theLocale) const; 00228 00229 00230 // Data members... 00231 bool m_isValid; 00232 00233 CollatorType* m_defaultCollator; 00234 00235 XalanDOMString m_defaultCollatorLocaleName; 00236 00237 bool m_cacheCollators; 00238 00239 mutable CollatorCacheListType m_collatorCache; 00240 00241 const static StylesheetExecutionContextDefault::DefaultCollationCompareFunctor s_defaultFunctor; 00242 }; 00243 00244 00245 00246 #endif // ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.4 |
|