// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2006 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WINTVALIDATOR_H_
#define WINTVALIDATOR_H_

#include <limits>

#include <WValidator>

namespace Wt {

/*! \class WIntValidator WIntValidator WIntValidator
 *  \brief A validator that validates integer user input.
 *
 * This validator checks whether user input is an integer number in a
 * pre-defined range.
 */
class WT_API WIntValidator : public WValidator
{
public:
  /*! \brief Create a new integer validator that accepts integer input
   *         within the given range.
   */
  WIntValidator(int minimum = std::numeric_limits<int>::min(),
		int maximum = std::numeric_limits<int>::max());

  /*! \brief Return the bottom of the valid integer range.
   */
  int bottom() const { return bottom_; }

  /*! \brief Set the bottom of the valid integer range.
   */
  void setBottom(int bottom);

  /*! \brief Return the top of the valid integer range.
   */
  int top() const { return top_; }

  /*! \brief Set the top of the valid integer range.
   */
  void setTop(int top);

  /*! \brief Set the range of valid integers.
   */
  virtual void setRange(int bottom, int top);

  /*! \brief Validate the input as an integer within the given range.
   *
   * Returns Valid if the input is an integer in the given range.
   * Returns Invalid if the input is not an integer, or outside of the
   * given range.        
   */
  virtual State validate(WString& input, int& pos) const;

private:
  int bottom_;
  int top_;
};

}

#endif // WINTVALIDATOR_H_
