Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/lex/location.h

Go to the documentation of this file.
00001 /*
00002  * lib/lex/location.h
00003  * 
00004  * Source code location (file/line) representation. 
00005  * 
00006  * Copyright (c) 2003--2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #ifndef _LIB_LEX_LOCATION_H_
00018 #define _LIB_LEX_LOCATION_H_ 1
00019 
00029 #include <lib/sconfig.h>    /* MUST be first */
00030 
00031 #include <lib/sourcepos/sourcepos.h>
00032 
00033 
00034 class SCLocationRange;
00035 
00047 struct /*_packed_*/ SCLocation  /* C++ save */
00048 {
00049     friend class SCLocationRange;
00050     
00051     enum _NullLoc { NullLoc };
00052     
00054     SourcePosition pos;
00055     
00057     inline SCLocation(_NullLoc = NullLoc) : pos()  {}
00059     inline SCLocation(const SourcePosition &p) : pos(p)  {}
00061     inline SCLocation(const SCLocation &loc) : pos(loc.pos)  {}
00067     SCLocation(const TLString &path,int line=-1,int lpos=-1);
00069     inline ~SCLocation() {}
00070     
00072     inline SCLocation &operator=(const SCLocation &loc)
00073         {  pos=loc.pos;  return(*this);  }
00075     inline SCLocation &operator=(_NullLoc)
00076         {  pos=SourcePosition();  return(*this);  }
00077     
00079     inline bool operator!() const
00080         {  return(!pos);  }
00082     inline operator bool() const
00083         {  return(pos.operator bool());  }
00084     
00086     inline TLString path() const
00087         {  return(pos->path());  }
00089     inline int line() const
00090         {  return(pos->line());  }
00092     inline int lpos() const
00093         {  return(pos->lpos());  }
00094     
00101     TLString LocString(int with_inc_hierarchy=0) const;
00102     
00110     TLString RelString(const SCLocation &rloc) const;
00111     
00112 };
00113 
00114 
00133 struct SCLocationRange  /* C++ save */
00134 {
00135     enum _NullRange { NullRange };
00136     
00137     SCLocation loc0;   
00138     SCLocation loc1;   
00139     
00141     inline SCLocationRange(_NullRange = NullRange) : 
00142         loc0(SCLocation::NullLoc),loc1(SCLocation::NullLoc)  {}
00144     inline SCLocationRange(const SCLocation &a,const SCLocation &b) : 
00145         loc0(a),loc1(b)  {}
00147     inline SCLocationRange(const SCLocationRange &r) : 
00148         loc0(r.loc0),loc1(r.loc1)  {}
00150     inline ~SCLocationRange() {}
00151     
00153     inline SCLocationRange &operator=(const SCLocationRange &r)
00154         {  loc0=r.loc0;  loc1=r.loc1;  return(*this);  }
00156     inline SCLocationRange &operator=(_NullRange)
00157         { loc0=SCLocation::NullLoc; loc1=SCLocation::NullLoc;  return(*this); }
00158     
00160     inline bool operator!() const
00161         {  return(!loc0 && !loc1);  }
00163     inline operator bool() const
00164         {  return(loc0 || loc1);  }
00165     
00175     TLString RangeString(int with_files=1) const;
00176     
00184     TLString RelString(const SCLocationRange &rloc) const;
00185     
00187     TLString RelString(const SCLocation &rloc) const;
00188 };
00189 
00190 #endif  /* _LIB_LEX_LOCATION_H_ */

Generated on Sat Feb 19 22:33:45 2005 for Ray by doxygen 1.3.5