dbertoni    00/04/21 13:28:23

  Modified:    c/src/PlatformSupport DOMStringHelper.cpp
                        DOMStringHelper.hpp
  Log:
  Added functions to compare according to collation sequence.
  
  Revision  Changes    Path
  1.17      +53 -3     xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp
  
  Index: DOMStringHelper.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DOMStringHelper.cpp       2000/04/20 16:42:28     1.16
  +++ DOMStringHelper.cpp       2000/04/21 20:28:22     1.17
  @@ -706,8 +706,35 @@
   
   
   
  -XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
  -compare(
  +struct WideStringLexicalCompare
  +{
  +     int
  +     operator()(
  +                     const XalanDOMChar*             theLHS,
  +                     const XalanDOMChar*             theRHS) const
  +     {
  +             return compare(theLHS, theRHS);
  +     }
  +};
  +
  +
  +
  +struct WideStringCollationCompare
  +{
  +     int
  +     operator()(
  +                     const XalanDOMChar*             theLHS,
  +                     const XalanDOMChar*             theRHS) const
  +     {
  +             return collationCompare(theLHS, theRHS);
  +     }
  +};
  +
  +
  +
  +template<class CompareFunctionType>
  +DOMStringCompare(
  +                     CompareFunctionType             theCompareFunction,
                        const XalanDOMString&   theLHS,
                        const XalanDOMString&   theRHS)
   {
  @@ -741,10 +768,33 @@
        {
                assert(c_wstr(theLHS) != 0 && c_wstr(theRHS) != 0);
   
  -             return compare(c_wstr(theLHS), c_wstr(theRHS));
  +             return theCompareFunction(c_wstr(theLHS), c_wstr(theRHS));
        }
   }
   
  +
  +
  +XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
  +compare(
  +                     const XalanDOMString&   theLHS,
  +                     const XalanDOMString&   theRHS)
  +{
  +     return DOMStringCompare(WideStringLexicalCompare(),
  +                                                     theLHS,
  +                                                     theRHS);
  +}
  +
  +
  +
  +XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
  +collationCompare(
  +                     const XalanDOMString&   theLHS,
  +                     const XalanDOMString&   theRHS)
  +{
  +     return DOMStringCompare(WideStringCollationCompare(),
  +                                                     theLHS,
  +                                                     theRHS);
  +}
   
   
   
  
  
  
  1.14      +64 -11    xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp
  
  Index: DOMStringHelper.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DOMStringHelper.hpp       2000/04/20 16:42:29     1.13
  +++ DOMStringHelper.hpp       2000/04/21 20:28:22     1.14
  @@ -810,18 +810,18 @@
   
   
   
  +#if defined(XALAN_FULL_WCHAR_SUPPORT)
  +
   /**
  - * Compare the contents of two strings for equality
  + * Compare the contents of two strings.
    * 
    * @param theLHS first string to compare
    * @param theRHS second string to compare
  - * @return Returns 0 for equal strings, less than 0 if theLHS is lexically
  - * less than theRHS, or greater than 0 if theRHS is lexically greater than
  - * theLHS.
  + * @return Returns 0 for equal strings, less than 0 if theLHS is less
  + * than theRHS, or greater than 0 if theRHS is greater than theLHS.
    * @see operator<
  + * @see collationCompare
    */
  -#if defined(XALAN_FULL_WCHAR_SUPPORT)
  -
   inline int
   compare(
                        const XalanDOMChar*             theLHS,
  @@ -841,18 +841,71 @@
   
   
   
  +#if defined(XALAN_FULL_WCHAR_SUPPORT)
  +
   /**
  - * Compare the contents of two strings for equality
  + * Compare the contents of two strings using the
  + * the collation settings of the current code page.
    * 
    * @param theLHS first string to compare
    * @param theRHS second string to compare
  - * @return Returns 0 for equal strings, less than 0 if theLHS is lexically
  - * less than theRHS, or greater than 0 if theRHS is lexically greater than
  - * theLHS.
  - * @see operator<
  + * @return Returns 0 for equal strings, less than 0 if theLHS is less
  + * than theRHS, or greater than 0 if theRHS is greater than theLHS.
  + * @see operator<()
  + * @see compare()
  + */
  +inline int
  +collationCompare(
  +                     const XalanDOMChar*             theLHS,
  +                     const XalanDOMChar*             theRHS)
  +{
  +     return wcscoll(theLHS, theRHS);
  +}
  +
  +#else
  +
  +// Can't really do it, so just call compare...
  +inline int
  +collationCompare(
  +                     const XalanDOMChar*             theLHS,
  +                     const XalanDOMChar*             theRHS)
  +{
  +     return compare(theLHS, theRHS);
  +}
  +
  +#endif
  +
  +
  +
  +/**
  + * Compare the contents of two strings.
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return Returns 0 for equal strings, less than 0 if theLHS is less
  + * than theRHS, or greater than 0 if theRHS is greater than theLHS.
  + * @see operator<()
  + * @see collationCompare()
    */
   XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
   compare(
  +                     const XalanDOMString&   theLHS,
  +                     const XalanDOMString&   theRHS);
  +
  +
  +/**
  + * Compare the contents of two strings using the
  + * the collation settings of the current code page.
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return Returns 0 for equal strings, less than 0 if theLHS is less
  + * than theRHS, or greater than 0 if theRHS is greater than theLHS.
  + * @see operator<()
  + * @see compare()
  + */
  +XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(int)
  +collationCompare(
                        const XalanDOMString&   theLHS,
                        const XalanDOMString&   theRHS);
   
  
  
  

Reply via email to