FileDocCategorySizeDatePackage
Preproc.javaAPI DocExample5066Sat Nov 25 11:54:30 GMT 2000None

PrimitivePreprocessor

public class PrimitivePreprocessor extends Object
Purpose: Scan source file and substitute all instances of #include with function names

Fields Summary
private FileInputStream
fis
private DataInputStream
dis
private FileOutputStream
writeOut
private DataOutputStream
dataWrite
private boolean
m_bDebug
private MembersArray
m_MembersVector
Constructors Summary
public PrimitivePreprocessor(String strInFile, String strOutFile, MembersArray vect)
Purpose: Constructor

param
strInFile - source file
param
strOutFile - output files
param
vec - vector of MemberBodies
exception
IOException

    
	                    	 
	      
            m_MembersVector = vect;
            
			try{

                fis = new FileInputStream(strInFile);
				writeOut = new FileOutputStream(strOutFile);

            }catch(FileNotFoundException eFnf){
		        System.out.println("Unable to open " + strInFile);
		        System.exit(1);
            }

			catch(Throwable e) {
				System.out.println("Error in opening file");
				return;
			}



              dis = new DataInputStream(fis);

    		  
		      dataWrite = new DataOutputStream(writeOut);
		
			  
		  	
	
Methods Summary
public voidProcessFile()
Purpose: preprocesses the file

          int iBadData = 0;
          String strLine;
          String strTry;

		  try{
          
			  while((strLine = dis.readLine())!=null){
			  	  //System.out.println(strLine);
				  strTry = new String(strLine);
				  if(strLine.trim().startsWith("#include")){
					  ProcessInclude(strLine);
				  	  dataWrite.writeByte('\n");
				  }
				  else{
					  dataWrite.writeBytes(strLine);
				  	  dataWrite.writeByte('\n");
				  }
		      
				}
		  
		  
		  }catch(Exception e){
             System.out.println("Error occurred reading file");
             System.exit(1);
          }
          

		  try{
			  dis.close();
			  fis.close();
				  
			  dataWrite.close();
			  writeOut.close();
		  
		  }catch(IOException e){System.out.println(e);}	  	     
	
private voidProcessInclude(java.lang.String strLine)

		   
		  if(strLine.compareTo("") == 0) return;
		  String strMemName, strInclude;
		  
		  StringTokenizer strTok = new StringTokenizer(strLine);

		   if(strTok != null && strTok.countTokens() == 2){
					strInclude = new String(strTok.nextToken()); //who cares
					strMemName = new String(strTok.nextToken());
					if(!m_MembersVector.FindAndWriteOut(dataWrite, strMemName))
						if(m_bDebug)System.out.println(strMemName + " not found!");
 		   }
		   else
					System.out.println("Bad Line" + strTok);