/* Copyright (C) 2020 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/sorter.h>
#include <gtkmm/expression.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/sorter_p.h)

namespace Gtk
{

/** Sort by comparing strings.
 *
 * %Gtk::StringSorter is a Gtk::Sorter that compares strings. It does the
 * comparison in a linguistically correct way using the current locale by
 * normalizing Unicode strings and possibly case-folding them before
 * performing the comparison.
 *
 * To obtain the strings to compare, this sorter evaluates a Gtk::Expression.
 *
 * @see Gtk::Expression
 * @newin{3,98}
 */
class GTKMM_API StringSorter : public Sorter
{
  _CLASS_GOBJECT(StringSorter, GtkStringSorter, GTK_STRING_SORTER, Gtk::Sorter, GtkSorter, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkStringSorter is a final type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(StringSorter(const Glib::RefPtr<Expression<Glib::ustring>>& expression), gtk_string_sorter_new)

public:
  _WRAP_CREATE(const Glib::RefPtr<Expression<Glib::ustring>>& expression)

  _WRAP_METHOD(Glib::RefPtr<Expression<Glib::ustring>> get_expression(), gtk_string_sorter_get_expression, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Expression<Glib::ustring>> get_expression() const, gtk_string_sorter_get_expression, refreturn)
  _WRAP_METHOD(void set_expression(const Glib::RefPtr<Expression<Glib::ustring>>& expression), gtk_string_sorter_set_expression)
  _WRAP_METHOD(bool get_ignore_case() const, gtk_string_sorter_get_ignore_case)
  _WRAP_METHOD(void set_ignore_case(bool ignore_case = true), gtk_string_sorter_set_ignore_case)

  _WRAP_PROPERTY("expression", Glib::RefPtr<Expression<Glib::ustring>>)
  _WRAP_PROPERTY("ignore-case", bool)
};

} // namespace Gtk
