# Class condition

- Defined in File condition.hpp

## Class Documentation

class condition

  The interface class for conditions. This uses the bridge pattern, which means the implementation is in the member m_impl.

  Public Functions

  inline condition()

    Construct a new, empty condition object.

  inline explicit condition(condition_impl *impl)

    Construct a new condition object with implementation impl.

    Parameters:

      impl – The implementation to use

  condition(const condition&) = delete
  inline condition(condition &&rhs) noexcept

    Construct a new condition object moving the data from rhs.

  condition &operator=(const condition&) = delete
  inline condition &operator=(condition &&rhs) noexcept

    Assignment operator moving the data from rhs.

  inline ~condition()
  bool prepare(const category &c)

    Prepare the condition to be used on category c. This will take care of setting the correct indices for items e.g.

    Parameters:

      c – The category this query should act upon

    Returns:

      Returns true if the condition might result in rows

  inline bool operator()(const_row_handle r) const

    This operator returns true if the row referenced by r is a match for this condition.

    Parameters:

      r – The reference to a row.

    Returns:

      true If there is a match

    Returns:

      false If there is no match

  inline explicit operator bool() const

    Return true if the condition is not empty.

  inline bool empty() const

    Return true if the condition is empty, has no condition.

  inline std::optional<const_row_handle> single() const

    If the prepare step found out there is only one hit this single hit can be returned by this method.

    Returns:

      std::optional<const_row_handle> The result will contain a row reference if there is a single hit, it will be empty otherwise

  Friends

  friend condition operator||(condition &&a, condition &&b)

    Create a condition containing the logical OR of conditions a and b.

    Return a condition which is the logical OR or condition and

  friend condition operator&&(condition &&a, condition &&b)

    Create a condition containing the logical AND of conditions a and b.

    Return a condition which is the logical AND or condition and

  inline friend void swap(condition &lhs, condition &rhs) noexcept

    Swap two conditions.

  inline friend std::ostream &operator<<(std::ostream &os, const condition &cond)

    Operator to use to write out a condition to os, for debugging purposes.

    Parameters:

      - os – The std::ostream to write to

      - cond – The condition to write

    Returns:

      std::ostream& The same as os