43 #define TF_IOSWAP_CC_VERSION \ 46 #include <tfxx/bytesex.h> 47 #include <tfxx/error.h> 59 int magic(
const char*
const cmagic)
66 char chr[
sizeof(int)];
67 unsigned char uchr[
sizeof(int)];
69 const int& intsize=
sizeof(int);
70 for (
int i=0; i<intsize; i++)
71 { in.chr[i]=cmagic[i]; }
73 for (
int i=0; i<intsize; i++)
74 { out.uival=out.uival*256+in.uchr[i]; }
85 "The integer memory size on this CPU differs from the" 86 "required value of 4");
87 const int& intsize=
sizeof(int);
88 char test_seq[]=
"ABCD";
90 for (
int i=0; i<intsize; i++)
92 u1.
bytes[i]=test_seq[i];
93 u2.
bytes[i]=test_seq[intsize-i-1];
98 if (magnum == u1.
value)
102 else if (magnum == u2.
value)
113 const bool& fortranmode)
120 if (fortranmode) is.read(in_magic.
bytes,
sizeof(
int));
122 is.read(in_magic.
bytes,
sizeof(
int));
128 if (fortranmode) is.read(in_magic.
bytes,
sizeof(
int));
136 const bool& fortranmode)
139 ifour.
value=
sizeof(int);
141 if (fortranmode) os.write(ifour.
bytes,
sizeof(
int));
142 os.write(imagic.
bytes,
sizeof(
int));
143 if (fortranmode) os.write(ifour.
bytes,
sizeof(
int));
#define TFXX_assert(C, M)
Check an assertion and report by throwing an exception.
Ecpu_type
Define different CPU type that are recognized.
int magic(const char *const cmagic)
Create a magic number from a character string. ,If represents the input character sequence cmagic an...
Emagic_type file_magic_test(std::istream &is, const char *const cmagic, const bool &fortranmode=false)
Check for magic number in file.
T swap(const T &value)
How to swap any generic type.
The bytesex of the file matches this machine.
The bytesex of the file must be swapped to match this machine.
Ecpu_type cpu()
Check CPU model. ,.
Emagic_type
Define bytesex indicator for magic number test.
The magic number does match the file.
void file_magic_write(std::ostream &os, const char *const cmagic, const bool &fortranmode=false)
Write magic number to file. ,.
Namespace containing all code of library libtfxx.