6 #ifndef INCLUDED_IMF_XDR_H
7 #define INCLUDED_IMF_XDR_H
91 template <
class S,
class T>
void write (
T& out,
bool v);
93 template <
class S,
class T>
void write (
T& out,
char v);
95 template <
class S,
class T>
void write (
T& out,
signed char v);
97 template <
class S,
class T>
void write (
T& out,
unsigned char v);
99 template <
class S,
class T>
void write (
T& out,
signed short v);
101 template <
class S,
class T>
void write (
T& out,
unsigned short v);
103 template <
class S,
class T>
void write (
T& out,
signed int v);
105 template <
class S,
class T>
void write (
T& out,
unsigned int v);
107 template <
class S,
class T>
void write (
T& out, int64_t v);
109 template <
class S,
class T>
void write (
T& out, uint64_t v);
111 template <
class S,
class T>
void write (
T& out,
float v);
113 template <
class S,
class T>
void write (
T& out,
double v);
115 template <
class S,
class T>
void write (
T& out,
half v);
117 template <
class S,
class T>
118 void write (
T& out,
const char v[],
int n);
120 template <
class S,
class T>
121 void write (
T& out,
const char v[]);
127 template <
class S,
class T>
void pad (
T& out,
int n);
133 template <
class S,
class T>
void read (
T& in,
bool& v);
135 template <
class S,
class T>
void read (
T& in,
char& v);
137 template <
class S,
class T>
void read (
T& in,
signed char& v);
139 template <
class S,
class T>
void read (
T& in,
unsigned char& v);
141 template <
class S,
class T>
void read (
T& in,
signed short& v);
143 template <
class S,
class T>
void read (
T& in,
unsigned short& v);
145 template <
class S,
class T>
void read (
T& in,
signed int& v);
147 template <
class S,
class T>
void read (
T& in,
unsigned int& v);
149 template <
class S,
class T>
void read (
T& in, int64_t& v);
151 template <
class S,
class T>
void read (
T& in, uint64_t& v);
153 template <
class S,
class T>
void read (
T& in,
float& v);
155 template <
class S,
class T>
void read (
T& in,
double& v);
157 template <
class S,
class T>
void read (
T& in,
half& v);
159 template <
class S,
class T>
160 void read (
T& in,
char v[],
int n);
162 template <
class S,
class T>
163 void read (
T& in,
int n,
char v[]);
169 template <
class S,
class T>
void skip (
T& in,
int n);
176 template <
class S>
int size ();
182 template <
class S,
class T>
186 S::writeChars (out, (
const char*) c, n);
189 template <
class S,
class T>
193 S::writeChars (out, (
const char*) c, n);
196 template <
class S,
class T>
200 S::readChars (in, (
char*) c, n);
203 template <
class S,
class T>
207 S::readChars (in, (
char*) c, n);
210 template <
class S,
class T>
215 S::writeChars (out, &c, 1);
218 template <
class S,
class T>
222 S::writeChars (out, &v, 1);
225 template <
class S,
class T>
229 writeSignedChars<S> (out, &
v, 1);
232 template <
class S,
class T>
236 writeUnsignedChars<S> (out, &
v, 1);
239 template <
class S,
class T>
245 b[0] = (
signed char) (v);
246 b[1] = (
signed char) (v >> 8);
248 writeSignedChars<S> (out,
b, 2);
251 template <
class S,
class T>
257 b[0] = (
unsigned char) (v);
258 b[1] = (
unsigned char) (v >> 8);
260 writeUnsignedChars<S> (out,
b, 2);
263 template <
class S,
class T>
269 b[0] = (
signed char) (v);
270 b[1] = (
signed char) (v >> 8);
271 b[2] = (
signed char) (v >> 16);
272 b[3] = (
signed char) (v >> 24);
274 writeSignedChars<S> (out,
b, 4);
277 template <
class S,
class T>
283 b[0] = (
unsigned char) (v);
284 b[1] = (
unsigned char) (v >> 8);
285 b[2] = (
unsigned char) (v >> 16);
286 b[3] = (
unsigned char) (v >> 24);
288 writeUnsignedChars<S> (out,
b, 4);
291 template <
class S,
class T>
297 b[0] = (
signed char) (v);
298 b[1] = (
signed char) (v >> 8);
299 b[2] = (
signed char) (v >> 16);
300 b[3] = (
signed char) (v >> 24);
301 b[4] = (
signed char) (v >> 32);
302 b[5] = (
signed char) (v >> 40);
303 b[6] = (
signed char) (v >> 48);
304 b[7] = (
signed char) (v >> 56);
306 writeSignedChars<S> (out,
b, 8);
309 template <
class S,
class T>
315 b[0] = (
unsigned char) (v);
316 b[1] = (
unsigned char) (v >> 8);
317 b[2] = (
unsigned char) (v >> 16);
318 b[3] = (
unsigned char) (v >> 24);
319 b[4] = (
unsigned char) (v >> 32);
320 b[5] = (
unsigned char) (v >> 40);
321 b[6] = (
unsigned char) (v >> 48);
322 b[7] = (
unsigned char) (v >> 56);
324 writeUnsignedChars<S> (out,
b, 8);
327 template <
class S,
class T>
340 b[0] = (
unsigned char) (u.i);
341 b[1] = (
unsigned char) (u.i >> 8);
342 b[2] = (
unsigned char) (u.i >> 16);
343 b[3] = (
unsigned char) (u.i >> 24);
345 writeUnsignedChars<S> (out,
b, 4);
348 template <
class S,
class T>
361 b[0] = (
unsigned char) (u.i);
362 b[1] = (
unsigned char) (u.i >> 8);
363 b[2] = (
unsigned char) (u.i >> 16);
364 b[3] = (
unsigned char) (u.i >> 24);
365 b[4] = (
unsigned char) (u.i >> 32);
366 b[5] = (
unsigned char) (u.i >> 40);
367 b[6] = (
unsigned char) (u.i >> 48);
368 b[7] = (
unsigned char) (u.i >> 56);
370 writeUnsignedChars<S> (out,
b, 8);
373 template <
class S,
class T>
379 b[0] = (
unsigned char) (v.bits ());
380 b[1] = (
unsigned char) (v.bits () >> 8);
382 writeUnsignedChars<S> (out,
b, 2);
385 template <
class S,
class T>
387 write (T& out,
const char v[],
int n)
389 S::writeChars (out, v, n);
392 template <
class S,
class T>
398 S::writeChars (out, v, 1);
402 S::writeChars (out, v, 1);
405 template <
class S,
class T>
409 for (
int i = 0; i <
n; i++)
412 S::writeChars (out, &c, 1);
416 template <
class S,
class T>
422 S::readChars (in, &c, 1);
426 template <
class S,
class T>
430 S::readChars (in, &v, 1);
433 template <
class S,
class T>
437 readSignedChars<S> (in, &
v, 1);
440 template <
class S,
class T>
444 readUnsignedChars<S> (in, &
v, 1);
447 template <
class S,
class T>
453 readSignedChars<S> (in,
b, 2);
455 v = (
static_cast<unsigned char> (b[0]) & 0x00ff) |
456 (
static_cast<unsigned char> (b[1]) << 8);
459 template <
class S,
class T>
461 read (T& in,
unsigned short& v)
465 readUnsignedChars<S> (in,
b, 2);
467 v = (b[0] & 0x00ff) | (b[1] << 8);
470 template <
class S,
class T>
476 readSignedChars<S> (in,
b, 4);
478 v = (
static_cast<unsigned char> (b[0]) & 0x000000ff) |
479 ((
static_cast<unsigned char> (b[1]) << 8) & 0x0000ff00) |
480 ((static_cast<unsigned char> (b[2]) << 16) & 0x00ff0000) |
481 (
static_cast<unsigned char> (b[3]) << 24);
484 template <
class S,
class T>
490 readUnsignedChars<S> (in,
b, 4);
492 v = (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) |
493 ((b[2] << 16) & 0x00ff0000) | (b[3] << 24);
496 template <
class S,
class T>
502 readSignedChars<S> (in,
b, 8);
504 v = (
static_cast<int64_t
> (b[0]) & 0x00000000000000ff) |
505 ((
static_cast<int64_t
> (b[1]) << 8) & 0x000000000000ff00) |
506 ((static_cast<int64_t> (b[2]) << 16) & 0x0000000000ff0000) |
507 ((
static_cast<int64_t
> (b[3]) << 24) & 0x00000000ff000000) |
508 ((static_cast<int64_t> (b[4]) << 32) & 0x000000ff00000000) |
509 ((
static_cast<int64_t
> (b[5]) << 40) & 0x0000ff0000000000) |
510 ((static_cast<int64_t> (b[6]) << 48) & 0x00ff000000000000) |
511 (
static_cast<int64_t
> (b[7]) << 56);
514 template <
class S,
class T>
520 readUnsignedChars<S> (in,
b, 8);
522 v = ((uint64_t) b[0] & 0x00000000000000ffLL) |
523 (((uint64_t) b[1] << 8) & 0x000000000000ff00LL) |
524 (((uint64_t) b[2] << 16) & 0x0000000000ff0000LL) |
525 (((uint64_t) b[3] << 24) & 0x00000000ff000000LL) |
526 (((uint64_t) b[4] << 32) & 0x000000ff00000000LL) |
527 (((uint64_t) b[5] << 40) & 0x0000ff0000000000LL) |
528 (((uint64_t) b[6] << 48) & 0x00ff000000000000LL) |
529 ((uint64_t) b[7] << 56);
532 template <
class S,
class T>
538 readUnsignedChars<S> (in,
b, 4);
546 u.i = (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) |
547 ((b[2] << 16) & 0x00ff0000) | (b[3] << 24);
552 template <
class S,
class T>
558 readUnsignedChars<S> (in,
b, 8);
566 u.i = ((uint64_t) b[0] & 0x00000000000000ffULL) |
567 (((uint64_t) b[1] << 8) & 0x000000000000ff00ULL) |
568 (((uint64_t) b[2] << 16) & 0x0000000000ff0000ULL) |
569 (((uint64_t) b[3] << 24) & 0x00000000ff000000ULL) |
570 (((uint64_t) b[4] << 32) & 0x000000ff00000000ULL) |
571 (((uint64_t) b[5] << 40) & 0x0000ff0000000000ULL) |
572 (((uint64_t) b[6] << 48) & 0x00ff000000000000ULL) |
573 ((uint64_t) b[7] << 56);
578 template <
class S,
class T>
584 readUnsignedChars<S> (in,
b, 2);
586 v.setBits ((b[0] & 0x00ff) | (b[1] << 8));
589 template <
class S,
class T>
593 S::readChars (in, v, n);
596 template <
class S,
class T>
602 S::readChars (in, v, 1);
611 template <
class S,
class T>
617 while (n >= (
int)
sizeof (c))
619 if (!S::readChars (in, c,
sizeof (c)))
return;
624 if (n >= 1) S::readChars (in, c, n);
715 #if defined(OPENEXR_IMF_INTERNAL_NAMESPACE_AUTO_EXPOSE)
#define OPENEXR_IMF_INTERNAL_NAMESPACE
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
void writeUnsignedChars(T &out, const unsigned char c[], int n)
imath_half_bits_t half
if we're in a C-only context, alias the half bits type to half
void readUnsignedChars(T &in, unsigned char c[], int n)
void read(T &in, bool &v)
void writeSignedChars(T &out, const signed char c[], int n)
GLboolean GLboolean GLboolean b
#define OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
void readSignedChars(T &in, signed char c[], int n)
void write(T &out, bool v)