USGS

Isis 3.0 Application Source Code Reference

Home

cathist.cpp

Go to the documentation of this file.
00001 #include "Isis.h"
00002 
00003 #include <sstream>
00004 
00005 #include "Pvl.h"
00006 #include "History.h"
00007 #include "iString.h"
00008 
00009 using namespace Isis;
00010 using namespace std;
00011 
00012 void IsisMain(){
00013 
00014   // Get user entered file name & mode 
00015   UserInterface &ui = Application::GetUserInterface();
00016   string file = ui.GetFilename("FROM");
00017   string mode = ui.GetString("MODE");
00018 
00019   // Extract history from file
00020   History hist("IsisCube", file);
00021   Pvl pvl = hist.ReturnHist();
00022 
00023   // Print full history
00024   if(mode=="FULL"){
00025     if (ui.IsInteractive()) {
00026       Application::GuiLog(pvl);    
00027     }
00028     else {
00029       cout << pvl << endl;
00030     }
00031   }
00032 
00033   // Print brief history in command line form
00034   else if(mode=="BRIEF"){  
00035     for(int i=0; i<pvl.Objects(); ++i){
00036       string all = pvl.Object(i).Name() + " ";
00037       PvlGroup user = pvl.Object(i).FindGroup("UserParameters");
00038       for(int j=0; j<user.Keywords(); ++j){
00039         ostringstream os;
00040         os << user[j];
00041         string temp = os.str();
00042         int index = temp.find("=");
00043         iString temp1(temp.substr(0,index-1));
00044         string temp2 = temp.substr(index+2);
00045         all += temp1.DownCase()+ "=" + temp2 + " "; 
00046       } 
00047       if (ui.IsInteractive()) {
00048         Application::GuiLog(all);
00049       }
00050       else {
00051         cout << all << endl;
00052       }
00053     }   
00054   }
00055 }