00001 /*------------------------------------------------------------------------------ 00002 This file is part of PHP-AST Project by Romain Gaucher (http://rgaucher.info). 00003 00004 PHP-AST is free software: you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation, either version 3 of the License, or 00007 (at your option) any later version. 00008 00009 PHP-AST/ORACLE is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with PHP-AST. If not, see <http://www.gnu.org/licenses/>. 00016 ------------------------------------------------------------------------------*/ 00017 00018 #ifndef __AST_RANGE_H 00019 #define __AST_RANGE_H 00020 00021 #include "tree.h" 00022 class AstNode; 00023 00024 class AstRange 00025 { 00026 tree<AstNode>::iterator min; 00027 tree<AstNode>::iterator max; 00028 public: 00029 AstRange() {} 00030 AstRange(const tree<AstNode>::iterator& _min, const tree<AstNode>::iterator& _max) : min(_min), max(_max) {} 00031 AstRange(const AstRange& a) : min(a.min), max(a.max) {} 00032 AstRange& operator= (const AstRange& a) { 00033 min = a.min; 00034 max = a.max; 00035 return *this; 00036 } 00037 00038 inline void setMin(const tree<AstNode>::iterator& _min) { min = _min; } 00039 inline void setMax(const tree<AstNode>::iterator& _max) { max = _max; } 00040 inline tree<AstNode>::iterator& getMin() { return min; } 00041 inline tree<AstNode>::iterator& getMax() { return max; } 00042 00043 inline bool inRange(const tree<AstNode>::iterator& a) const { 00044 tree<AstNode>::iterator temp = min; 00045 for (;temp != max; ++temp) 00046 if (temp == a) 00047 return true; 00048 return false; 00049 } 00050 }; 00051 00052 typedef AstRange AstNodeRange; 00053 00054 #endif