File indexing completed on 2024-04-28 05:37:01

0001 /***************************************************************************
0002  * Copyright (C) 2014 by Renaud Guezennec                                   *
0003  * https://rolisteam.org/contact                      *
0004  *                                                                          *
0005  *  This file is part of DiceParser                                         *
0006  *                                                                          *
0007  * DiceParser is free software; you can redistribute it and/or modify       *
0008  * it under the terms of the GNU General Public License as published by     *
0009  * the Free Software Foundation; either version 2 of the License, or        *
0010  * (at your option) any later version.                                      *
0011  *                                                                          *
0012  * This program is distributed in the hope that it will be useful,          *
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of           *
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
0015  * GNU General Public License for more details.                             *
0016  *                                                                          *
0017  * You should have received a copy of the GNU General Public License        *
0018  * along with this program; if not, write to the                            *
0019  * Free Software Foundation, Inc.,                                          *
0020  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 *
0021  ***************************************************************************/
0022 #ifndef RANGE_H
0023 #define RANGE_H
0024 
0025 #include "validator.h"
0026 #include <Qt>
0027 
0028 /**
0029  * @brief The Range class is validator class to check validity between two values.
0030  */
0031 class Range : public Validator
0032 {
0033 public:
0034     Range();
0035     void setValue(qint64, qint64);
0036     void setStart(qint64);
0037     void setEnd(qint64);
0038     virtual qint64 hasValid(Die* b, bool recursive, bool unlight= false) const override;
0039 
0040     virtual QString toString() override;
0041     virtual Dice::CONDITION_STATE isValidRangeSize(const std::pair<qint64, qint64>& range) const override;
0042 
0043     bool isFullyDefined() const;
0044     qint64 getStart() const;
0045     qint64 getEnd() const;
0046 
0047     void setEmptyRange(bool);
0048     bool isEmptyRange();
0049 
0050     virtual Validator* getCopy() const override;
0051 
0052 private:
0053     qint64 m_start= 0;
0054     qint64 m_end= 0;
0055     bool m_hasEnd;
0056     bool m_hasStart;
0057     bool m_emptyRange;
0058 };
0059 
0060 #endif // RANGE_H