/* Copyright (C) 2019 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/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <gtk/gtk.h>
#include <cstddef> // std::size_t

_DEFS(gtkmm,gtk)

namespace Gtk
{
/** Presents a location in a file - or other source of data parsed by the CSS engine.
 * 
 * The @a bytes and @a line_bytes offsets are meant to be used to
 * programmatically match data. The @a lines and @a line_chars offsets
 * can be used for printing the location in a file.
 *
 * Note that the @a lines parameter starts from 0 and is increased
 * whenever a CSS line break is encountered. (CSS defines the C character
 * sequences "\r\n", "\r", "\n" and "\f" as newlines.)
 * If your document uses different rules for line breaking, you might
 * run into problems here.
 *
 * @newin{3,96}
 */
class GTKMM_API CssLocation
{
  _CLASS_GENERIC(CssLocation, GtkCssLocation)
public:

  CssLocation();
  CssLocation(const GtkCssLocation* location);
  CssLocation(std::size_t bytes, std::size_t chars, std::size_t lines,
    std::size_t line_bytes, std::size_t line_chars);

#m4 _EQUAL(gsize, std::size_t)
  /** @returns Number of bytes parsed since the beginning.
   */
  _MEMBER_GET(bytes, bytes, std::size_t, gsize)
  _MEMBER_SET(bytes, bytes, std::size_t, gsize)

  /** @returns Number of characters parsed since the beginning.
   */
  _MEMBER_GET(chars, chars, std::size_t, gsize)
  _MEMBER_SET(chars, chars, std::size_t, gsize)

  /** @returns Number of full lines that have been parsed.
   *           If you want to display this as a line number, you
   *           need to add 1 to this.
   */
  _MEMBER_GET(lines, lines, std::size_t, gsize)
  _MEMBER_SET(lines, lines, std::size_t, gsize)

  /** @returns Number of bytes parsed since the last line break.
   */
  _MEMBER_GET(line_bytes, line_bytes, std::size_t, gsize)
  _MEMBER_SET(line_bytes, line_bytes, std::size_t, gsize)

  /** @returns Number of characters parsed since the last line break.
   */
  _MEMBER_GET(line_chars, line_chars, std::size_t, gsize)
  _MEMBER_SET(line_chars, line_chars, std::size_t, gsize)

  GtkCssLocation*       gobj()       { return &gobject_; }
  const GtkCssLocation* gobj() const { return &gobject_; }

protected:
  GtkCssLocation gobject_;
};

} // namespace Gtk

namespace Glib
{
  /** A Glib::wrap() method for this object.
   *
   * @param object The C instance.
   * @result A C++ instance that wraps a copy of this C instance.
   *
   * @relates Gtk::CssLocation
   */
GTKMM_API
Gtk::CssLocation wrap(const GtkCssLocation* object);

} // namespace Glib
