Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


ICUBridgeCollationCompareFunctorImpl.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #if !defined(ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680)
20 #define ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680
21 
22 
23 
25 
26 
27 
29 
30 
31 
33 
34 
35 
36 #include <unicode/coll.h>
37 
38 
39 
40 
41 XALAN_CPP_NAMESPACE_BEGIN
42 
43 
44 #if defined(XALAN_HAS_CPP_NAMESPACE)
45 typedef U_ICU_NAMESPACE::Collator CollatorType;
46 #else
47 typedef Collator CollatorType;
48 #endif
49 
51 {
53  MemoryManager& theManager,
54  const XalanDOMString& theLocale,
55  CollatorType* theCollator) :
56  m_locale(theLocale, theManager),
57  m_collator(theCollator)
58  {
59  }
60 
61  CollationCacheStruct(MemoryManager& theManager) :
62  m_locale(theManager),
63  m_collator(0)
64  {
65  }
66 
68  MemoryManager& theManager) :
69  m_locale(other.m_locale,theManager),
70  m_collator(other.m_collator)
71  {
72  }
73  void
75  {
76  m_locale.swap(theOther.m_locale);
77 
78  CollatorType* const theTemp = m_collator;
79 
80  m_collator = theOther.m_collator;
81 
82  theOther.m_collator = theTemp;
83  }
84 
85 #if defined(XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION)
86  bool
87  operator<(const CollationCacheStruct& theRHS) const
88  {
89  return this < &theRHS;
90  }
91 
92  bool
93  operator==(const CollationCacheStruct& theRHS) const
94  {
95  return this == &theRHS;
96  }
97 #endif
98 
100 
102 
104  {
105  CollatorDeleteFunctor(MemoryManager& theManager):
106  m_memoryManager(theManager)
107  {
108  }
109 
110  void
112  {
113  delete theStruct.m_collator;
114  }
115  private:
116  MemoryManager& m_memoryManager;
117  };
118 
120  {
121  CollatorFindFunctor(const XalanDOMChar* theLocale) :
122  m_locale(theLocale)
123  {
124  }
125 
126  bool
128  {
129  return XalanDOMString::equals(theStruct.m_locale ,m_locale);
130  }
131 
132  const XalanDOMChar* const m_locale;
133  };
134 };
135 
137 
139 {
140 public:
141 
142  /**
143  * Constructor.
144  *
145  * @param fCacheCollators If true, the instance will cache collators. This is not thread-safe, so each thread must have its own instance.
146  */
147  ICUBridgeCollationCompareFunctorImpl( MemoryManager& theManager ,
148  bool fCacheCollators = false);
149 
151  create( MemoryManager& theManager,
152  bool fCacheCollators = false);
153 
154 
156 
157  MemoryManager&
159  {
160  return m_collatorCache.getMemoryManager();
161  }
162 
163  int
164  operator()(
165  const XalanDOMChar* theLHS,
166  const XalanDOMChar* theRHS,
168 
169  int
170  operator()(
171  const XalanDOMChar* theLHS,
172  const XalanDOMChar* theRHS,
173  const XalanDOMChar* theLocale,
175 
176  bool
177  isValid() const
178  {
179  return m_isValid;
180  }
181 
182 
184 
185  enum { eCacheMax = 10 };
186 
187 private:
188 
189  int
190  doDefaultCompare(
191  const XalanDOMChar* theLHS,
192  const XalanDOMChar* theRHS) const;
193 
194  int
195  doCompare(
196  const XalanDOMChar* theLHS,
197  const XalanDOMChar* theRHS,
198  const XalanDOMChar* theLocale,
199  XalanCollationServices::eCaseOrder theCaseOrder) const;
200 
201  int
202  doCompareCached(
203  const XalanDOMChar* theLHS,
204  const XalanDOMChar* theRHS,
205  const XalanDOMChar* theLocale,
206  XalanCollationServices::eCaseOrder theCaseOrder) const;
207 
208  int
209  doCompare(
210  const CollatorType& theCollator,
211  const XalanDOMChar* theLHS,
212  const XalanDOMChar* theRHS) const;
213 
214  int
215  doCompare(
216  CollatorType& theCollator,
217  const XalanDOMChar* theLHS,
218  const XalanDOMChar* theRHS,
219  XalanCollationServices::eCaseOrder theCaseOrder) const;
220 
221  CollatorType*
222  getCachedCollator(const XalanDOMChar* theLocale) const;
223 
224  void
225  cacheCollator(
226  CollatorType* theCollator,
227  const XalanDOMChar* theLocale) const;
228 
229 
230  // Data members...
231  bool m_isValid;
232 
233  CollatorType* m_defaultCollator;
234 
235  XalanDOMString m_defaultCollatorLocaleName;
236 
237  bool m_cacheCollators;
238 
239  mutable CollatorCacheListType m_collatorCache;
240 
242 };
243 
244 
245 
246 XALAN_CPP_NAMESPACE_END
247 
248 
249 
250 #endif // ICUBRIDGE_COLLATIONCOMPAREFUNCTORIMPL_GUARD_1357924680
CollationCacheStruct(const CollationCacheStruct &other, MemoryManager &theManager)
void swap(CollationCacheStruct &theOther)
void swap(XalanDOMString &theOther)
bool operator()(CollationCacheStruct &theStruct) const
CollationCacheStruct(MemoryManager &theManager)
static bool equals(const XalanDOMChar *theLHS, size_type theLHSLength, const XalanDOMChar *theRHS, size_type theRHSLength)
XALAN_CPP_NAMESPACE_BEGIN typedef Collator CollatorType
bool operator<(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
#define XALAN_USES_MEMORY_MANAGER(Type)
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
void operator()(CollationCacheStruct &theStruct) const
CollationCacheStruct(MemoryManager &theManager, const XalanDOMString &theLocale, CollatorType *theCollator)
#define XALAN_ICUBRIDGE_EXPORT

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

Apache Logo