ioHelper.h

Engine/source/core/stream/ioHelper.h

More...

Namespaces:

namespace

Helper templates to aggregate IO operations - generally used in template expansion.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _UTIL_IOHELPER_H_
 25#define _UTIL_IOHELPER_H_
 26
 27#ifndef _CORE_STREAM_H_
 28#include "core/stream/stream.h"
 29#endif
 30
 31/// Helper templates to aggregate IO operations - generally used in
 32/// template expansion.
 33namespace IOHelper
 34{
 35   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K, class L, class M>
 36      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k,L& l,M& m)
 37   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); s->read(&h); s->read(&i); s->read(&j); s->read(&k); s->read(&l); return s->read(&m); }
 38
 39   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K, class L>
 40      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k,L& l)
 41   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); s->read(&h); s->read(&i); s->read(&j); s->read(&k); return s->read(&l); }
 42
 43   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K>
 44      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k)
 45   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); s->read(&h); s->read(&i); s->read(&j); return s->read(&k); }
 46
 47   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J>
 48      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j)
 49   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); s->read(&h); s->read(&i); return s->read(&j); }
 50
 51   template<class A,class B,class C,class D,class E,class F,class G,class H,class I>
 52      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i)
 53   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); s->read(&h); return s->read(&i); }
 54
 55   template<class A,class B,class C,class D,class E,class F,class G,class H>
 56      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h)
 57   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); s->read(&g); return s->read(&h); }
 58
 59   template<class A,class B,class C,class D,class E,class F,class G>
 60      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g)
 61   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); s->read(&f); return s->read(&g); }
 62
 63   template<class A,class B,class C,class D,class E,class F>
 64      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f)
 65   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); s->read(&e); return s->read(&f); }
 66
 67   template<class A,class B,class C,class D,class E>
 68      inline bool reads(Stream *s,A& a,B& b,C& c,D& d,E& e)
 69   { s->read(&a); s->read(&b); s->read(&c); s->read(&d); return s->read(&e); }
 70
 71   template<class A,class B,class C,class D>
 72      inline bool reads(Stream *s,A& a,B& b,C& c,D& d)
 73   { s->read(&a); s->read(&b); s->read(&c); return s->read(&d); }
 74
 75   template<class A,class B,class C>
 76      inline bool reads(Stream *s,A& a,B& b,C& c)
 77   { s->read(&a); s->read(&b); return s->read(&c); }
 78
 79   template<class A,class B>
 80      inline bool reads(Stream *s,A& a,B& b)
 81   { s->read(&a); return s->read(&b); }
 82
 83   template<class A>
 84      inline bool reads(Stream *s,A& a)
 85   { return s->read(&a); }
 86
 87   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K,class L,class M>
 88      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k,L& l,M& m)
 89   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); s->write(h); s->write(i); s->write(j); s->write(k); s->write(l); return s->write(m); }
 90
 91   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K,class L>
 92      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k,L& l)
 93   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); s->write(h); s->write(i); s->write(j); s->write(k); return s->write(l); }
 94
 95   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J,class K>
 96      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j,K& k)
 97   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); s->write(h); s->write(i); s->write(j); return s->write(k); }
 98
 99   template<class A,class B,class C,class D,class E,class F,class G,class H,class I,class J>
100      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i,J& j)
101   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); s->write(h); s->write(i); return s->write(j); }
102
103   template<class A,class B,class C,class D,class E,class F,class G,class H,class I>
104      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h,I& i)
105   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); s->write(h); return s->write(i); }
106
107   template<class A,class B,class C,class D,class E,class F,class G,class H>
108      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g,H& h)
109   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); s->write(g); return s->write(h); }
110
111   template<class A,class B,class C,class D,class E,class F,class G>
112      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f,G& g)
113   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); s->write(f); return s->write(g); }
114
115   template<class A,class B,class C,class D,class E,class F>
116      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e,F& f)
117   { s->write(a); s->write(b); s->write(c); s->write(d); s->write(e); return s->write(f); }
118
119   template<class A,class B,class C,class D,class E>
120      inline bool writes(Stream *s,A& a,B& b,C& c,D& d,E& e)
121   { s->write(a); s->write(b); s->write(c); s->write(d); return s->write(e); }
122
123   template<class A,class B,class C,class D>
124      inline bool writes(Stream *s,A& a,B& b,C& c,D& d)
125   { s->write(a); s->write(b); s->write(c); return s->write(d); }
126
127   template<class A,class B,class C>
128      inline bool writes(Stream *s,A& a,B& b,C& c)
129   { s->write(a); s->write(b); return s->write(c); }
130
131   template<class A,class B>
132      inline bool writes(Stream *s,A& a,B& b)
133   { s->write(a); return s->write(b); }
134
135   template<class A>
136      inline bool writes(Stream *s,A& a)
137   { return s->write(a); }
138}
139
140#endif
141