-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpack_base.h
786 lines (688 loc) · 21 KB
/
pack_base.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
/*
@copyright Russell Standish 2000-2013
@author Russell Standish
This file is part of Classdesc
Open source licensed under the MIT license. See LICENSE for details.
*/
/**\file
\brief serialisation descriptor
*/
#ifndef CLASSDESC_PACK_BASE_H
#define CLASSDESC_PACK_BASE_H
#include "classdesc.h"
#include "function.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <stdarg.h>
#include <exception>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <Realloc.h>
#ifdef _MSC_VER
// stupid warning about unassignable objects
#pragma warning(disable:4512)
#endif
namespace classdesc
{
struct XDR;
class pack_error : public exception
{
string msg;
public:
pack_error(const char *s): msg("pack:") {msg+=s;}
virtual ~pack_error() throw() {}
virtual const char* what() const throw() {return msg.c_str();}
};
#ifdef XDR_PACK
typedef bool (*xdr_filter)(XDR*,...);
#endif
struct basic_type
{
void *val;
size_t size;
#ifdef XDR_PACK
xdr_filter filter;
#endif
};
#ifdef XDR_PACK
template <class T> xdr_filter XDR_filter(const T&);
#endif
template <class T>
struct Basic_Type: public basic_type
{
Basic_Type(const T& x){
val=(void*)&x; size=sizeof(x);
#if defined(__GNUC__) && !defined(__ICC)
#pragma GCC diagnostic push
// gcc is not clever enough to delve into xdr to know this is not uninitialised
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#ifdef XDR_PACK
filter=XDR_filter(x);
#endif
#if defined(__GNUC__) && !defined(__ICC)
#pragma GCC diagnostic pop
#endif
}
};
/**
What to do with pointers: throw an exception, use graphnode or treenode
algorithm)
*/
enum Ptr_flag {DEFAULT, GRAPH, TREE};
/**
class for handling data allocated on heap by graphnode and treenode
algorithms
*/
struct PtrStoreBase
{
int cnt;
PtrStoreBase(): cnt(0) {}
virtual ~PtrStoreBase() {};
virtual void *data()=0;
};
/**
class for handling data allocated on heap by graphnode and treenode
algorithms
*/
template <class T>
struct PtrStore: public PtrStoreBase
{
T d;
void* data() {return &d;}
};
/**
class for handling data allocated on heap by graphnode and treenode
algorithms
*/
class PtrStoreRef
{
PtrStoreBase *d;
public:
void* data() {return d->data();}
PtrStoreRef(PtrStoreBase *d=NULL): d(d) {}
PtrStoreRef(const PtrStoreRef& x): d(x.d) {d && d->cnt++;}
PtrStoreRef& operator=(const PtrStoreRef& x) {d=x.d; d && d->cnt++; return *this;}
~PtrStoreRef() {if (d && d->cnt-- == 0) delete d;}
};
/**
basic serialisation buffer object
*/
class pack_t
{
#if __cplusplus < 201103L
pack_t operator=(const pack_t&){return *this;}
pack_t(const pack_t&){}
#else
pack_t operator=(const pack_t&)=delete;
pack_t(const pack_t&)=delete;
#endif
protected:
FILE *f;
void swap_base (pack_t& other){
std::swap(f,other.f);
std::swap(mode,other.mode);
std::swap(m_data,other.m_data);
std::swap(m_size,other.m_size);
std::swap(m_pos,other.m_pos);
std::swap(ptr_flag,other.ptr_flag);
std::swap(alloced,other.alloced);
}
enum mode_t {buf, readf, writef};
mode_t mode;
char *m_data; ///< actual buffer
size_t m_size; ///< size of buffer
size_t m_pos; ///< position of read pointer
public:
// class notimplemented{};
// int xdr;
Ptr_flag ptr_flag;
unsigned recur_max; ///< recursion limit for pack_graph
std::vector<PtrStoreRef> alloced; //allocated data used for cleaning up
const char* data() const {return m_data;} ///< actual buffer
char* data() {return m_data;} ///< actual buffer
size_t size() const {return m_size;} ///< size of buffer
size_t pos() const {return m_pos;} ///< position of read pointer
char* realloc(char* d, size_t s) {
#ifdef Realloc
return (char*)Realloc(d,s);
#else
return (char*)classdesc::realloc(d,s);
#endif
}
void realloc(size_t s) {m_data=realloc(m_data,s);}
/** resizes the buffer, leaving any extra allocated space uninitialised
use this for expanding an input buffer when reading from a stream
*/
void resize(size_t s) {
realloc(s);
if (!m_data) throw std::bad_alloc();
m_size=s;
}
virtual void append(const basic_type& x)
{
if (mode==buf)
{
realloc(m_size+x.size);
if (!m_data)
throw std::bad_alloc();
memcpy(m_data+m_size,x.val,x.size);
}
else
if (fwrite(x.val,x.size,1,f) != 1)
throw pack_error("file write fail");
m_size+=x.size;
}
virtual void popoff(basic_type& x)
{
if (mode==buf)
if (m_pos+x.size>m_size)
throw pack_error("unexpected end of data");
else
memcpy(x.val,m_data+m_pos,x.size);
else
if (fread(x.val,x.size,1,f) != 1)
throw pack_error("unexpected end of file");
m_pos+=x.size;
}
pack_t(size_t sz=0): f(0), mode(buf), m_data(NULL), m_size(sz), m_pos(0), ptr_flag(DEFAULT), recur_max(500) {
#ifdef RECUR_MAX
recur_max=RECUR_MAX;
#endif
realloc(sz);}
pack_t(const char *fname, const char *rw):
f(fopen(fname,rw)), mode( (rw&&rw[0]=='w')? writef: readf),
m_data(0), m_size(0), m_pos(0), ptr_flag(DEFAULT), recur_max(500) {
// this is to support a deprecated interface
#ifdef RECUR_MAX
recur_max=RECUR_MAX;
#endif
if (!f) throw pack_error(strerror(errno));
}
virtual ~pack_t() {realloc(0); if (f) fclose(f);}
#if __cplusplus >= 201103L
pack_t(pack_t&& x): f(nullptr), m_data(nullptr) {swap_base(x);}
pack_t& operator=(pack_t&& x) {swap_base(x); return *this;}
#endif
operator bool() {return m_pos<m_size;}
virtual pack_t& reseti() {m_size=0; if (f) fseek(f,0,SEEK_SET); return *this;}
virtual pack_t& reseto() {m_pos=0; if (f) fseek(f,0,SEEK_SET); return *this;}
virtual pack_t& seeki(long offs) {
assert(offs<=0); m_size+=offs;
if (f) fseek(f,offs,SEEK_CUR);
return *this;
}
virtual pack_t& seeko(long offs) {
m_pos+=offs;
if (f) fseek(f,offs,SEEK_CUR);
return *this;
}
void clear() {realloc(0); m_data=0; m_size=m_pos=0;}
virtual void packraw(const char *x, size_t s)
{
if (mode==buf)
{
realloc(m_size+s);
memcpy(m_data+m_size,x,s); m_size+=s;
}
else
if (fwrite(x,s,1,f)!=1)
throw pack_error("filed to write data to stream");
}
#if defined(__GNUC__) && !defined(__ICC)
#pragma GCC diagnostic push
// this warning is randomly triggered on Tumbleweed docker environment
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
virtual void unpackraw(char *x, size_t s)
{
if (mode==buf)
{
if (s>m_size-m_pos)
throw pack_error("premature end of buffered data");
memcpy(x,m_data+m_pos,s);
}
else
if (fread(x,s,1,f)!=1)
throw pack_error("premature end of stream");
m_pos+=s;
}
#if defined(__GNUC__) && !defined(__ICC)
#pragma GCC diagnostic pop
#endif
virtual void swap(pack_t& other) {
if (typeid(*this)!=typeid(other))
throw pack_error("cannot swap differing types");
swap_base(other);
}
/// returns -1, 0 or 1 if this is lexicographically less, equal or
/// greater than \a x
virtual int cmp(const pack_t& x) const {
if (m_size==x.m_size)
return memcmp(m_data,x.m_data,m_size);
else
return m_size<x.m_size? -1: 1;
}
bool operator<(const pack_t& x) const {return cmp(x)==-1;}
bool operator>(const pack_t& x) const {return cmp(x)==1;}
bool operator==(const pack_t& x) const {return cmp(x)==0;}
bool operator!=(const pack_t& x) const {return cmp(x)!=0;}
};
/// deep comparison of two serialisable items
template <class T>
int deepCmp(const T& x, const T& y) {
pack_t xb, yb;
return (xb<<x).cmp(yb<<y);
}
/// deep equality of two serialisable items
template <class T>
bool deepEq(const T& x, const T& y) {
pack_t xb, yb;
return (xb<<x).cmp(yb<<y)==0;
}
typedef pack_t unpack_t;
template <> inline string typeName<pack_t>() {return "classdesc::pack_t";}
#ifdef XDR_PACK
const int BUFCHUNK=1024;
/**
machine independent serialisation buffer object
*/
class xdr_pack: public pack_t
{
size_t asize;
XDR *input, *output;
public:
xdr_pack(size_t sz=BUFCHUNK);
xdr_pack(const char *, const char* rw);
~xdr_pack();
#if __cplusplus >= 201103L
xdr_pack(xdr_pack&& x): input(nullptr), output(nullptr) {swap(x);}
xdr_pack& operator=(xdr_pack&& x) {swap(x); return *this;}
#endif
virtual void append(const basic_type& x);
virtual void popoff(basic_type& x);
virtual xdr_pack& reseti();
virtual xdr_pack& reseto();
virtual xdr_pack& seeki(long offs);
virtual xdr_pack& seeko(long offs);
virtual void packraw(const char *x, size_t sz);
virtual void unpackraw(char *x, size_t sz);
virtual void swap(pack_t& other) {
xdr_pack* xdr_other=dynamic_cast<xdr_pack*>(&other);
if (!xdr_other) throw pack_error("cannot swap differing types");
swap_base(other);
std::swap(asize,xdr_other->asize);
std::swap(input,xdr_other->input);
std::swap(input,xdr_other->output);
}
};
template <> inline string typeName<xdr_pack>() {return "classdesc::xdr_pack";}
#else
typedef pack_t xdr_pack;
#endif
/** Binary streamer class. This subverts the normal classdesc
serialisation to just stream types directly to a pack_t
type, for efficiency. Only useful for PODs.
Caveat: Do not use on classes with virtual functions!
*/
class BinStream
{
pack_t& packer;
public:
BinStream(pack_t& packer): packer(packer) {}
template <class T>
typename enable_if<Not<is_container<T> >, BinStream&>::T
operator<<(const T& o)
{
packer.packraw(reinterpret_cast<const char*>(&o), sizeof(T));
return *this;
}
template <class T>
typename enable_if<Not<is_container<T> >, BinStream&>::T
operator>>(T& o)
{
packer.unpackraw(reinterpret_cast<char*>(&o), sizeof(T));
return *this;
}
template <class T>
typename enable_if<is_container<T>, BinStream&>::T
operator<<(const T& o)
{
(*this)<<o.size();
for (typename T::const_iterator i=o.begin(); i!=o.end(); ++i)
(*this)<<*i;
return *this;
}
template <class T>
typename enable_if<is_sequence<T>, BinStream&>::T
operator>>(T& o)
{
size_t s;
(*this)>>s;
typename T::value_type v;
for (size_t i=0; i<s; ++i)
{
(*this)>>v;
o.push_back(v);
}
return *this;
}
template <class T>
typename enable_if<is_associative_container<T>, BinStream&>::T
operator>>(T& o)
{
size_t s;
(*this)>>s;
typename T::value_type v;
for (size_t i=0; i<s; ++i)
{
(*this)>>v;
o.insert(v);
}
return *this;
}
/// specialisation for vector
template <class T, class A>
inline BinStream& operator<<(const std::vector<T,A>& o);
template <class T, class A>
inline BinStream& operator>>(std::vector<T,A>& o);
};
/**
convenience Template for creating a binary streamer in one hit
BinStreamT cannot be a Pack, as this causes ambiguity in the
resolution of the streaming operators. So instead it has one.
*/
template <class Pack> struct BinStreamT: public BinStream
{
Pack thePack;
BinStreamT(): BinStream(thePack) {}
template <class A1> BinStreamT(A1 a1):
BinStream(thePack), thePack(a1) {}
template <class A1, class A2> BinStreamT(A1 a1, A2 a2):
BinStream(thePack), thePack(a1, a2) {}
};
/**
Used to indicate a member is not to be serialised: eg
class foo
{
unserialisable<std::vector<int>::iterator> i;
...
};
Deprecated in favour of Exclude
*/
template <class T>
struct unserialisable: public T
{
unserialisable() {}
unserialisable(const T& x): T(x) {}
unserialisable operator=(const T& x) {T::operator=(x); return *this;}
};
template <class T> pack_t& operator<<(pack_t& y,const T&x);
template <class T> pack_t& operator>>(pack_t& y,T&x);
/// for use in metaprogramming support. Indicate that a given type
/// is supported explicitly
template <class T> struct pack_supported:
public Or<
Or<
is_fundamental<T>,
is_container<T>
>,
is_excluded<T>
> {};
#ifndef THROW_PTR_EXCEPTION
template <class T>
inline void pack(pack_t& targ, const string& desc, is_treenode dum, const T* const& arg);
template <class T>
inline void unpack(unpack_t& targ, const string& desc,
is_treenode dum, T*& arg);
template <class T>
inline void pack(pack_t& targ, const string& desc,
is_graphnode dum,const T& arg);
///unserialise a graph structure
/** can contain cycles */
template <class T>
inline void unpack(pack_t& targ, const string& desc,
is_graphnode dum,T& arg);
#endif
template <class T>
void pack_onbase(pack_t& x,const string& d,T& a)
{pack(x,d,a);}
template <class T>
void unpack_onbase(unpack_t& x,const string& d,T& a)
{unpack(x,d,a);}
}
using classdesc::pack_onbase;
using classdesc::unpack_onbase;
/**
@namespace classdesc_access \brief Contains access_* structs, and nothing
else. These structs are used to gain access to private members
*/
namespace classdesc_access
{
/// class to allow access to private members
template <class T> struct access_pack;
/// class to allow access to private members
template <class T> struct access_unpack;
/* default action for pointers is to throw an error message */
template <class T>
struct access_pack<T*>
{
typedef T Arg;
template <class C>
typename classdesc::enable_if<classdesc::Not<classdesc::is_function<Arg> >,void>::T
operator()(classdesc::pack_t& targ, const classdesc::string& desc, C& arg)
{
switch (targ.ptr_flag)
{
// You may wish to define this macro if you have messy types containing pointers
#ifndef THROW_PTR_EXCEPTION
case classdesc::GRAPH:
pack(targ,desc,classdesc::is_graphnode(),arg);
break;
case classdesc::TREE:
pack(targ,desc,classdesc::is_treenode(),arg);
break;
#endif
default:
throw classdesc::pack_error("Packing arbitrary pointer data not implemented");
}
}
};
template <class T>
struct access_unpack<T*>
{
template <class C>
void operator()(classdesc::unpack_t& targ, const classdesc::string& desc, C& arg)
{
switch (targ.ptr_flag)
{
// You may wish to define this macro if you have messy types containing pointers
#ifndef THROW_PTR_EXCEPTION
case classdesc::GRAPH:
unpack(targ,desc,classdesc::is_graphnode(),arg);
break;
case classdesc::TREE:
unpack(targ,desc,classdesc::is_treenode(),arg);
break;
#endif
default:
throw classdesc::pack_error("Unpacking arbitrary pointer data not implemented");
}
}
};
template <class T>
struct access_pack<classdesc::unserialisable<T> >:
public classdesc::NullDescriptor<classdesc::pack_t> {};
template <class T>
struct access_unpack<classdesc::unserialisable<T> >:
public classdesc::NullDescriptor<classdesc::pack_t> {};
template <class T>
struct access_pack<classdesc::Exclude<T> >:
public classdesc::NullDescriptor<classdesc::pack_t> {};
template <class T>
struct access_unpack<classdesc::Exclude<T> >:
public classdesc::NullDescriptor<classdesc::pack_t> {};
}
namespace classdesc
{
//generic pack, unpack - defined in pack_stream
template <class T> typename
enable_if<Not<pack_supported<T> >, void>::T
pack(pack_t& buf, const string& desc, T& arg)
{classdesc_access::access_pack<T>()(buf,desc,arg);}
template <class T> typename
enable_if<Not<pack_supported<T> >, void>::T
unpack(unpack_t& buf, const string& desc, T& arg)
{classdesc_access::access_unpack<T>()(buf,desc,arg);}
template <class T>
typename enable_if<is_fundamental<T>, void>::T
pack(pack_t& targ, const string&, T& arg)
{
Basic_Type<T> b(arg);
targ.append(b);
}
template <class T>
typename enable_if<is_fundamental<T>, void>::T
pack(pack_t& targ, const string&, const T& arg)
{
Basic_Type<T> b(arg);
targ.append(b);
}
template <class T>
typename enable_if<is_fundamental<T>, void>::T
unpack(unpack_t& targ, const string&, T& arg)
{
Basic_Type<T> b(arg);
targ.popoff(b);
}
template <class T>
typename enable_if<is_fundamental<T>, void>::T
unpack(unpack_t& targ, const string&, const T&)
{ /* const vars cannot be unpacked */
T dum(0); Basic_Type<T> b(dum);
targ.popoff(b);
}
/* The problem is that function pointers this template also, so we
need a separate pack to packup pointers to single objects:
pack a flag indicating validity, and then the object pointer points
to. Cannot handle arrays, but useful for graphs - assumes pointer is
valid unless NULL.
*/
template <class T>
void pack(pack_t& targ, const string& desc, is_array,
T &arg,int dims,size_t ncopies,...)
{
va_list ap;
va_start(ap,ncopies);
for (int i=1; i<dims; i++) ncopies*=va_arg(ap,int); //assume that 2 and higher D arrays dimensions are int
va_end(ap);
for (size_t i=0; i<ncopies; i++) pack(targ,desc,(&arg)[i]);
}
template <class T>
void unpack(unpack_t& targ, const string& desc, is_array, T &arg,
int dims,size_t ncopies,...)
{
va_list ap;
va_start(ap,ncopies);
for (int i=1; i<dims; i++) ncopies*=va_arg(ap,int);
va_end(ap);
for (size_t i=0; i<ncopies; i++) unpack(targ,desc,(&arg)[i]);
}
/* specialise for char* */
inline void pack(pack_t& targ, const string&, is_array,
char &arg,int dims,size_t ncopies,...)
{
int i;
va_list ap;
va_start(ap,ncopies);
for (i=1; i<dims; i++) ncopies*=va_arg(ap,int);
va_end(ap);
targ.packraw(&arg,ncopies);
}
inline void unpack(unpack_t& targ, const string&, is_array,
char &arg,int dims,size_t ncopies,...)
{
int i;
va_list ap;
va_start(ap,ncopies);
for (i=1; i<dims; i++) ncopies*=va_arg(ap,int);
va_end(ap);
targ.unpackraw(&arg,ncopies);
}
/*
Method pointer serialisation
*/
template <class C, class R, class A1>
void pack(pack_t& targ, const string& desc, R (C::*&arg)(A1))
{targ.packraw((char*)&arg,sizeof(arg));}
template <class C, class R, class A1>
void unpack(pack_t& targ, const string& desc, R (C::*&arg)(A1))
{targ.unpackraw((char*)&arg,sizeof(arg));}
template<class C, class T>
typename enable_if<And<is_member_object_pointer<T>,
Not<functional::is_nonmember_function_ptr<T> > >,void>::T
pack(pack_t& b, const string& d, C& o, T y);
template<class C, class T>
typename enable_if<And<is_member_object_pointer<T>,
Not<functional::is_nonmember_function_ptr<T> > >,void>::T
unpack(unpack_t& b, const string& d, C& o, T y);
template<class C, class T>
typename enable_if<
And<Not<is_base_of<is_const_static,C> >,
is_object<T> >,void>::T
pack(pack_t& b, const string& d, C&, T* y);
template<class C, class T>
typename enable_if<
And<Not<is_base_of<is_const_static,C> >,
is_object<T> >,void>::T
unpack(unpack_t& b, const string& d, C&, T* y);
/// const static support. No need to stream
template <class T>
void pack(pack_t& targ, const string& desc, is_const_static i, T t)
{}
template <class T>
void unpack(pack_t& targ, const string& desc,is_const_static i, T t)
{}
// static methods
template <class T, class U>
void pack(pack_t&, const string&,is_const_static, const T&, U) {}
template <class T, class U>
void unpack(pack_t& targ, const string& desc,is_const_static i, const T&, U) {}
// to handle pack/unpacking of enums when -typeName is in effect
template <class E>
void pack(pack_t& targ, const string& desc,Enum_handle<E> a)
{
int x=a;
pack(targ,desc,x);
}
template <class E>
void unpack(pack_t& targ, const string& desc, Enum_handle<E> a)
{
int x;
unpack(targ,desc,x);
a=x;
}
template <class T> void pack(pack_t&, const string&, const Exclude<T>&) {}
template <class T> void unpack(pack_t&, const string&, const Exclude<T>&) {}
}
#include "use_mbr_pointers.h"
CLASSDESC_FUNCTION_NOP(pack)
CLASSDESC_FUNCTION_NOP(unpack)
using classdesc::pack;
using classdesc::unpack;
using classdesc::pack_onbase;
using classdesc::unpack_onbase;
#ifdef _CLASSDESC
#pragma omit pack classdesc::string
#pragma omit pack eco_strstream
#pragma omit pack xdr_pack
#pragma omit unpack classdesc::string
#pragma omit unpack eco_strstream
#pragma omit unpack xdr_pack
#endif
#endif