ProgramMetaData Class Reference

#include <ProgramMetaData.hpp>

Public Member Functions

void * operator new (size_t size, RexxBuffer *buff)
 
void operator delete (void *p, RexxBuffer *buff)
 
 ProgramMetaData ()
 
 ProgramMetaData (RexxBuffer *)
 
 ProgramMetaData (size_t size)
 
size_t getDataSize ()
 
size_t getHeaderSize ()
 
RexxBufferextractBufferData ()
 
char * getImageData ()
 
size_t getImageSize ()
 
bool validate (bool &)
 
void write (FILE *handle, RexxBuffer *program)
 
RexxBufferread (RexxString *name, FILE *handle)
 

Protected Types

enum  { MAGICNUMBER = 11111 , METAVERSION = 40 }
 

Protected Attributes

char fileTag [16]
 
unsigned short magicNumber
 
unsigned short imageVersion
 
unsigned short wordSize
 
unsigned short bigEndian
 
char rexxVersion [40]
 
size_t imageSize
 
char imageData [4]
 

Detailed Description

Definition at line 45 of file ProgramMetaData.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MAGICNUMBER 
METAVERSION 

Definition at line 65 of file ProgramMetaData.hpp.

Constructor & Destructor Documentation

◆ ProgramMetaData() [1/3]

ProgramMetaData::ProgramMetaData ( )

Initialized a default metadata descriptor.

Definition at line 119 of file ProgramMetaData.cpp.

References bigEndian, imageSize, imageVersion, magicNumber, and wordSize.

◆ ProgramMetaData() [2/3]

ProgramMetaData::ProgramMetaData ( RexxBuffer image)

◆ ProgramMetaData() [3/3]

ProgramMetaData::ProgramMetaData ( size_t  size)

Initialize program metadata for a specific size image.

Parameters
sizeThe size of the program data.

Definition at line 97 of file ProgramMetaData.cpp.

References bigEndian, compiledHeader, fileTag, RexxString::getStringData(), Interpreter::getVersionNumber(), Interpreter::getWordSize(), imageSize, imageVersion, Interpreter::isBigEndian(), MAGICNUMBER, magicNumber, METAVERSION, rexxVersion, and wordSize.

Member Function Documentation

◆ extractBufferData()

RexxBuffer * ProgramMetaData::extractBufferData ( )

Extract the following data as a RexxBuffer object.

Returns
The extracted buffer object.

Definition at line 158 of file ProgramMetaData.cpp.

References imageData, imageSize, and new_buffer().

Referenced by RoutineClass::restore().

◆ getDataSize()

size_t ProgramMetaData::getDataSize ( )

Get the final size of a copied buffer

Returns
The data image size.

Definition at line 136 of file ProgramMetaData.cpp.

References imageData, and imageSize.

Referenced by RoutineClass::save().

◆ getHeaderSize()

size_t ProgramMetaData::getHeaderSize ( )

Get the final size of a copied buffer

Returns
The data image size.

Definition at line 147 of file ProgramMetaData.cpp.

References imageData.

Referenced by read(), and write().

◆ getImageData()

char * ProgramMetaData::getImageData ( )

Return a pointer to the inline image data.

Returns
The pointer to the image data following the metadata header.

Definition at line 169 of file ProgramMetaData.cpp.

References imageData.

Referenced by RoutineClass::restore().

◆ getImageSize()

size_t ProgramMetaData::getImageSize ( )
inline

Definition at line 59 of file ProgramMetaData.hpp.

References imageSize.

Referenced by RoutineClass::restore().

◆ operator delete()

void ProgramMetaData::operator delete ( void *  p,
RexxBuffer buff 
)
inline

Definition at line 49 of file ProgramMetaData.hpp.

References SystemInterpreter::releaseResultMemory().

◆ operator new()

void * ProgramMetaData::operator new ( size_t  size,
RexxBuffer buff 
)

Allocate a combined metadata object with the flattened program data after it.

Parameters
sizeThe size of the object
buffThe appended buffer.
Returns
The storage allocated for the new instance.

Definition at line 60 of file ProgramMetaData.cpp.

References SystemInterpreter::allocateResultMemory().

◆ read()

RexxBuffer * ProgramMetaData::read ( RexxString fileName,
FILE *  handle 
)

Read the program meta data and the image data from a file, with image validation.

Parameters
handleThe input file handle.
Returns
A RexxBuffer instance containing the program data, or OREF_NULL if the file is not a valid image.

Definition at line 228 of file ProgramMetaData.cpp.

References Error_Program_unreadable_version, fileTag, RexxBuffer::getData(), getHeaderSize(), imageSize, new_buffer(), OREF_NULL, reportException(), and validate().

◆ validate()

bool ProgramMetaData::validate ( bool &  badVersion)

Validate that this saved program image is valid for this interpreter.

Parameters
badVersionIndicates whether this is a version failure.
Returns
true if this is good data, false otherwise.

Definition at line 184 of file ProgramMetaData.cpp.

References bigEndian, compiledHeader, fileTag, Interpreter::getWordSize(), imageVersion, Interpreter::isBigEndian(), MAGICNUMBER, magicNumber, METAVERSION, and wordSize.

Referenced by read(), and RoutineClass::restore().

◆ write()

void ProgramMetaData::write ( FILE *  handle,
RexxBuffer program 
)

Write the metadata to a file.

Parameters
handleThe handle of the output file.
programThe program buffer data (also written out).

Definition at line 211 of file ProgramMetaData.cpp.

References RexxBuffer::getData(), RexxBufferBase::getDataLength(), and getHeaderSize().

Referenced by RoutineClass::save().

Member Data Documentation

◆ bigEndian

unsigned short ProgramMetaData::bigEndian
protected

Definition at line 76 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData(), and validate().

◆ fileTag

char ProgramMetaData::fileTag[16]
protected

Definition at line 72 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData(), read(), and validate().

◆ imageData

char ProgramMetaData::imageData[4]
protected

◆ imageSize

size_t ProgramMetaData::imageSize
protected

◆ imageVersion

unsigned short ProgramMetaData::imageVersion
protected

Definition at line 74 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData(), and validate().

◆ magicNumber

unsigned short ProgramMetaData::magicNumber
protected

Definition at line 73 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData(), and validate().

◆ rexxVersion

char ProgramMetaData::rexxVersion[40]
protected

Definition at line 77 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData().

◆ wordSize

unsigned short ProgramMetaData::wordSize
protected

Definition at line 75 of file ProgramMetaData.hpp.

Referenced by ProgramMetaData(), and validate().


The documentation for this class was generated from the following files: