dbertoni    00/05/03 14:09:35

  Modified:    c/src/PlatformSupport DOMStringHelper.hpp DoubleSupport.cpp
                        DoubleSupport.hpp
  Log:
  New functors and support functions for comparison.
  
  Revision  Changes    Path
  1.17      +116 -1    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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DOMStringHelper.hpp       2000/04/27 15:09:37     1.16
  +++ DOMStringHelper.hpp       2000/05/03 21:09:33     1.17
  @@ -1285,7 +1285,122 @@
        operator() (first_argument_type         theLHS,
                                second_argument_type    theRHS) const
        {
  -             return theLHS.equals(theRHS);
  +             return compare(theLHS, theRHS) == 0 ? true : false;
  +     }
  +};
  +
  +
  +
  +/**
  + * Not equals functor for DOMStrings
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return true if the contents of both strings are identical
  + */
  +#if defined(XALAN_NO_NAMESPACES)
  +struct DOMStringNotEqualsFunction : public binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#else
  +struct DOMStringNotEqualsFunction : public std::binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#endif
  +{
  +     result_type
  +     operator() (first_argument_type         theLHS,
  +                             second_argument_type    theRHS) const
  +     {
  +             return compare(theLHS, theRHS) == 0 ? false : true;
  +     }
  +};
  +
  +
  +
  +/**
  + * Less than functor for DOMStrings
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return true if the contents of both strings are identical
  + */
  +#if defined(XALAN_NO_NAMESPACES)
  +struct DOMStringLessThanFunction : public binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#else
  +struct DOMStringLessThanFunction : public std::binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#endif
  +{
  +     result_type
  +     operator() (first_argument_type         theLHS,
  +                             second_argument_type    theRHS) const
  +     {
  +             return compare(theLHS, theRHS) < 0 ? true : false;
  +     }
  +};
  +
  +
  +
  +/**
  + * Less than or equal functor for DOMStrings
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return true if the contents of both strings are identical
  + */
  +#if defined(XALAN_NO_NAMESPACES)
  +struct DOMStringLessThanOrEqualFunction : public binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#else
  +struct DOMStringLessThanOrEqualFunction : public std::binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#endif
  +{
  +     result_type
  +     operator() (first_argument_type         theLHS,
  +                             second_argument_type    theRHS) const
  +     {
  +             return compare(theLHS, theRHS) <= 0 ? true : false;
  +     }
  +};
  +
  +
  +
  +/**
  + * Greater than functor for DOMStrings
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return true if the contents of both strings are identical
  + */
  +#if defined(XALAN_NO_NAMESPACES)
  +struct DOMStringGreaterThanFunction : public binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#else
  +struct DOMStringGreaterThanFunction : public std::binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#endif
  +{
  +     result_type
  +     operator() (first_argument_type         theLHS,
  +                             second_argument_type    theRHS) const
  +     {
  +             return compare(theLHS, theRHS) > 0 ? true : false;
  +     }
  +};
  +
  +
  +
  +/**
  + * Greater than or equal functor for DOMStrings
  + * 
  + * @param theLHS first string to compare
  + * @param theRHS second string to compare
  + * @return true if the contents of both strings are identical
  + */
  +#if defined(XALAN_NO_NAMESPACES)
  +struct DOMStringGreaterThanOrEqualFunction : public binary_function<const 
XalanDOMString&, const XalanDOMString&, bool>
  +#else
  +struct DOMStringGreaterThanOrEqualFunction : public 
std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
  +#endif
  +{
  +     result_type
  +     operator() (first_argument_type         theLHS,
  +                             second_argument_type    theRHS) const
  +     {
  +             return compare(theLHS, theRHS) >= 0 ? true : false;
        }
   };
   
  
  
  
  1.6       +102 -1    xml-xalan/c/src/PlatformSupport/DoubleSupport.cpp
  
  Index: DoubleSupport.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DoubleSupport.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DoubleSupport.cpp 2000/04/20 16:42:29     1.5
  +++ DoubleSupport.cpp 2000/05/03 21:09:34     1.6
  @@ -60,7 +60,6 @@
   #if defined(NO_STD_LIMITS)
   #if defined(__GNUC__)
   #include <math.h>
  -// @@ JMD: Shouldn't need this as well ??
   #include <bits/nan.h>
   #else
   #error Unsupported platform!!!
  @@ -106,3 +105,105 @@
   const unsigned long* DoubleSupport::s_NaNSecondDWORD =
                                        s_NaNFirstDWORD + 1;
   #endif
  +
  +
  +
  +bool
  +DoubleSupport::equal(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return theLHS == theRHS;
  +     }
  +}
  +
  +
  +
  +bool
  +DoubleSupport::notEqual(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return true;
  +     }
  +     else
  +     {
  +             return theLHS != theRHS;
  +     }
  +}
  +
  +
  +
  +bool
  +DoubleSupport::lessThan(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return theLHS < theRHS;
  +     }
  +}
  +
  +
  +
  +bool
  +DoubleSupport::lessThanOrEqual(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return theLHS <= theRHS;
  +     }
  +}
  +
  +
  +
  +bool
  +DoubleSupport::greaterThan(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return theLHS > theRHS;
  +     }
  +}
  +
  +
  +
  +bool
  +DoubleSupport::greaterThanOrEqual(
  +                     double  theLHS,
  +                     double  theRHS)
  +{
  +     if (isNaN(theLHS) == true || isNaN(theRHS) == true)
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             return theLHS >= theRHS;
  +     }
  +}
  
  
  
  1.3       +174 -0    xml-xalan/c/src/PlatformSupport/DoubleSupport.hpp
  
  Index: DoubleSupport.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DoubleSupport.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DoubleSupport.hpp 2000/02/23 20:23:11     1.2
  +++ DoubleSupport.hpp 2000/05/03 21:09:34     1.3
  @@ -64,6 +64,10 @@
   
   
   
  +#include <functional>
  +
  +
  +
   class XALAN_PLATFORMSUPPORT_EXPORT DoubleSupport
   {
   public:
  @@ -166,6 +170,176 @@
        {
                return s_negativeInfinity;
        }
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     equal(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     notEqual(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     lessThan(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     lessThanOrEqual(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     greaterThan(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     /**
  +      * Compare two double values, taking into account
  +      * the fact that we must support IEEE 754
  +      *
  +      * *param theLHS a number to compare
  +      * *param theRHS a number to compare
  +      * @return the result of the compare
  +      */
  +     static bool
  +     greaterThanOrEqual(
  +                     double  theLHS,
  +                     double  theRHS);
  +
  +     // Some functors to do the same thing.  This is for
  +     // STL integration...
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct equalFunction : public binary_function<const double&, const 
double&, bool>
  +     #else
  +     struct equalFunction : public std::binary_function<const double&, const 
double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return equal(theLHS, theRHS);
  +             }
  +     };
  +
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct notEqualFunction : public binary_function<const double&, const 
double&, bool>
  +     #else
  +     struct notEqualFunction : public std::binary_function<const double&, 
const double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return notEqual(theLHS, theRHS);
  +             }
  +     };
  +
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct lessThanFunction : public binary_function<const double&, const 
double&, bool>
  +     #else
  +     struct lessThanFunction : public std::binary_function<const double&, 
const double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return lessThan(theLHS, theRHS);
  +             }
  +     };
  +
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct lessThanOrEqualFunction : public binary_function<const double&, 
const double&, bool>
  +     #else
  +     struct lessThanOrEqualFunction : public std::binary_function<const 
double&, const double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return lessThanOrEqual(theLHS, theRHS);
  +             }
  +     };
  +
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct greaterThanFunction : public binary_function<const double&, 
const double&, bool>
  +     #else
  +     struct greaterThanFunction : public std::binary_function<const double&, 
const double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return greaterThan(theLHS, theRHS);
  +             }
  +     };
  +
  +     #if defined(XALAN_NO_NAMESPACES)
  +     struct greaterThanOrEqualFunction : public binary_function<const 
double&, const double&, bool>
  +     #else
  +     struct greaterThanOrEqualFunction : public std::binary_function<const 
double&, const double&, bool>
  +     #endif
  +     {
  +             result_type
  +             operator()(
  +                     first_argument_type             theLHS,
  +                     second_argument_type    theRHS) const
  +             {
  +                     return greaterThanOrEqual(theLHS, theRHS);
  +             }
  +     };
   
   private:
   
  
  
  

Reply via email to