Isis 3 Programmer Reference
History.cpp
Go to the documentation of this file.
1 
23 #include "History.h"
24 
25 #include <fstream>
26 #include <sstream>
27 #include <string>
28 
29 #include "Application.h"
30 #include "PvlObject.h"
31 
32 using namespace std;
33 
34 namespace Isis {
35 
40  History::History(const QString &name) : Isis::Blob(name, "History") {
42  }
43 
49  History::History(const QString &name, const QString &file) :
50  Isis::Blob(name, "History") {
51  Blob::Read(file);
52  }
53 
56  }
57 
62  PvlObject hist = Isis::iApp->History();
63  AddEntry(hist);
64  }
65 
72  p_history.addObject(obj);
73  }
74 
79  ostringstream ostr;
80  if (p_nbytes > 0) ostr << std::endl;
81  ostr << p_history;
82  string histStr = ostr.str();
83  int bytes = histStr.size();
84 
85  char *temp = p_buffer;
86  p_buffer = new char[p_nbytes+bytes];
87  if (temp != NULL) memcpy(p_buffer, temp, p_nbytes);
88  const char *ptr = histStr.c_str();
89  memcpy(&p_buffer[p_nbytes], (void *)ptr, bytes);
90  p_nbytes += bytes;
91 
92  if (temp != NULL) delete [] temp;
93  }
94 
101  Pvl pvl;
102  stringstream os;
103  for (int i = 0; i < p_nbytes; i++) os << p_buffer[i];
104  os >> pvl;
105  return pvl;
106  }
107 
114  void History::Read(const Isis::Pvl &pvl, std::istream &is) {
115  try {
116  Blob::Read(pvl, is);
117  }
118  catch (IException &e) {
119  }
120  }
121 }
void Read(const QString &file)
This method reads Pvl values from a specified file.
Definition: Blob.cpp:243
void WriteInit()
This virtual method for classes that inherit Blob.
Definition: History.cpp:78
Namespace for the standard library.
int p_nbytes
Size of blob data (in bytes)
Definition: Blob.h:99
Pvl ReturnHist()
Reads p_buffer into a pvl.
Definition: History.cpp:100
~History()
Destructor.
Definition: History.cpp:55
char * p_buffer
Buffer blob data is stored in.
Definition: Blob.h:97
Pvl p_history
History Pvl.
Definition: History.h:66
void addObject(const PvlObject &object)
Add a PvlObject.
Definition: PvlObject.h:319
void setTerminator(const QString &term)
Sets the terminator used to signify the end of the PVL informationDefaults to "END".
Definition: Pvl.h:159
void Read(const Isis::Pvl &pvl, std::istream &is)
Reads input stream into Pvl.
Definition: History.cpp:114
History(const QString &name)
Constructor for reading a history blob.
Definition: History.cpp:40
Container for cube-like labels.
Definition: Pvl.h:135
PvlObject History()
Creates an application history PvlObject.
void AddEntry()
Adds History PvlObject.
Definition: History.cpp:61
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74