#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "memry.h"
#include "errcode.h"
#include "fileerr.h"
Go to the source code of this file.
#define make_serialise | ( | CLASSNAME | ) |
Definition at line 55 of file serialis.h.
#define QUOTE_IT | ( | parm | ) | #parm |
Replace <parm> with "\<parm\>". <parm> may be an arbitrary number of tokens
Definition at line 53 of file serialis.h.
DLLSYM void* de_serialise_bytes | ( | FILE * | f, | |
int | size | |||
) |
read non-class items, bytes
These are the only routines that write/read data to/from the serialisation.
"serialise_bytes" and "de_serialise_bytes" are used to serialise NON class items. The "make_serialise" macro generates "serialise" and "de_serialise" member functions for the class name specified in the macro parameter.
Definition at line 32 of file serialis.cpp.
References ABORT, alloc_mem(), ERRCODE::error(), NULL, and READFAILED.
Referenced by QSPLINE::de_dump(), and STRING::de_dump().
00032 { 00033 void *ptr; 00034 00035 ptr = alloc_mem (size); 00036 /* 00037 printf( "De_serialising bytes\n" ); 00038 printf( " Addr: %d Size: %d\n", int(ptr), size ); 00039 */ 00040 if (fread (ptr, size, 1, f) != 1) 00041 READFAILED.error ("de_serialise_bytes", ABORT, NULL); 00042 return ptr; 00043 }
DLLSYM double de_serialise_FLOAT64 | ( | FILE * | f | ) |
read non-class items, FLOAT64
Definition at line 92 of file serialis.cpp.
References ABORT, ERRCODE::error(), fscanf(), NULL, and READFAILED.
00092 { 00093 double the_float; 00094 00095 if (fscanf (f, "%lg", &the_float) != 1) 00096 READFAILED.error ("de_serialise_FLOAT64", ABORT, NULL); 00097 return the_float; 00098 }
DLLSYM INT32 de_serialise_INT32 | ( | FILE * | f | ) |
read non-class items, INT32
Definition at line 71 of file serialis.cpp.
References ABORT, ERRCODE::error(), fscanf(), INT32FORMAT, NULL, and READFAILED.
Referenced by TEXT_BLOCK::de_serialise_asc(), RULE_BLOCK::de_serialise_asc(), GRAPHICS_BLOCK::de_serialise_asc(), IMAGE_BLOCK::de_serialise_asc(), SCRIBBLE_BLOCK::de_serialise_asc(), WEIRD_BLOCK::de_serialise_asc(), ICOORD::de_serialise_asc(), POLY_BLOCK::de_serialise_asc(), and read_poly_blocks().
00071 { 00072 INT32 the_int; 00073 00074 if (fscanf (f, INT32FORMAT, &the_int) != 1) 00075 READFAILED.error ("de_serialise_INT32", ABORT, NULL); 00076 return the_int; 00077 }
Byte swap an INT32 or UINT32.
Definition at line 104 of file serialis.cpp.
References reverse16().
00106 { 00107 return (reverse16 ((UINT16) (num & 0xffff)) << 16) 00108 | reverse16 ((UINT16) ((num >> 16) & 0xffff)); 00109 }
DLLSYM void serialise_bytes | ( | FILE * | f, | |
void * | ptr, | |||
int | size | |||
) |
write non-class items, bytes
Definition at line 49 of file serialis.cpp.
References ABORT, ERRCODE::error(), NULL, and WRITEFAILED.
Referenced by QSPLINE::dump(), and STRING::dump().
00049 { 00050 /* 00051 printf( "Serialising bytes\n" ); 00052 printf( " Addr: %d Size: %d\n", int(ptr), size ); 00053 */ 00054 if (fwrite (ptr, size, 1, f) != 1) 00055 WRITEFAILED.error ("serialise_bytes", ABORT, NULL); 00056 }
DLLSYM void serialise_FLOAT64 | ( | FILE * | f, | |
double | the_float | |||
) |
write non-class items, FLOAT64
Definition at line 83 of file serialis.cpp.
References ABORT, ERRCODE::error(), NULL, and WRITEFAILED.
00083 { 00084 if (fprintf (f, "%g\n", the_float) < 0) 00085 WRITEFAILED.error ("serialise_FLOAT64", ABORT, NULL); 00086 }
DLLSYM void serialise_INT32 | ( | FILE * | f, | |
INT32 | the_int | |||
) |
write non-class items, INT32
Definition at line 62 of file serialis.cpp.
References ABORT, ERRCODE::error(), INT32FORMAT, NULL, and WRITEFAILED.
Referenced by ICOORD::serialise_asc().
00062 { 00063 if (fprintf (f, INT32FORMAT "\n", the_int) < 0) 00064 WRITEFAILED.error ("serialise_INT32", ABORT, NULL); 00065 }