44   Blob::Blob(
const QString &name, 
const QString &type) {
 
   51     p_blobPvl.setName(p_type);
 
   65   Blob::Blob(
const QString &name, 
const QString &type, 
 
   66              const QString &file) {
 
   71     p_labelFile = 
FileName(file).expanded();
 
   81   Blob::Blob(
const Blob &other) {
 
   93       p_buffer = 
new char[p_nbytes];
 
   95       for (
int i = 0; i < p_nbytes; i++) {
 
  120       p_buffer = 
new char[p_nbytes];
 
  122       for (
int i = 0; i < p_nbytes; i++) {
 
  132     if (p_buffer != NULL) 
delete [] p_buffer;
 
  140   QString Blob::Type()
 const {
 
  149   QString Blob::Name()
 const {
 
  158   int Blob::Size()
 const {
 
  179   void Blob::Find(
const Pvl &pvl) {
 
  183       QString blobName = p_blobName.toUpper();
 
  184       for (
int o = 0; o < pvl.
objects(); o++) {
 
  187           QString curName = obj[
"Name"];
 
  188           curName = curName.toUpper();
 
  189           if (blobName == curName) {
 
  195             if (p_type == 
"OriginalLabel" && curName == 
"ORIGINALLABEL") {
 
  205       QString msg = 
"Invalid " + p_type + 
" label format";
 
  211       QString msg = 
"Unable to find " + p_type + 
" [" + p_blobName + 
"]";
 
  217       p_startByte = p_blobPvl[
"StartByte"];
 
  218       p_nbytes = p_blobPvl[
"Bytes"];
 
  220       if (p_blobPvl.hasKeyword(
"^" + p_type)) {
 
  222         if (p_labelFile != 
"") {
 
  225         p_detached = path + (QString) p_blobPvl[
"^"+p_type];
 
  226         p_blobPvl.deleteKeyword(
"^" + p_type);
 
  230       QString msg = 
"Invalid " + p_type + 
" label format";
 
  243   void Blob::Read(
const QString &file) {
 
  245     QString temp(
FileName(file).expanded());
 
  253       QString msg = 
"Invalid " + p_type + 
" label format";
 
  268   void Blob::Read(
const QString &file, 
const Pvl &pvlLabels) {
 
  271     QString temp(
FileName(file).expanded());
 
  275     istm.open(temp.toLatin1().data(), std::ios::in);
 
  283       Read(pvlLabels, istm);
 
  287       QString msg = 
"Unable to open " + p_type + 
" [" + p_blobName +
 
  288                    "] in file [" + temp + 
"]";
 
  303   void Blob::Read(
const Pvl &pvl, std::istream &istm) {
 
  307       if (p_detached != 
"") {
 
  309         dstm.open(p_detached.toLatin1().data(), std::ios::in);
 
  321       QString msg = 
"Unable to read " + p_type + 
" [" + p_blobName + 
"]";
 
  330   void Blob::ReadInit(){
 
  340   void Blob::ReadData(std::istream &stream) {
 
  342     if (p_buffer != NULL) 
delete [] p_buffer;
 
  343     p_buffer = 
new char[p_nbytes];
 
  345     streampos sbyte = p_startByte - 1;
 
  346     stream.seekg(sbyte, std::ios::beg);
 
  347     if (!stream.good()) {
 
  348       QString msg = 
"Error preparing to read data from " + p_type +
 
  349                    " [" + p_blobName + 
"]";
 
  353     stream.read(p_buffer, p_nbytes);
 
  354     if (!stream.good()) {
 
  355       QString msg = 
"Error reading data from " + p_type + 
" [" + p_blobName + 
"]";
 
  369   void Blob::Write(
const QString &file) {
 
  377       os.seekp(0, std::ios::end);
 
  378       BigInt nbytes = (BigInt) os.tellp() + (BigInt) 64;
 
  379       p_startByte = nbytes + 1 + 1; 
 
  386       ios::openmode flags = std::ios::in | std::ios::binary | std::ios::out;
 
  387       stream.open(file.toLatin1().data(), flags);
 
  389         QString message = 
"Unable to open [" + file + 
"]";
 
  393       streampos sbyte = p_startByte - 1;
 
  394       stream.seekp(sbyte, std::ios::beg);
 
  395       if (!stream.good()) {
 
  397         QString msg = 
"Error preparing to write data to " +
 
  398                      p_type + 
" [" + p_blobName + 
"]";
 
  406       QString msg = 
"Unable to create " + p_type + 
" file [" + file + 
"]";
 
  418   void Blob::Write(
Pvl &pvl, std::fstream &stm,
 
  419                    const QString &detachedFileName) {
 
  424     streampos sbyte = stm.tellp();
 
  428     stm.seekp(0, std::ios::end);
 
  429     streampos eofbyte = stm.tellp();
 
  433     if (detachedFileName != 
"") {
 
  434       p_blobPvl += 
PvlKeyword(
"^" + p_type, detachedFileName);
 
  438     p_blobPvl[
"StartByte"] = 
toString((BigInt)sbyte);
 
  439     p_blobPvl[
"Bytes"] = 
toString(p_nbytes);
 
  442     for (
int i = 0; i < pvl.
objects(); i++) {
 
  443       if (pvl.
object(i).
name() == p_blobPvl.name()) {
 
  445         if ((QString)obj[
"Name"] == (QString)p_blobPvl[
"Name"]) {
 
  448           BigInt oldSbyte = obj[
"StartByte"];
 
  449           int oldNbytes = (int) obj[
"Bytes"];
 
  452           if (p_nbytes <= oldNbytes) {
 
  453             p_blobPvl[
"StartByte"] = obj[
"StartByte"];
 
  458           else if (((oldSbyte + oldNbytes) == eofbyte) &&
 
  459                   (eofbyte >= sbyte)) {
 
  460             p_blobPvl[
"StartByte"] = obj[
"StartByte"];
 
  479     stm.seekp((BigInt) sbyte - (BigInt)1);
 
  483     if (detachedFileName != 
"") {
 
  484       p_blobPvl.deleteKeyword(
"^" + p_type);
 
  492   void Blob::WriteInit(){
 
  502   void Blob::WriteData(std::fstream &stream) {
 
  503     stream.write(p_buffer, p_nbytes);
 
  504     if (!stream.good()) {
 
  505       QString msg = 
"Error writing data to " + p_type + 
" [" + p_blobName + 
"]";
 
  519     if (obj.
isNamed(
"TABLE")) 
return true;
 
PvlObject & object(const int index)
Return the object at the specified index. 
 
QString p_type
Type of data stored in the buffer. 
 
QString p_detached
Used for reading detached blobs. 
 
File name manipulation and expansion. 
 
QString p_blobName
Name of the Blob object. 
 
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes. 
 
bool IsBlob(PvlObject &obj)
Checks pvl object and returns whether or not it is a Blob. 
 
int p_nbytes
Size of blob data (in bytes) 
 
QString p_labelFile
The file containing the labels. 
 
PvlObject p_blobPvl
Pvl Blob object. 
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string. 
 
char * p_buffer
Buffer blob data is stored in. 
 
void addObject(const PvlObject &object)
Add a PvlObject. 
 
#define _FILEINFO_
Macro for the filename and line number. 
 
int objects() const 
Returns the number of objects. 
 
A single keyword-value pair. 
 
Container for cube-like labels. 
 
QString FileOpen(const QString &filename)
This error should be used when a file could not be opened. 
 
bool isNamed(const QString &match) const 
Returns whether the given string is equal to the container name or not. 
 
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence. 
 
Contains Pvl Groups and Pvl Objects. 
 
BigInt p_startByte
Byte blob data starts at in buffer. 
 
void read(const QString &file)
Loads PVL information from a stream. 
 
QString path() const 
Returns the path. 
 
QString name() const 
Returns the container name.