Vidalia  0.2.17
PortValidator.cpp
Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file PortValidator.cpp
00013 ** \brief Validates that a number is a valid port number
00014 */
00015 
00016 #include "PortValidator.h"
00017 
00018 #define MIN_PORT  1     /**< Minimum valid port. */
00019 #define MAX_PORT  65535 /**< Maximum valid port. */
00020 #define MATCH_ALL "*"   /**< Matches all ports. */
00021 
00022 
00023 /** Constructor. */
00024 PortValidator::PortValidator(QObject *parent)
00025  : QIntValidator(MIN_PORT, MAX_PORT, parent)
00026 {
00027 }
00028 
00029 /** Validates that the given port is either a valid port or a "*". */
00030 QValidator::State
00031 PortValidator::validate(QString &input, int &pos) const
00032 {
00033   if (input == MATCH_ALL) {
00034     return QValidator::Acceptable;
00035   }
00036   return QIntValidator::validate(input, pos);
00037 }
00038