class AutoC::Range::InputRange

@abstract

Private Instance Methods

configure() click to toggle source
Calls superclass method AutoC::Range#configure
# File lib/autoc/ranges.rb, line 117
def configure
  super
  method(:int, :empty, { range: const_rvalue }).configure do
    header %{
      @brief Check for range emptiness

      @param[in] range range to check
      @return non-zero value if the range is not empty or zero value otherwise

      An empty range is the range for which there are to accessible elements left.
      This specifically means that any calls to the element retrieval and position change functions
      (@ref #{type.take_front}, @ref #{type.view_front}, @ref #{type.pop_front} et al.) are invalid for empty ranges.

      @since 2.0
    }
  end
  method(:void, :pop_front, { range: rvalue }).configure do
    header %{
      @brief Advance front position to the next existing element

      @param[in] range range to advance front position for

      This function is used to get to the next element in the range.

      @note Prior calling this function one must ensure that the range is not empty (see @ref #{type.empty}).
      Advancing position of a range that is already empty results in undefined behaviour.

      @since 2.0
    }
  end
  method(iterable.element.const_lvalue, :view_front, { range: const_rvalue }).configure do
    header %{
      @brief Get a view of the front element

      @param[in] range range to retrieve element from
      @return a view of an element at the range's front position

      This function is used to get a constant reference (in form of the C pointer) to the value contained in the iterable container at the range's front position.
      Refer to @ref #{type.take_front} to get an independent copy of that element.
  
      It is generally not safe to bypass the constness and to alter the value in place (although no one prevents to).
  
      @note Range must not be empty (see @ref #{type.empty}).

      @since 2.0
    }
  end
  method(iterable.element, :take_front, { range: const_rvalue }, constraint:-> { iterable.element.copyable? }).configure do
    dependencies << empty << view_front
    inline_code %{
      #{iterable.element} result;
      #{iterable.element.const_lvalue} e;
      assert(!#{empty.(range)});
      e = #{view_front.(range)};
      #{iterable.element.copy.(:result, '*e')};
      return result;
    }
    header %{
      @brief Get a copy of the front element

      @param[in] range range to retrieve element from
      @return a *copy* of element at the range's front position

      This function is used to get a *copy* of the value contained in the iterable container at the range's front position.
      Refer to @ref #{type.view_front} to get a view of the element without making an independent copy.

      This function requires the element type to be *copyable* (i.e. to have a well-defined copy operation).

      @note Range must not be empty (see @ref #{type.empty}).

      @since 2.0
    }
  end
end