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

/ray/src/lib/sourcepos/sourcepos.h

Go to the documentation of this file.
00001 /*
00002  * lib/sourcepos/sourcepos.h
00003  * 
00004  * Classes for sophisticated source position (file/line/lpos, 
00005  * include hierarchy) handling. 
00006  * 
00007  * Copyright (c) 2003--2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00008  * 
00009  * This file may be distributed and/or modified under the terms of the 
00010  * GNU General Public License version 2 as published by the Free Software 
00011  * Foundation. (See COPYING.GPL for details.)
00012  * 
00013  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00014  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00015  * 
00016  */
00017 
00018 #ifndef _LIB_SOURCEPOS_SOURCEPOS_H_
00019 #define _LIB_SOURCEPOS_SOURCEPOS_H_ 1
00020 
00065 #include <lib/sconfig.h>    /* MUST be first */
00066 
00067 #include <lib/tl/refnode.h>
00068 #include <lib/sourcepos/sourcefile.h>
00069 
00070 
00071 // As defined further down: 
00072 class _InternalSourcePosition;
00073 
00075 typedef RefNode<_InternalSourcePosition> SourcePosition;
00076 
00077 
00092 class _InternalSourcePosition : InternalRefNodeBase_ThreadSave
00093 {
00094     friend class SourcePositionArchive;
00095     friend class RefNode<_InternalSourcePosition>;
00096     friend bool operator==(const SourcePosition &a,const SourcePosition &b);
00097     public:
00101         static SourcePosition CreateSinglePosition(const SourceFileNode &sfn,
00102             int line,int lpos);
00103     private:
00104         SourceFileNode _file;   
00105         int _line;              
00106         int _lpos;              
00107         
00109         bool test_equal(const _InternalSourcePosition &b) const;
00110         
00112         _InternalSourcePosition(const _InternalSourcePosition &);
00113         void operator=(const _InternalSourcePosition &);
00114         
00116         _InternalSourcePosition(const SourceFileNode &fnode,int line,int lpos);
00117     public:
00119         ~_InternalSourcePosition();
00120         
00122         inline SourceFileNode file() const
00123             {  return(this ? _file : SourceFileNode());  }
00124         
00126         inline int line() const  {  return(this ? _line : (-1));  }
00128         inline int lpos() const  {  return(this ? _lpos : (-1));  }
00130         inline TLString path() const
00131             {  return(this ? _file->path() : TLString());  }
00132         
00134         inline void SetLine(int l)  {  if(this)  _line=l;  }
00136         inline void SetLPos(int l)  {  if(this)  _lpos=l;  }
00137         
00145         TLString PosString(bool with_file=1) const;
00146         
00153         TLString PosRangeString(const SourcePosition &end,
00154             bool with_file=1) const;
00155         
00161         TLString PosStringRelative(const SourcePosition &rpos) const;
00162         
00170         TLString IncludeHierarchyStr() const;
00171 };
00172 
00173 
00178 inline bool operator==(const SourcePosition &a,const SourcePosition &b)
00179     {  return((a && b) ? a->test_equal(*b) : (!a && !b));  }
00180 
00185 inline bool operator!=(const SourcePosition &a,const SourcePosition &b)
00186     {  return(!operator==(a,b));  }
00187 
00188 #endif  /* _LIB_SOURCEPOS_SOURCEPOS_H_ */

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