00001 /******************************************************************************* 00002 * Copyright (c) 2006 International Business Machines Corporation 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Common Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.opensource.org/licenses/cpl1.0.php 00007 * 00008 * Contributors: 00009 * Douglas Sprague, Joel Wheeler - initial API and implementation 00010 * 00011 *****************************************************************************/ 00012 00013 #ifndef STILINCLUDEFILE_H 00014 #define STILINCLUDEFILE_H 00015 00016 #include "stilcom.h" // Common library 00017 #include "stilcomstr.h" 00018 00019 00020 extern void stiltok_set_file(FILE *); 00021 00022 #ifdef __GNUC__ 00023 // For linux FLEX file buffering: 00024 extern struct stil_yy_buffer_state* stiltok_get_current_file_buffer(); 00025 extern void stiltok_parse_new_file (); 00026 #endif 00027 00028 // STILIncludeFile Class 00029 //--------------------------------------------------------------------------- 00036 //--------------------------------------------------------------------------- 00037 class STILIncludeFile { 00038 00039 // - Public members 00040 public: 00041 00042 // - Default Constructor 00043 STILIncludeFile(); 00044 00045 // - Copy Constructor 00046 STILIncludeFile(const STILIncludeFile &); 00047 00048 // - Destructor 00049 ~STILIncludeFile(); 00050 00051 // - Assignment operator 00052 STILIncludeFile & operator=(const STILIncludeFile &); 00053 00054 // - Equality operator 00055 bool operator==(const STILIncludeFile &) const; 00056 00057 // - Less Than Operator 00058 bool operator<(const STILIncludeFile &) const; 00059 00060 // - Get/Set the current file 00061 void setFile(const sstring& fn); 00062 00063 // - Get the current pointer to FILE 00064 FILE * getFilePtr(); 00065 00066 #ifdef __GNUC__ 00067 struct stil_yy_buffer_state * getFileBuffPtr() { return m_pPrevFileBuff; } 00068 #endif 00069 00070 // - Get the current file name 00071 const sstring & getFileName(); 00072 00073 // - Get/Set the current line number 00074 void setLastLineNumber(const unsigned int); 00075 const unsigned int getLastLineNumber(); 00076 00077 // - Get/Set the base path 00078 void setBasePath (sstring &); 00079 const sstring & getBasePath (); 00080 00081 // Private members 00082 private: 00083 00084 unsigned int m_lineNumber; // line # last read from in file 00085 sstring m_basepath; // basepath of filename 00086 sstring m_filename; // name of file 00087 FILE * m_pFile; // ptr to file 00088 #ifdef __GNUC__ 00089 struct stil_yy_buffer_state* m_pPrevFileBuff; // Buffer ptr for Linux FLEX file buffering, pt's to prev file buffer 00090 #endif 00091 00092 }; // end STILIncludeFile class 00093 00094 // Inline functions 00095 //-------------------------------------------------------------------------- 00103 //-------------------------------------------------------------------------- 00104 inline const sstring& STILIncludeFile::getFileName() { return m_filename; } 00105 00106 //-------------------------------------------------------------------------- 00114 //-------------------------------------------------------------------------- 00115 inline FILE * STILIncludeFile::getFilePtr() { return m_pFile; } 00116 00117 //-------------------------------------------------------------------------- 00125 //-------------------------------------------------------------------------- 00126 inline const unsigned int STILIncludeFile::getLastLineNumber() { return m_lineNumber; } 00127 00128 //-------------------------------------------------------------------------- 00136 //-------------------------------------------------------------------------- 00137 inline void STILIncludeFile::setLastLineNumber(const unsigned int ln) { m_lineNumber = ln; } 00138 00139 //-------------------------------------------------------------------------- 00147 //-------------------------------------------------------------------------- 00148 inline void STILIncludeFile::setBasePath(sstring & bp) { m_basepath = bp; } 00149 00150 //-------------------------------------------------------------------------- 00158 //-------------------------------------------------------------------------- 00159 inline const sstring & STILIncludeFile::getBasePath() { return m_basepath; } 00160 00161 #endif