cloudy trunk
Loading...
Searching...
No Matches
container_classes.cpp
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and
2 * others. For conditions of distribution and use see copyright notice in license.txt */
3
4#include "cddefines.h"
5#include "container_classes.h"
6
7
8#ifdef _MSC_VER
9/* disable "'extern' before template explicit instantiation" */
10# pragma warning( disable : 4231 )
11#endif
12
13/* Explicit instantiations for debugging purposes */
18#ifndef FLT_IS_DBL
20#endif
22
25void do_dump_state(const void* buf, size_t nelem, size_t size, FILE* out, int32 magic)
26{
27 DEBUG_ENTRY( "do_dump_state()" );
28
29 bool lgErr = ( fwrite( &magic, sizeof(int32), 1, out ) != 1 );
30 int32 help = (int32)sizeof(size_t);
31 lgErr = lgErr || ( fwrite( &help, sizeof(int32), 1, out ) != 1 );
32 lgErr = lgErr || ( fwrite( &size, sizeof(size_t), 1, out ) != 1 );
33 lgErr = lgErr || ( fwrite( buf, size, nelem, out ) != nelem );
34 if( lgErr )
35 {
36 fprintf( ioQQQ, " I/O error while dumping state!\n" );
38 }
39}
40
45void do_restore_state(void* buf, size_t nelem, size_t size, FILE *in, int32 magic)
46{
47 DEBUG_ENTRY( "do_restore_state()" );
48
49 int32 help = 0;
50 size_t help2 = 0;
51 bool lgErr = ( fread( &help, sizeof(int32), 1, in ) != 1 );
52 // this checks for correct version and prevents mixing up old style and new style data
53 // it also prevents mixing up data from big-endian and little-endian machines.
54 lgErr = lgErr || ( help != magic );
55 lgErr = lgErr || ( fread( &help, sizeof(int32), 1, in ) != 1 );
56 // this prevents mixing up data from 32-bit and 64-bit systems
57 lgErr = lgErr || ( help != (int32)sizeof(size_t) );
58 lgErr = lgErr || ( fread( &help2, sizeof(size_t), 1, in ) != 1 );
59 // this may guard against reading an older, incompatible version of the array
60 lgErr = lgErr || ( help2 != size );
61 lgErr = lgErr || ( fread( buf, size, nelem, in ) != nelem );
62 if( lgErr )
63 {
64 fprintf( ioQQQ, " Error while restoring state!\n" );
66 }
67}
FILE * ioQQQ
Definition cddefines.cpp:7
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
float realnum
Definition cddefines.h:103
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
void do_restore_state(void *buf, size_t nelem, size_t size, FILE *in, int32 magic)
void do_dump_state(const void *buf, size_t nelem, size_t size, FILE *out, int32 magic)
#define INSTANTIATE_MULTI_ARR(TYPE, BC)
#define lgBOUNDSCHECKVAL