00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 <xalanc/ICUBridge/ICUBridgeDefinitions.hpp> 00064 00065 00066 00067 #include <list> 00068 00069 00070 00071 #include <xalanc/XSLT/StylesheetExecutionContextDefault.hpp> 00072 00073 00074 00075 #include <unicode/coll.h> 00076 00077 00078 00079 00080 XALAN_CPP_NAMESPACE_BEGIN 00081 00082 00083 00084 class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl : public XalanCollationServices::CollationCompareFunctor 00085 { 00086 public: 00087 00093 ICUBridgeCollationCompareFunctorImpl(bool fCacheCollators = false); 00094 00095 ~ICUBridgeCollationCompareFunctorImpl(); 00096 00097 int 00098 operator()( 00099 const XalanDOMChar* theLHS, 00100 const XalanDOMChar* theRHS, 00101 XalanCollationServices::eCaseOrder theCaseOrder = XalanCollationServices::eDefault) const; 00102 00103 int 00104 operator()( 00105 const XalanDOMChar* theLHS, 00106 const XalanDOMChar* theRHS, 00107 const XalanDOMChar* theLocale, 00108 XalanCollationServices::eCaseOrder theCaseOrder = XalanCollationServices::eDefault) const; 00109 00110 bool 00111 isValid() const 00112 { 00113 return m_isValid; 00114 } 00115 00116 #if defined(XALAN_HAS_CPP_NAMESPACE) 00117 typedef U_ICU_NAMESPACE::Collator CollatorType; 00118 #else 00119 typedef Collator CollatorType; 00120 #endif 00121 00122 struct CollationCacheStruct 00123 { 00124 CollationCacheStruct( 00125 const XalanDOMString& theLocale, 00126 CollatorType* theCollator) : 00127 m_locale(theLocale), 00128 m_collator(theCollator) 00129 { 00130 } 00131 00132 CollationCacheStruct() : 00133 m_locale(), 00134 m_collator(0) 00135 { 00136 } 00137 00138 void 00139 swap(CollationCacheStruct& theOther) 00140 { 00141 m_locale.swap(theOther.m_locale); 00142 00143 CollatorType* const theTemp = m_collator; 00144 00145 m_collator = theOther.m_collator; 00146 00147 theOther.m_collator = theTemp; 00148 } 00149 00150 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION) 00151 bool 00152 operator<(const CollationCacheStruct& theRHS) const 00153 { 00154 return this < &theRHS; 00155 } 00156 00157 bool 00158 operator==(const CollationCacheStruct& theRHS) const 00159 { 00160 return this == &theRHS; 00161 } 00162 #endif 00163 00164 XalanDOMString m_locale; 00165 00166 CollatorType* m_collator; 00167 00168 struct CollatorDeleteFunctor 00169 { 00170 void 00171 operator()(CollationCacheStruct& theStruct) const 00172 { 00173 delete theStruct.m_collator; 00174 } 00175 }; 00176 00177 struct CollatorFindFunctor 00178 { 00179 CollatorFindFunctor(const XalanDOMChar* theLocale) : 00180 m_locale(theLocale) 00181 { 00182 } 00183 00184 bool 00185 operator()(CollationCacheStruct& theStruct) const 00186 { 00187 return XalanDOMString::equals(theStruct.m_locale ,m_locale); 00188 } 00189 00190 const XalanDOMChar* const m_locale; 00191 }; 00192 }; 00193 00194 #if defined(XALAN_NO_STD_NAMESPACE) 00195 typedef list<CollationCacheStruct> CollatorCacheListType; 00196 #else 00197 typedef std::list<CollationCacheStruct> CollatorCacheListType; 00198 #endif 00199 00200 enum { eCacheMax = 10 }; 00201 00202 private: 00203 00204 int 00205 doDefaultCompare( 00206 const XalanDOMChar* theLHS, 00207 const XalanDOMChar* theRHS) const; 00208 00209 int 00210 doCompare( 00211 const XalanDOMChar* theLHS, 00212 const XalanDOMChar* theRHS, 00213 const XalanDOMChar* theLocale, 00214 XalanCollationServices::eCaseOrder theCaseOrder) const; 00215 00216 int 00217 doCompareCached( 00218 const XalanDOMChar* theLHS, 00219 const XalanDOMChar* theRHS, 00220 const XalanDOMChar* theLocale, 00221 XalanCollationServices::eCaseOrder theCaseOrder) const; 00222 00223 int 00224 doCompare( 00225 const CollatorType& theCollator, 00226 const XalanDOMChar* theLHS, 00227 const XalanDOMChar* theRHS) const; 00228 00229 int 00230 doCompare( 00231 CollatorType& theCollator, 00232 const XalanDOMChar* theLHS, 00233 const XalanDOMChar* theRHS, 00234 XalanCollationServices::eCaseOrder theCaseOrder) const; 00235 00236 CollatorType* 00237 getCachedCollator(const XalanDOMChar* theLocale) const; 00238 00239 void 00240 cacheCollator( 00241 CollatorType* theCollator, 00242 const XalanDOMChar* theLocale) const; 00243 00244 00245 // Data members... 00246 bool m_isValid; 00247 00248 CollatorType* m_defaultCollator; 00249 00250 XalanDOMString m_defaultCollatorLocaleName; 00251 00252 bool m_cacheCollators; 00253 00254 mutable CollatorCacheListType m_collatorCache; 00255 00256 static const StylesheetExecutionContextDefault::DefaultCollationCompareFunctor s_defaultFunctor; 00257 }; 00258 00259 00260 00261 XALAN_CPP_NAMESPACE_END 00262 00263 00264 00265 #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.7 |
|