company logo

Value :: compare - Compare the values for two value handles

The function compares the values of the two value handles. Instances in both value handles have to be selected. When operands on both sides are of different type or complexity, conversion is performed for the left operator before comparing.

The function returns -1 when the value for the left operand (calling handle) is lower than the value for the right operand (parameter). The function returns 1 when the the value for the left operand is higher than the value for right operand. The function returns 0 when values are equal.

The function throws an exception, when one of the value handles is invalid or when no instance is selected in one of the value handles. An exception is thrown also, when values are not comparable, i.e. when converting the right operand failed. In order to check, whether values are comparable, one may call canCompare().

Return value:  Compare result ( int32  )

The result of a comparison is an integer value with the following meaning:

  • 0: both operands have the same value
  • 1: the calling operand is greater than the passed operand
  • -1: the calling operand is smaller than the passed operand

Implementation overview

Implementation details

  1. Compare with date
    int32 Value  :: compare ( odaba::Date &cDate )

    This implementation compares the value with the date passed in cDate. Data conversion is performed for the passed value when required. Converting date values to string values may result in different string values for the same date value depending on the national setting. Hence, string values should not be compared with date values. In this case it is more appropriate to compare the date values directly by calling toDate().

    • cDate - Date

      The date contains day, month and year, but not the time.

  2. to list
  3. Compare with double
    int32 Value  :: compare ( double vDouble )

    This implementation compares the value with the double value passed in vDouble. Data conversion is performed for the passed value when required.

    • vDouble - Double value
  4. to list
  5. Compare with integer
    int32 Value  :: compare ( int32 iValue )

    This implementation compares the value with the integer value passed in iValue. Data conversion is performed for the passed value when required.

    • iValue - Integer value

      The value is passed as platform independent 32-bit integer value.

  6. to list
  7. Compare with string
    int32 Value  :: compare ( odaba::String &sString )

    This implementation compares the value with the string value passed in sString. Data conversion is performed for the string when required.

    • sString - String value
  8. to list
  9. Compare with time
    int32 Value  :: compare ( odaba::Time &cTime )

    This implementation compares the value with the time passed in cTime. Data conversion is performed for the passed value when required. Converting date values to string values may result in different string values for the same time value depending on the national setting. Hence, string values should not be compared with time values, directly. In this case, it is more appropriate to compare the time value directly by calling toTime().

    • cTime - Time value

      The time value is passed in the ODABA Interface::Time format and provides time in 1/100th seconds.

  10. to list
  11. Compare with value
    int32 Value  :: compare ( odaba::Value &cValue )

    This implementation compares the value with the value passed in cValue. Data conversion is performed for cValue when required.

    • cValue - Value handle

      A value handle refers to a (usually) opened value. Invalid value handles may cause an exception.

  12. to list