You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/05/29 20:22:02 UTC
cvs commit: xml-xalan/c/src/ICUBridge ICUBridgeCollationCompareFunctor.cpp ICUBridgeCollationCompareFunctor.hpp ICUBridgeCollationCompareFunctorImpl.cpp ICUBridgeCollationCompareFunctorImpl.hpp
dbertoni 02/05/29 11:22:02
Modified: c/src/ICUBridge ICUBridgeCollationCompareFunctor.cpp
ICUBridgeCollationCompareFunctor.hpp
ICUBridgeCollationCompareFunctorImpl.cpp
ICUBridgeCollationCompareFunctorImpl.hpp
Log:
Implemented "case-order" attribute of xsl:sort.
Revision Changes Path
1.21 +6 -4 xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.cpp
Index: ICUBridgeCollationCompareFunctor.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ICUBridgeCollationCompareFunctor.cpp 4 Jan 2002 19:12:43 -0000 1.20
+++ ICUBridgeCollationCompareFunctor.cpp 29 May 2002 18:22:02 -0000 1.21
@@ -81,9 +81,10 @@
int
ICUBridgeCollationCompareFunctor::operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder) const
{
- return (*m_impl)(theLHS, theRHS);
+ return (*m_impl)(theLHS, theRHS, theCaseOrder);
}
@@ -92,7 +93,8 @@
ICUBridgeCollationCompareFunctor::operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder) const
{
- return (*m_impl)(theLHS, theRHS, theLocale);
+ return (*m_impl)(theLHS, theRHS, theLocale, theCaseOrder);
}
1.9 +8 -3 xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.hpp
Index: ICUBridgeCollationCompareFunctor.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctor.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ICUBridgeCollationCompareFunctor.hpp 4 Jan 2002 19:12:43 -0000 1.8
+++ ICUBridgeCollationCompareFunctor.hpp 29 May 2002 18:22:02 -0000 1.9
@@ -72,10 +72,13 @@
-class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctor : public StylesheetExecutionContextDefault::CollationCompareFunctor
+class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctor : public StylesheetExecutionContextDefault::CollationCompareFunctor
{
public:
+ typedef StylesheetExecutionContextDefault::eCaseOrder eCaseOrder;
+
+
ICUBridgeCollationCompareFunctor();
virtual
@@ -84,13 +87,15 @@
virtual int
operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const;
virtual int
operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const;
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const;
private:
ICUBridgeCollationCompareFunctorImpl* const m_impl;
1.2 +99 -25 xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctorImpl.cpp
Index: ICUBridgeCollationCompareFunctorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctorImpl.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ICUBridgeCollationCompareFunctorImpl.cpp 4 Jan 2002 18:41:42 -0000 1.1
+++ ICUBridgeCollationCompareFunctorImpl.cpp 29 May 2002 18:22:02 -0000 1.2
@@ -77,17 +77,25 @@
+inline Collator*
+createCollator(UErrorCode& theStatus)
+{
+#if defined(XALAN_ICU_DEFAULT_LOCALE_PROBLEM)
+ return Collator::createInstance(Locale::US, theStatus);
+#else
+ return Collator::createInstance(theStatus);
+#endif
+}
+
+
+
ICUBridgeCollationCompareFunctorImpl::ICUBridgeCollationCompareFunctorImpl() :
m_isValid(false),
m_defaultCollator(0)
{
UErrorCode theStatus = U_ZERO_ERROR;
-#if defined(XALAN_ICU_DEFAULT_LOCALE_PROBLEM)
- m_defaultCollator = Collator::createInstance(Locale::US, theStatus);
-#else
- m_defaultCollator = Collator::createInstance(theStatus);
-#endif
+ m_defaultCollator = createCollator(theStatus);
if (theStatus == U_ZERO_ERROR ||
(theStatus >= U_ERROR_INFO_START && theStatus < U_ERROR_INFO_LIMIT))
@@ -105,32 +113,91 @@
+inline int
+doCompare(
+ const Collator& theCollator,
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
+{
+#if defined(XALAN_USE_WCHAR_CAST_HACK)
+ return theCollator.compare(
+ (const wchar_t*)theLHS,
+ length(theLHS),
+ (const wchar_t*)theRHS,
+ length(theRHS));
+#else
+ return theCollator.compare(
+ theLHS,
+ length(theLHS),
+ theRHS,
+ length(theRHS));
+#endif
+}
+
+
+
+inline UColAttributeValue
+caseOrderConvert(ICUBridgeCollationCompareFunctorImpl::eCaseOrder theCaseOrder)
+{
+ switch(theCaseOrder)
+ {
+ case StylesheetExecutionContext::eLowerFirst:
+ return UCOL_LOWER_FIRST;
+ break;
+
+ case StylesheetExecutionContext::eUpperFirst:
+ return UCOL_UPPER_FIRST;
+ break;
+
+ case StylesheetExecutionContext::eDefault:
+ break;
+
+ default:
+ assert(false);
+ break;
+ }
+
+ return UCOL_DEFAULT;
+}
+
+
+
int
ICUBridgeCollationCompareFunctorImpl::doDefaultCompare(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder) const
{
if (isValid() == false)
{
- return s_defaultFunctor(theLHS, theRHS);
+ return s_defaultFunctor(theLHS, theRHS, theCaseOrder);
}
- else
+ else if (theCaseOrder == StylesheetExecutionContext::eDefault)
{
assert(m_defaultCollator != 0);
-#if defined(XALAN_USE_WCHAR_CAST_HACK)
- return m_defaultCollator->compare(
- (const wchar_t*)theLHS,
- length(theLHS),
- (const wchar_t*)theRHS,
- length(theRHS));
-#else
- return m_defaultCollator->compare(
- theLHS,
- length(theLHS),
- theRHS,
- length(theRHS));
-#endif
+ return doCompare(*m_defaultCollator, theLHS, theRHS);
+ }
+ else
+ {
+ UErrorCode theStatus = U_ZERO_ERROR;
+
+ XalanAutoPtr<Collator> theCollator(createCollator(theStatus));
+
+ if (theStatus == U_ZERO_ERROR ||
+ (theStatus >= U_ERROR_INFO_START && theStatus < U_ERROR_INFO_LIMIT))
+ {
+ theCollator->setAttribute(
+ UCOL_CASE_FIRST,
+ caseOrderConvert(theCaseOrder),
+ theStatus);
+
+ return doCompare(*theCollator.get(), theLHS, theRHS);
+ }
+ else
+ {
+ return s_defaultFunctor(theLHS, theRHS, theCaseOrder);
+ }
}
}
@@ -139,9 +206,10 @@
int
ICUBridgeCollationCompareFunctorImpl::operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder) const
{
- return doDefaultCompare(theLHS, theRHS);
+ return doDefaultCompare(theLHS, theRHS, theCaseOrder);
}
@@ -189,7 +257,8 @@
ICUBridgeCollationCompareFunctorImpl::operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder) const
{
UErrorCode theStatus = U_ZERO_ERROR;
@@ -200,6 +269,11 @@
{
assert(theCollator.get() != 0);
+ theCollator->setAttribute(
+ UCOL_CASE_FIRST,
+ caseOrderConvert(theCaseOrder),
+ theStatus);
+
#if defined(XALAN_USE_WCHAR_CAST_HACK)
return theCollator->compare(
(const wchar_t*)theLHS,
@@ -216,6 +290,6 @@
}
else
{
- return s_defaultFunctor(theLHS, theRHS);
+ return s_defaultFunctor(theLHS, theRHS, theCaseOrder);
}
}
1.2 +11 -5 xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctorImpl.hpp
Index: ICUBridgeCollationCompareFunctorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/ICUBridge/ICUBridgeCollationCompareFunctorImpl.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ICUBridgeCollationCompareFunctorImpl.hpp 4 Jan 2002 18:41:42 -0000 1.1
+++ ICUBridgeCollationCompareFunctorImpl.hpp 29 May 2002 18:22:02 -0000 1.2
@@ -73,10 +73,13 @@
-class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl
+class XALAN_ICUBRIDGE_EXPORT ICUBridgeCollationCompareFunctorImpl : public StylesheetExecutionContextDefault::CollationCompareFunctor
{
public:
+ typedef StylesheetExecutionContextDefault::eCaseOrder eCaseOrder;
+
+
ICUBridgeCollationCompareFunctorImpl();
~ICUBridgeCollationCompareFunctorImpl();
@@ -84,13 +87,15 @@
int
operator()(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const;
int
operator()(
const XalanDOMChar* theLHS,
const XalanDOMChar* theRHS,
- const XalanDOMChar* theLocale) const;
+ const XalanDOMChar* theLocale,
+ eCaseOrder theCaseOrder = StylesheetExecutionContextDefault::eDefault) const;
bool
isValid() const
@@ -103,9 +108,10 @@
int
doDefaultCompare(
const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS) const;
+ const XalanDOMChar* theRHS,
+ eCaseOrder theCaseOrder) const;
- bool m_isValid;
+ bool m_isValid;
#if defined(XALAN_NO_NAMESPACES)
Collator* m_defaultCollator;
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org