company logo

Binary :: compare - Compare two binary data blocks

The function compares the binary data block with the passed binary data. The function returns 0, when both blocks are identical. The function returns -1, when the first byte differing is less in the current data block than in the passed area. When the first differing value in the current data block is larger, the function returns 1.

When data block areas differ in size, but are identical in the smaller part, the larger binary data block is considered as the larger one.

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 two binary data blocks
    int32 Binary  :: compare ( odaba::Binary &cBinary )

    The function compares the current binary data block with the one passed in cBinary.

    • cBinary - Binary data block handle

      Constant reference to a binary data block handle, which may contain binary data up to 2 GB.

  2. to list
  3. Compare part of the binary data block
    int32 Binary  :: compare ( int32 iPosition, int32 iCount, odaba::Binary &cBinary )

    The function compares iCount bytes of the current data block beginning at iPosition with the binary data block passed in cBinary.

    The function provides a sort of shortcut for mid(iPosition,iCount).compare(cBinary).

    When iPosition is less than zero or iCount is less than -1, the function throws an exception.

    • iPosition - Position in collection

      The position of an element in a collection is beginning with 0 for the first element.

    • iCount - Number of items

      The value contains the number of items to be processed or stored in a collection.

    • cBinary - Binary data block handle

      Constant reference to a binary data block handle, which may contain binary data up to 2 GB.

  4. to list
  5. Compare binary data block at position
    int32 Binary  :: compare ( int32 iPosition, odaba::Binary &cBinary )

    The function compares the current binary data block beginning at position iPosition with the binary data block passed in cBinary.

    • iPosition - Position in collection

      The position of an element in a collection is beginning with 0 for the first element.

    • cBinary - Binary data block handle

      Constant reference to a binary data block handle, which may contain binary data up to 2 GB.

  6. to list