Isis 3 Programmer Reference
History.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "History.h"
8
9#include <fstream>
10#include <sstream>
11#include <string>
12
13#include "Application.h"
14#include "PvlObject.h"
15
16using namespace std;
17
18namespace Isis {
25
26
33
34 char *blob_buffer = blob.getBuffer();
35 p_bufferSize = blob.Size();
36 p_histBuffer = new char[p_bufferSize];
37
38 if (blob_buffer != NULL) {
39 // Copy existing history
40 memcpy(p_histBuffer, blob_buffer, p_bufferSize);
41 }
42 }
43
44
47 if (p_histBuffer != NULL) {
48 delete [] p_histBuffer;
49 }
50 }
51
52
57 PvlObject hist = Isis::iApp->History();
58 AddEntry(hist);
59 }
60
61
70
71
79 Blob History::toBlob(const QString &name) {
80 ostringstream ostr;
81 if (p_bufferSize > 0) ostr << std::endl;
82 ostr << p_history;
83 string histStr = ostr.str();
84 int bytes = histStr.size();
85
86 int blobBufferSize = p_bufferSize+bytes;
87 char *blobBuffer = new char[blobBufferSize];
88 if (p_histBuffer != NULL) memcpy(blobBuffer, p_histBuffer, p_bufferSize);
89 const char *ptr = histStr.c_str();
90 memcpy(&blobBuffer[p_bufferSize], (void *)ptr, bytes);
91
92 Blob newBlob(name, "History");
93 newBlob.takeData(blobBuffer, blobBufferSize);
94 return newBlob;
95 }
96
97
104 Pvl pvl;
105 stringstream os;
106 for (int i = 0; i < p_bufferSize; i++) os << p_histBuffer[i];
107
108 for (int i = 0; i < p_history.objects(); i++) {
109 os << std::endl << p_history.object(i);
110 }
111 os >> pvl;
112 return pvl;
113 }
114}
PvlObject History()
Creates an application history PvlObject.
Pvl p_history
History Pvl.
Definition History.h:51
Blob toBlob(const QString &name="IsisCube")
Converts a history object into a new blob object.
Definition History.cpp:79
char * p_histBuffer
Store for read in history data.
Definition History.h:52
History()
Default Constructor for history.
Definition History.cpp:22
Pvl ReturnHist()
Reads p_histBuffer into a pvl.
Definition History.cpp:103
void AddEntry()
Adds History PvlObject.
Definition History.cpp:56
~History()
Destructor.
Definition History.cpp:46
Container for cube-like labels.
Definition Pvl.h:119
void setTerminator(const QString &term)
Sets the terminator used to signify the end of the PVL informationDefaults to "END".
Definition Pvl.h:144
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
int objects() const
Returns the number of objects.
Definition PvlObject.h:221
PvlObject & object(const int index)
Return the object at the specified index.
void addObject(const PvlObject &object)
Add a PvlObject.
Definition PvlObject.h:309
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.