00001 /* 00002 * lib/sourcepos/sparchive.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_SOURCEPOSARCHIVE_H_ 00019 #define _LIB_SOURCEPOS_SOURCEPOSARCHIVE_H_ 1 00020 00030 #include <lib/sconfig.h> /* MUST be first */ 00031 00032 #include <lib/sourcepos/sourcepos.h> 00033 00034 00052 class SourcePositionArchive 00053 { 00054 private: 00056 SourceFileNode head; 00058 SourceFileNode current; 00059 00062 int tot_file_nodes; 00064 int max_file_nodes; 00066 int curr_file_nodes; 00067 00069 size_t tot_src_pos; 00070 size_t max_src_pos; 00071 size_t curr_src_pos; 00072 00074 void _RecursiveDetachArchive(_InternalSourceFileNode *head); 00075 00077 SourcePositionArchive(const SourcePositionArchive &); 00078 void operator=(const SourcePositionArchive &); 00079 public: 00080 // Pass the primary input file as argument. failflag unused. 00081 SourcePositionArchive(const TLString &path); 00082 ~SourcePositionArchive(); 00083 00096 SourcePosition GetPos(int line,int lpos=-1); 00097 00111 SourceFileNode IncludeFile(const TLString &path, 00112 int line,int lpos, 00113 filepos_t include_stmt_pos=-1,size_t include_stmt_len=0); 00120 SourceFileNode EndFile(); 00121 00123 SourceFileNode CurrentFile() const 00124 { return(current); } 00125 00128 _InternalSourceFileNode *AllocISF(const TLString &path, 00129 SourceFileNode &parent); 00130 void DestroyingISF(_InternalSourceFileNode *); // READ FUNCTION!!! 00133 _InternalSourcePosition *AllocISPNoCache( 00134 const SourceFileNode &fnode,int line,int lpos); 00135 void DestroyingISP(_InternalSourcePosition *isp); 00136 00137 }; 00138 00139 #endif /* _LIB_SOURCEPOS_SOURCEPOSARCHIVE_H_ */