36 #define DATRW_BYTESEX_CC_VERSION \ 37 "DATRW_BYTESEX_CC V1.1" 52 int magic(
const char*
const cmagic)
59 char chr[
sizeof(int)];
60 unsigned char uchr[
sizeof(int)];
62 const int& intsize=
sizeof(int);
63 for (
int i=0; i<intsize; i++)
64 { in.chr[i]=cmagic[i]; }
66 for (
int i=0; i<intsize; i++)
67 { out.uival=out.uival*256+in.uchr[i]; }
78 "The integer memory size on this CPU differs from the" 79 "required value of 4");
80 const int& intsize=
sizeof(int);
81 char test_seq[]=
"ABCD";
83 for (
int i=0; i<intsize; i++)
85 u1.
bytes[i]=test_seq[i];
86 u2.
bytes[i]=test_seq[intsize-i-1];
91 if (magnum == u1.
value)
95 else if (magnum == u2.
value)
106 const bool& fortranmode)
113 if (fortranmode) is.read(in_magic.
bytes,
sizeof(
int));
115 is.read(in_magic.
bytes,
sizeof(
int));
121 if (fortranmode) is.read(in_magic.
bytes,
sizeof(
int));
129 const bool& fortranmode)
132 ifour.
value=
sizeof(int);
134 if (fortranmode) os.write(ifour.
bytes,
sizeof(
int));
135 os.write(imagic.
bytes,
sizeof(
int));
136 if (fortranmode) os.write(ifour.
bytes,
sizeof(
int));
#define DATRW_assert(C, M)
Check an assertion and report by throwing an exception.
The bytesex of the file matches this machine.
Ecpu_type cpu()
check for my CPU model
Emagic_type file_magic_test(std::istream &is, const char *const cmagic, const bool &fortranmode)
check magic number in file
Ecpu_type
Define different CPU type that are recognized.
The magic number does match the file.
exception class declaration for libdatrwxx (prototypes)
T swap(const T &value)
How to swap any generic type.
A copy of bytesex.h from libtfxx (prototypes)
Root namespace of library.
The bytesex of the file must be swapped to match this machine.
int magic(const char *const cmagic)
function to create the magic number
Emagic_type
Define bytesex indicator for magic number test.
void file_magic_write(std::ostream &os, const char *const cmagic, const bool &fortranmode)
write magic number to file