Purpose:
|
Defines the
BinaryFile class for doing
ACIS save and restore to binary files.
|
|
Derivation:
|
BinaryFile : FileInterface : ACIS_OBJECT : -
|
|
Filename:
|
kern/kernel/kernutil/fileio/binfile.hxx
|
|
Description:
|
This is an abstract base class. It implements most of the virtual methods which are used by all of the binary file formats.
|
|
|
If there is a need to save and restore
ACISENTITY data in binary form to a target other than a
FILE*, then it is advisable to derive a new class from this one rather than directly from
FileInterface.
|
|
Data:
|
protected int read_long_size;
|
|
Size of the long.
|
|
|
protected int write_long_size;
|
|
Output size.
|
|
|
protected logical big_end;
|
|
Big/little-endian flag.
|
|
|
protected logical need_swap;
|
|
Is byte swapping needed.
|
|
Constructor:
|
public: BinaryFile::BinaryFile
();
|
|
|
C++ allocation constructor requests memory for this object but does not populate it.
|
|
|
|
|
Destructor:
|
public: virtual BinaryFile::~BinaryFile
();
|
|
|
C++ destructor for
BinaryFile which deallocates memory.
|
|
|
|
Methods:
|
protected: virtual TaggedData::DataType
|
|
|
BinaryFile::read_data_type ();
|
|
|
Read a data type. The return type is
TaggedData::DataType. The
read_data_type method is a virtual method of BinaryFile.
|
|
|
|
|
|
|
protected: virtual TaggedData::DataType
|
|
|
BinaryFile::read_type ();
|
|
|
Reads the data type.
|
|
|
|
|
|
|
protected: virtual TaggedData::DataType
|
|
|
BinaryFile::test_type (
|
|
|
TaggedData::DataType
|
// data type
|
|
|
|
type_wanted,
|
// type wanted
|
|
|
int error_num
|
// error number
|
|
|
|
= 0
|
//
|
|
|
);
|
|
|
Reads the next data type tag, and checks to see if it is the required type. If it is not the required type, it signals an error.
|
|
|
|
|
|
|
public: virtual FilePosition BinaryFile::goto_mark
(
|
|
|
FilePosition
|
// new file position
|
|
|
) = 0;
|
|
|
This method repositions the file pointer and must be implemented for each class derived from
BinaryFile. In a normal save that does not require writing the
ENTITY count to the
ACIS header, this is only used to reposition the file pointer if there is an error reading the header.
|
|
|
|
|
|
|
protected: virtual size_t BinaryFile::read
(
|
|
|
void* buffer,
|
// buffer name
|
|
|
size_t length,
|
// length
|
|
|
logical swap
|
// support byte swapping?
|
|
|
) = 0;
|
|
|
This method reads the data and must be implemented for all derived classes.
|
|
|
|
|
|
|
protected: logical BinaryFile::read_an_int
(
|
|
|
int long_size,
|
|
// long size
|
|
|
int& retval
|
|
// return value
|
|
);
|
|
|
Read the integer.
|
|
|
|
|
|
|
protected: virtual size_t BinaryFile::read_and_test
(
|
|
|
void* data,
|
// data
|
|
|
size_t num_bytes,
|
// number of bytes
|
|
|
logical swap
|
// support byte swapping?
|
|
|
);
|
|
|
Read in a given number of bytes of data and signal a
sys_error if not enough data was read.
|
|
|
|
|
|
|
public: virtual char BinaryFile::read_char
();
|
|
|
Read a character.
|
|
|
|
|
|
|
public: virtual TaggedData* BinaryFile::read_data
();
|
|
|
Read the data type and the subsequent datum of that type.
|
|
|
|
|
|
|
public: virtual double BinaryFile::read_double
();
|
|
|
Read a double.
|
|
|
|
|
|
|
public: virtual int BinaryFile::read_enum
(
|
|
|
enum_table const&
|
// table
|
|
|
);
|
|
|
Reads in the enumeration table.
|
|
|
|
|
|
|
public: virtual float BinaryFile::read_float
();
|
|
|
Reads a float.
|
|
|
|
|
|
|
public: virtual logical BinaryFile::read_header
(
|
|
|
int&,
|
// first integer
|
|
|
int&,
|
// second integer
|
|
|
int&,
|
// third integer
|
|
|
int&
|
// fourth integer
|
|
|
);
|
|
|
Reads a header string.
|
|
|
|
|
|
|
public: virtual int BinaryFile::read_id
(
|
|
|
char*,
|
// buffer to read from
|
|
|
int
|
|
// buffer size or -1 for
|
|
|
|
|
// no limit
|
|
|
|
= 0
|
|
|
);
|
|
|
Reads an identifier.
|
|
|
|
|
|
|
public: virtual logical BinaryFile::read_logical
(
|
|
|
const char* f
|
// character string that
|
|
|
|
= "F",
|
// requests FALSE
|
|
|
const char* t
|
// character string that
|
|
|
|
= "T"
|
// requests TRUE
|
|
|
);
|
|
|
Reads the logical.
|
|
|
|
|
|
|
public: virtual long BinaryFile::read_long
();
|
|
|
Reads the long.
|
|
|
|
|
|
|
public: virtual void* BinaryFile::read_pointer
();
|
|
|
Reads the pointer.
|
|
|
|
|
|
|
public: virtual SPAposition
|
|
|
BinaryFile::read_position ();
|
|
|
Reads the position.
|
|
|
|
|
|
|
public: virtual short BinaryFile::read_short
();
|
|
|
Reads the short.
|
|
|
|
|
|
|
public: virtual char* BinaryFile::read_string
(
|
|
|
int&
|
// length
|
|
|
);
|
|
|
Reads the string.
|
|
|
|
|
|
|
public: virtual size_t BinaryFile::read_string
(
|
|
|
char*,
|
// title
|
|
|
size_t maxlen
|
// maximum length
|
|
|
|
= 0
|
|
|
);
|
|
|
Reads the string.
|
|
|
|
|
|
|
public: virtual
|
|
|
size_t BinaryFile::read_string_length (
|
|
|
TaggedData::DataType
|
// data type
|
|
|
);
|
|
|
Reads the string length.
|
|
|
|
|
|
|
public: virtual logical
|
|
|
BinaryFile::read_subtype_end ();
|
|
|
Reads the subtype end.
|
|
|
|
|
|
|
public: virtual logical
|
|
|
BinaryFile::read_subtype_start ();
|
|
|
Reads subtype start.
|
|
|
|
|
|
|
protected: virtual TaggedData::DataType
|
|
|
BinaryFile::read_type ();
|
|
|
Reads the data type.
|
|
|
|
|
|
|
public: virtual SPAvector BinaryFile::read_vector
();
|
|
|
Reads the vector.
|
|
|
|
|
|
|
protected: virtual long
|
|
|
BinaryFile::safe_read_long ();
|
|
|
The long value.
|
|
|
|
|
|
|
protected: virtual void
|
|
|
BinaryFile::safe_write_long (
|
|
|
long
|
|
// long
|
|
|
);
|
|
|
Used to convert between 32 and 64 bit formats.
|
|
|
|
|
|
|
protected: virtual void BinaryFile::safe_write_long_tagged
(
|
|
|
TaggedData::DataType,
|
|
// data type
|
|
|
long
|
|
// long
|
|
|
);
|
|
|
Used to convert between 32 and 64 bit formats.
|
|
|
|
|
|
|
public: virtual FilePosition
|
|
|
BinaryFile::set_mark () = 0;
|
|
|
This method repositions the file pointer and must be implemented for each class derived from
BinaryFile. In a normal save that does not require writing the
ENTITY count to the
ACIS header, this is only used to reposition the file pointer if there is an error reading the header.
|
|
|
|
|
|
|
protected: virtual void BinaryFile::write
(
|
|
|
const void* data,
|
// data
|
|
|
size_t len,
|
// length
|
|
|
logical swap
|
// support byte swapping?
|
|
|
) = 0;
|
|
|
This method writes the data and must be implemented for all derived classes.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_char
(
|
|
|
char
|
// character to write
|
|
|
);
|
|
|
Writes the character.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_double
(
|
|
|
double
|
// double to be written
|
|
|
);
|
|
|
Writes the double.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_enum
(
|
|
|
int,
|
// value to be written
|
|
|
enum_table const&
|
// enumeration table
|
|
|
);
|
|
|
Writes value to enumeration table.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_float
(
|
|
|
float
|
// float to be written
|
|
|
);
|
|
|
Writes the float.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_header
(
|
|
|
int,
|
// first integer
|
|
|
int,
|
// second integer
|
|
|
int,
|
// third integer
|
|
|
int
|
|
// fourth integer
|
|
|
);
|
|
|
Writes the header.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_id
(
|
|
|
const char*,
|
// entity identifier
|
|
|
int
|
|
// integer
|
|
|
);
|
|
|
Writes an entity identifier.
|
|
|
|
|
|
|
public: virtual void
|
|
|
BinaryFile::write_literal_string (
|
|
|
const char*,
|
// string to be written
|
|
|
size_t len
|
// length
|
|
|
|
= 0
|
|
|
);
|
|
|
Writes the literal string.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_logical
(
|
|
|
logical,
|
// logical to be written
|
|
|
const char* f
|
// represents FALSE
|
|
|
|
= "F",
|
|
|
const char* t
|
// represents TRUE
|
|
|
|
= "T"
|
|
|
);
|
|
|
Writes a logical.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_long
(
|
|
|
long
|
// long to be written
|
|
|
);
|
|
|
Writes a long.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_pointer
(
|
|
|
void*
|
// pointer to be written
|
|
|
);
|
|
|
Writes a pointer.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_position
(
|
|
|
const SPAposition&
|
// position to be written
|
|
|
);
|
|
|
Writes a position.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_short
(
|
|
|
short
|
// short to be written
|
|
|
);
|
|
|
Writes a short.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_string
(
|
|
|
const char*,
|
// string to be written
|
|
|
size_t len
|
// length
|
|
|
|
= 0
|
|
|
);
|
|
|
Writes a string.
|
|
|
|
|
|
|
public: virtual void
|
|
|
BinaryFile::write_subtype_end ();
|
|
|
Writes a subtype end.
|
|
|
|
|
|
|
public: virtual void
|
|
|
BinaryFile::write_subtype_start ();
|
|
|
Writes a subtype start.
|
|
|
|
|
|
|
protected: virtual void BinaryFile::write_tagged
(
|
|
|
TaggedData::DataType tp,
|
// data type
|
|
|
const void* data,
|
// data
|
|
|
size_t size,
|
// size
|
|
|
logical swap
|
// support byte swapping?
|
|
|
);
|
|
|
Writes tagged data.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_terminator
();
|
|
|
Writes a terminator.
|
|
|
|
|
|
|
public: virtual void BinaryFile::write_vector
(
|
|
|
const SPAvector&
|
// vector to be written
|
|
|
);
|
|
|
Writes a vector.
|