// -*- c++ -*-

/*
 * Jakelib2 - General purpose C++ library
 * Copyright (C) 2001 Florian Wolff  (florian@donuz.de)
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: ParsePosition.h,v 1.2 2003/09/17 08:16:51 florian Exp $
 */

#ifndef INCLUDE_JAKELIB2_TEXT_PARSEPOSITION_H
# define INCLUDE_JAKELIB2_TEXT_PARSEPOSITION_H

namespace jakelib {
  namespace text {

    /**
     * This class is used to keep track of the current position during parsing
     * operations.
     *
     * @author Alex Fabijanic <fabijanica@nucorsteel.com>(jakelib2 port)
     */
    class ParsePosition : public jakelib::lang::Object
    {
    public:

      /**
       * This method initializes a new instance of <code>ParsePosition</code> to
       * have the specified initial index value.
       *
       * @param index The initial parsing index.
       */
      ParsePosition(jint index);

      /**
       * This method returns the current parsing index.
       *
       * @return The current parsing index
       */
      jint getIndex();

      /**
       * This method sets the current parsing index to the specified value.
       *
       * @param index The new parsing index.
       */
      void setIndex(jint index);

      /**
       * This method returns the error index value. This value defaults to \c -1
       * unless explicitly set to another value.
       *
       * @return The error index.
       */
      jint getErrorIndex();

      /**
       * This method sets the error index to the specified value.
       *
       * @param error_index The new error index
       */
      void setErrorIndex(jint error_index);

      /**
       * This method tests the specified object for equality with this
       * object. The two objects will be considered equal if and only if
       * all of the following conditions are met.
       *
       * \li The specified object is not \c null.
       * \li The specified object is an instance of ParsePosition.
       * \li The specified object has the same index and error index as
       *     this object.  
       *
       * @param obj The \c Object to test for equality against
       *            this object. 
       *
       * @return \c true if the specified object is equal to
       *         this object, \c false otherwise.
       */
      jboolean equals(jakelib::lang::Object* obj);

      /**
       * This method returns a human-readable String representation of this
       * object.
       *
       * @return A String that represents this object.
       */
      jakelib::lang::String* toString();

    private:

      /**
       * This is the index of the current parse position.
       */
      jint index;

      /**
       * This is the index of the position where an error occurred during parsing.
       */
      jint error_index;

      JAKELIB_DECLARE_CLASS(ParsePosition);
    };
  }
}

#endif
