/src/FreeImage/Source/OpenEXR/IlmImf/ImfXdr.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 916 lines · 576 code · 223 blank · 117 comment · 32 complexity · c0d4e4802b8c4e2ad476eea7bb680e3f MD5 · raw file

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
  4. // Digital Ltd. LLC
  5. //
  6. // All rights reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are
  10. // met:
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Industrial Light & Magic nor the names of
  18. // its contributors may be used to endorse or promote products derived
  19. // from this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. ///////////////////////////////////////////////////////////////////////////
  34. #ifndef INCLUDED_IMF_XDR_H
  35. #define INCLUDED_IMF_XDR_H
  36. //----------------------------------------------------------------------------
  37. //
  38. // Xdr -- routines to convert data between the machine's native
  39. // format and a machine-independent external data representation:
  40. //
  41. // write<R> (T &o, S v); converts a value, v, of type S
  42. // into a machine-independent
  43. // representation and stores the
  44. // result in an output buffer, o.
  45. //
  46. // read<R> (T &i, S &v); reads the machine-independent
  47. // representation of a value of type
  48. // S from input buffer i, converts
  49. // the value into the machine's native
  50. // representation, and stores the result
  51. // in v.
  52. //
  53. // size<S>(); returns the size, in bytes, of the
  54. // machine-independent representation
  55. // of an object of type S.
  56. //
  57. // The write() and read() routines are templates; data can be written
  58. // to and read from any output or input buffer type T for which a helper
  59. // class, R, exits. Class R must define a method to store a char array
  60. // in a T, and a method to read a char array from a T:
  61. //
  62. // struct R
  63. // {
  64. // static void
  65. // writeChars (T &o, const char c[/*n*/], int n)
  66. // {
  67. // ... // Write c[0], c[1] ... c[n-1] to output buffer o.
  68. // }
  69. //
  70. // static void
  71. // readChars (T &i, char c[/*n*/], int n)
  72. // {
  73. // ... // Read n characters from input buffer i
  74. // // and copy them to c[0], c[1] ... c[n-1].
  75. // }
  76. // };
  77. //
  78. // Example - writing to and reading from iostreams:
  79. //
  80. // struct CharStreamIO
  81. // {
  82. // static void
  83. // writeChars (ostream &os, const char c[], int n)
  84. // {
  85. // os.write (c, n);
  86. // }
  87. //
  88. // static void
  89. // readChars (istream &is, char c[], int n)
  90. // {
  91. // is.read (c, n);
  92. // }
  93. // };
  94. //
  95. // ...
  96. //
  97. // Xdr::write<CharStreamIO> (os, 3);
  98. // Xdr::write<CharStreamIO> (os, 5.0);
  99. //
  100. //----------------------------------------------------------------------------
  101. #include <ImfInt64.h>
  102. #include "IexMathExc.h"
  103. #include "half.h"
  104. #include <limits.h>
  105. namespace Imf {
  106. namespace Xdr {
  107. //-------------------------------
  108. // Write data to an output stream
  109. //-------------------------------
  110. template <class S, class T>
  111. void
  112. write (T &out, bool v);
  113. template <class S, class T>
  114. void
  115. write (T &out, char v);
  116. template <class S, class T>
  117. void
  118. write (T &out, signed char v);
  119. template <class S, class T>
  120. void
  121. write (T &out, unsigned char v);
  122. template <class S, class T>
  123. void
  124. write (T &out, signed short v);
  125. template <class S, class T>
  126. void
  127. write (T &out, unsigned short v);
  128. template <class S, class T>
  129. void
  130. write (T &out, signed int v);
  131. template <class S, class T>
  132. void
  133. write (T &out, unsigned int v);
  134. template <class S, class T>
  135. void
  136. write (T &out, signed long v);
  137. template <class S, class T>
  138. void
  139. write (T &out, unsigned long v);
  140. #if ULONG_MAX != 18446744073709551615LU
  141. template <class S, class T>
  142. void
  143. write (T &out, Int64 v);
  144. #endif
  145. template <class S, class T>
  146. void
  147. write (T &out, float v);
  148. template <class S, class T>
  149. void
  150. write (T &out, double v);
  151. template <class S, class T>
  152. void
  153. write (T &out, half v);
  154. template <class S, class T>
  155. void
  156. write (T &out, const char v[/*n*/], int n); // fixed-size char array
  157. template <class S, class T>
  158. void
  159. write (T &out, const char v[]); // zero-terminated string
  160. //-----------------------------------------
  161. // Append padding bytes to an output stream
  162. //-----------------------------------------
  163. template <class S, class T>
  164. void
  165. pad (T &out, int n); // write n padding bytes
  166. //-------------------------------
  167. // Read data from an input stream
  168. //-------------------------------
  169. template <class S, class T>
  170. void
  171. read (T &in, bool &v);
  172. template <class S, class T>
  173. void
  174. read (T &in, char &v);
  175. template <class S, class T>
  176. void
  177. read (T &in, signed char &v);
  178. template <class S, class T>
  179. void
  180. read (T &in, unsigned char &v);
  181. template <class S, class T>
  182. void
  183. read (T &in, signed short &v);
  184. template <class S, class T>
  185. void
  186. read (T &in, unsigned short &v);
  187. template <class S, class T>
  188. void
  189. read (T &in, signed int &v);
  190. template <class S, class T>
  191. void
  192. read (T &in, unsigned int &v);
  193. template <class S, class T>
  194. void
  195. read (T &in, signed long &v);
  196. template <class S, class T>
  197. void
  198. read (T &in, unsigned long &v);
  199. #if ULONG_MAX != 18446744073709551615LU
  200. template <class S, class T>
  201. void
  202. read (T &in, Int64 &v);
  203. #endif
  204. template <class S, class T>
  205. void
  206. read (T &in, float &v);
  207. template <class S, class T>
  208. void
  209. read (T &in, double &v);
  210. template <class S, class T>
  211. void
  212. read (T &in, half &v);
  213. template <class S, class T>
  214. void
  215. read (T &in, char v[/*n*/], int n); // fixed-size char array
  216. template <class S, class T>
  217. void
  218. read (T &in, int n, char v[/*n*/]); // zero-terminated string
  219. //-------------------------------------------
  220. // Skip over padding bytes in an input stream
  221. //-------------------------------------------
  222. template <class S, class T>
  223. void
  224. skip (T &in, int n); // skip n padding bytes
  225. //--------------------------------------
  226. // Size of the machine-independent
  227. // representation of an object of type S
  228. //--------------------------------------
  229. template <class S>
  230. int
  231. size ();
  232. //---------------
  233. // Implementation
  234. //---------------
  235. template <class S, class T>
  236. inline void
  237. writeSignedChars (T &out, const signed char c[], int n)
  238. {
  239. S::writeChars (out, (const char *) c, n);
  240. }
  241. template <class S, class T>
  242. inline void
  243. writeUnsignedChars (T &out, const unsigned char c[], int n)
  244. {
  245. S::writeChars (out, (const char *) c, n);
  246. }
  247. template <class S, class T>
  248. inline void
  249. readSignedChars (T &in, signed char c[], int n)
  250. {
  251. S::readChars (in, (char *) c, n);
  252. }
  253. template <class S, class T>
  254. inline void
  255. readUnsignedChars (T &in, unsigned char c[], int n)
  256. {
  257. S::readChars (in, (char *) c, n);
  258. }
  259. template <class S, class T>
  260. inline void
  261. write (T &out, bool v)
  262. {
  263. char c = !!v;
  264. S::writeChars (out, &c, 1);
  265. }
  266. template <class S, class T>
  267. inline void
  268. write (T &out, char v)
  269. {
  270. S::writeChars (out, &v, 1);
  271. }
  272. template <class S, class T>
  273. inline void
  274. write (T &out, signed char v)
  275. {
  276. writeSignedChars<S> (out, &v, 1);
  277. }
  278. template <class S, class T>
  279. inline void
  280. write (T &out, unsigned char v)
  281. {
  282. writeUnsignedChars<S> (out, &v, 1);
  283. }
  284. template <class S, class T>
  285. void
  286. write (T &out, signed short v)
  287. {
  288. signed char b[2];
  289. b[0] = (signed char) (v);
  290. b[1] = (signed char) (v >> 8);
  291. writeSignedChars<S> (out, b, 2);
  292. }
  293. template <class S, class T>
  294. void
  295. write (T &out, unsigned short v)
  296. {
  297. unsigned char b[2];
  298. b[0] = (unsigned char) (v);
  299. b[1] = (unsigned char) (v >> 8);
  300. writeUnsignedChars<S> (out, b, 2);
  301. }
  302. template <class S, class T>
  303. void
  304. write (T &out, signed int v)
  305. {
  306. signed char b[4];
  307. b[0] = (signed char) (v);
  308. b[1] = (signed char) (v >> 8);
  309. b[2] = (signed char) (v >> 16);
  310. b[3] = (signed char) (v >> 24);
  311. writeSignedChars<S> (out, b, 4);
  312. }
  313. template <class S, class T>
  314. void
  315. write (T &out, unsigned int v)
  316. {
  317. unsigned char b[4];
  318. b[0] = (unsigned char) (v);
  319. b[1] = (unsigned char) (v >> 8);
  320. b[2] = (unsigned char) (v >> 16);
  321. b[3] = (unsigned char) (v >> 24);
  322. writeUnsignedChars<S> (out, b, 4);
  323. }
  324. template <class S, class T>
  325. void
  326. write (T &out, signed long v)
  327. {
  328. signed char b[8];
  329. b[0] = (signed char) (v);
  330. b[1] = (signed char) (v >> 8);
  331. b[2] = (signed char) (v >> 16);
  332. b[3] = (signed char) (v >> 24);
  333. #if LONG_MAX == 2147483647
  334. if (v >= 0)
  335. {
  336. b[4] = 0;
  337. b[5] = 0;
  338. b[6] = 0;
  339. b[7] = 0;
  340. }
  341. else
  342. {
  343. b[4] = ~0;
  344. b[5] = ~0;
  345. b[6] = ~0;
  346. b[7] = ~0;
  347. }
  348. #elif LONG_MAX == 9223372036854775807L
  349. b[4] = (signed char) (v >> 32);
  350. b[5] = (signed char) (v >> 40);
  351. b[6] = (signed char) (v >> 48);
  352. b[7] = (signed char) (v >> 56);
  353. #else
  354. #error write<T> (T &out, signed long v) not implemented
  355. #endif
  356. writeSignedChars<S> (out, b, 8);
  357. }
  358. template <class S, class T>
  359. void
  360. write (T &out, unsigned long v)
  361. {
  362. unsigned char b[8];
  363. b[0] = (unsigned char) (v);
  364. b[1] = (unsigned char) (v >> 8);
  365. b[2] = (unsigned char) (v >> 16);
  366. b[3] = (unsigned char) (v >> 24);
  367. #if ULONG_MAX == 4294967295U
  368. b[4] = 0;
  369. b[5] = 0;
  370. b[6] = 0;
  371. b[7] = 0;
  372. #elif ULONG_MAX == 18446744073709551615LU
  373. b[4] = (unsigned char) (v >> 32);
  374. b[5] = (unsigned char) (v >> 40);
  375. b[6] = (unsigned char) (v >> 48);
  376. b[7] = (unsigned char) (v >> 56);
  377. #else
  378. #error write<T> (T &out, unsigned long v) not implemented
  379. #endif
  380. writeUnsignedChars<S> (out, b, 8);
  381. }
  382. #if ULONG_MAX != 18446744073709551615LU
  383. template <class S, class T>
  384. void
  385. write (T &out, Int64 v)
  386. {
  387. unsigned char b[8];
  388. b[0] = (unsigned char) (v);
  389. b[1] = (unsigned char) (v >> 8);
  390. b[2] = (unsigned char) (v >> 16);
  391. b[3] = (unsigned char) (v >> 24);
  392. b[4] = (unsigned char) (v >> 32);
  393. b[5] = (unsigned char) (v >> 40);
  394. b[6] = (unsigned char) (v >> 48);
  395. b[7] = (unsigned char) (v >> 56);
  396. writeUnsignedChars<S> (out, b, 8);
  397. }
  398. #endif
  399. template <class S, class T>
  400. void
  401. write (T &out, float v)
  402. {
  403. union {unsigned int i; float f;} u;
  404. u.f = v;
  405. unsigned char b[4];
  406. b[0] = (unsigned char) (u.i);
  407. b[1] = (unsigned char) (u.i >> 8);
  408. b[2] = (unsigned char) (u.i >> 16);
  409. b[3] = (unsigned char) (u.i >> 24);
  410. writeUnsignedChars<S> (out, b, 4);
  411. }
  412. template <class S, class T>
  413. void
  414. write (T &out, double v)
  415. {
  416. union {Int64 i; double d;} u;
  417. u.d = v;
  418. unsigned char b[8];
  419. b[0] = (unsigned char) (u.i);
  420. b[1] = (unsigned char) (u.i >> 8);
  421. b[2] = (unsigned char) (u.i >> 16);
  422. b[3] = (unsigned char) (u.i >> 24);
  423. b[4] = (unsigned char) (u.i >> 32);
  424. b[5] = (unsigned char) (u.i >> 40);
  425. b[6] = (unsigned char) (u.i >> 48);
  426. b[7] = (unsigned char) (u.i >> 56);
  427. writeUnsignedChars<S> (out, b, 8);
  428. }
  429. template <class S, class T>
  430. inline void
  431. write (T &out, half v)
  432. {
  433. unsigned char b[2];
  434. b[0] = (unsigned char) (v.bits());
  435. b[1] = (unsigned char) (v.bits() >> 8);
  436. writeUnsignedChars<S> (out, b, 2);
  437. }
  438. template <class S, class T>
  439. inline void
  440. write (T &out, const char v[], int n) // fixed-size char array
  441. {
  442. S::writeChars (out, v, n);
  443. }
  444. template <class S, class T>
  445. void
  446. write (T &out, const char v[]) // zero-terminated string
  447. {
  448. while (*v)
  449. {
  450. S::writeChars (out, v, 1);
  451. ++v;
  452. }
  453. S::writeChars (out, v, 1);
  454. }
  455. template <class S, class T>
  456. void
  457. pad (T &out, int n) // add n padding bytes
  458. {
  459. for (int i = 0; i < n; i++)
  460. {
  461. const char c = 0;
  462. S::writeChars (out, &c, 1);
  463. }
  464. }
  465. template <class S, class T>
  466. inline void
  467. read (T &in, bool &v)
  468. {
  469. char c;
  470. S::readChars (in, &c, 1);
  471. v = !!c;
  472. }
  473. template <class S, class T>
  474. inline void
  475. read (T &in, char &v)
  476. {
  477. S::readChars (in, &v, 1);
  478. }
  479. template <class S, class T>
  480. inline void
  481. read (T &in, signed char &v)
  482. {
  483. readSignedChars<S> (in, &v, 1);
  484. }
  485. template <class S, class T>
  486. inline void
  487. read (T &in, unsigned char &v)
  488. {
  489. readUnsignedChars<S> (in, &v, 1);
  490. }
  491. template <class S, class T>
  492. void
  493. read (T &in, signed short &v)
  494. {
  495. signed char b[2];
  496. readSignedChars<S> (in, b, 2);
  497. v = (b[0] & 0x00ff) |
  498. (b[1] << 8);
  499. }
  500. template <class S, class T>
  501. void
  502. read (T &in, unsigned short &v)
  503. {
  504. unsigned char b[2];
  505. readUnsignedChars<S> (in, b, 2);
  506. v = (b[0] & 0x00ff) |
  507. (b[1] << 8);
  508. }
  509. template <class S, class T>
  510. void
  511. read (T &in, signed int &v)
  512. {
  513. signed char b[4];
  514. readSignedChars<S> (in, b, 4);
  515. v = (b[0] & 0x000000ff) |
  516. ((b[1] << 8) & 0x0000ff00) |
  517. ((b[2] << 16) & 0x00ff0000) |
  518. (b[3] << 24);
  519. }
  520. template <class S, class T>
  521. void
  522. read (T &in, unsigned int &v)
  523. {
  524. unsigned char b[4];
  525. readUnsignedChars<S> (in, b, 4);
  526. v = (b[0] & 0x000000ff) |
  527. ((b[1] << 8) & 0x0000ff00) |
  528. ((b[2] << 16) & 0x00ff0000) |
  529. (b[3] << 24);
  530. }
  531. template <class S, class T>
  532. void
  533. read (T &in, signed long &v)
  534. {
  535. signed char b[8];
  536. readSignedChars<S> (in, b, 8);
  537. #if LONG_MAX == 2147483647
  538. v = (b[0] & 0x000000ff) |
  539. ((b[1] << 8) & 0x0000ff00) |
  540. ((b[2] << 16) & 0x00ff0000) |
  541. (b[3] << 24);
  542. if (( b[4] || b[5] || b[6] || b[7]) &&
  543. (~b[4] || ~b[5] || ~b[6] || ~b[7]))
  544. {
  545. throw Iex::OverflowExc ("Long int overflow - read a large "
  546. "64-bit integer in a 32-bit process.");
  547. }
  548. #elif LONG_MAX == 9223372036854775807L
  549. v = ((long) b[0] & 0x00000000000000ff) |
  550. (((long) b[1] << 8) & 0x000000000000ff00) |
  551. (((long) b[2] << 16) & 0x0000000000ff0000) |
  552. (((long) b[3] << 24) & 0x00000000ff000000) |
  553. (((long) b[4] << 32) & 0x000000ff00000000) |
  554. (((long) b[5] << 40) & 0x0000ff0000000000) |
  555. (((long) b[6] << 48) & 0x00ff000000000000) |
  556. ((long) b[7] << 56);
  557. #else
  558. #error read<T> (T &in, signed long &v) not implemented
  559. #endif
  560. }
  561. template <class S, class T>
  562. void
  563. read (T &in, unsigned long &v)
  564. {
  565. unsigned char b[8];
  566. readUnsignedChars<S> (in, b, 8);
  567. #if ULONG_MAX == 4294967295U
  568. v = (b[0] & 0x000000ff) |
  569. ((b[1] << 8) & 0x0000ff00) |
  570. ((b[2] << 16) & 0x00ff0000) |
  571. (b[3] << 24);
  572. if (b[4] || b[5] || b[6] || b[7])
  573. {
  574. throw Iex::OverflowExc ("Long int overflow - read a large "
  575. "64-bit integer in a 32-bit process.");
  576. }
  577. #elif ULONG_MAX == 18446744073709551615LU
  578. v = ((unsigned long) b[0] & 0x00000000000000ff) |
  579. (((unsigned long) b[1] << 8) & 0x000000000000ff00) |
  580. (((unsigned long) b[2] << 16) & 0x0000000000ff0000) |
  581. (((unsigned long) b[3] << 24) & 0x00000000ff000000) |
  582. (((unsigned long) b[4] << 32) & 0x000000ff00000000) |
  583. (((unsigned long) b[5] << 40) & 0x0000ff0000000000) |
  584. (((unsigned long) b[6] << 48) & 0x00ff000000000000) |
  585. ((unsigned long) b[7] << 56);
  586. #else
  587. #error read<T> (T &in, unsigned long &v) not implemented
  588. #endif
  589. }
  590. #if ULONG_MAX != 18446744073709551615LU
  591. template <class S, class T>
  592. void
  593. read (T &in, Int64 &v)
  594. {
  595. unsigned char b[8];
  596. readUnsignedChars<S> (in, b, 8);
  597. v = ((Int64) b[0] & 0x00000000000000ffLL) |
  598. (((Int64) b[1] << 8) & 0x000000000000ff00LL) |
  599. (((Int64) b[2] << 16) & 0x0000000000ff0000LL) |
  600. (((Int64) b[3] << 24) & 0x00000000ff000000LL) |
  601. (((Int64) b[4] << 32) & 0x000000ff00000000LL) |
  602. (((Int64) b[5] << 40) & 0x0000ff0000000000LL) |
  603. (((Int64) b[6] << 48) & 0x00ff000000000000LL) |
  604. ((Int64) b[7] << 56);
  605. }
  606. #endif
  607. template <class S, class T>
  608. void
  609. read (T &in, float &v)
  610. {
  611. unsigned char b[4];
  612. readUnsignedChars<S> (in, b, 4);
  613. union {unsigned int i; float f;} u;
  614. u.i = (b[0] & 0x000000ff) |
  615. ((b[1] << 8) & 0x0000ff00) |
  616. ((b[2] << 16) & 0x00ff0000) |
  617. (b[3] << 24);
  618. v = u.f;
  619. }
  620. template <class S, class T>
  621. void
  622. read (T &in, double &v)
  623. {
  624. unsigned char b[8];
  625. readUnsignedChars<S> (in, b, 8);
  626. union {Int64 i; double d;} u;
  627. u.i = ((Int64) b[0] & 0x00000000000000ffULL) |
  628. (((Int64) b[1] << 8) & 0x000000000000ff00ULL) |
  629. (((Int64) b[2] << 16) & 0x0000000000ff0000ULL) |
  630. (((Int64) b[3] << 24) & 0x00000000ff000000ULL) |
  631. (((Int64) b[4] << 32) & 0x000000ff00000000ULL) |
  632. (((Int64) b[5] << 40) & 0x0000ff0000000000ULL) |
  633. (((Int64) b[6] << 48) & 0x00ff000000000000ULL) |
  634. ((Int64) b[7] << 56);
  635. v = u.d;
  636. }
  637. template <class S, class T>
  638. inline void
  639. read (T &in, half &v)
  640. {
  641. unsigned char b[2];
  642. readUnsignedChars<S> (in, b, 2);
  643. v.setBits ((b[0] & 0x00ff) | (b[1] << 8));
  644. }
  645. template <class S, class T>
  646. inline void
  647. read (T &in, char v[], int n) // fixed-size char array
  648. {
  649. S::readChars (in, v, n);
  650. }
  651. template <class S, class T>
  652. void
  653. read (T &in, int n, char v[]) // zero-terminated string
  654. {
  655. while (n >= 0)
  656. {
  657. S::readChars (in, v, 1);
  658. if (*v == 0)
  659. break;
  660. --n;
  661. ++v;
  662. }
  663. }
  664. template <class S, class T>
  665. void
  666. skip (T &in, int n) // skip n padding bytes
  667. {
  668. char c[1024];
  669. while (n >= (int) sizeof (c))
  670. {
  671. if (!S::readChars (in, c, sizeof (c)))
  672. return;
  673. n -= sizeof (c);
  674. }
  675. if (n >= 1)
  676. S::readChars (in, c, n);
  677. }
  678. template <> inline int size <bool> () {return 1;}
  679. template <> inline int size <char> () {return 1;}
  680. template <> inline int size <signed char> () {return 1;}
  681. template <> inline int size <unsigned char> () {return 1;}
  682. template <> inline int size <signed short> () {return 2;}
  683. template <> inline int size <unsigned short> () {return 2;}
  684. template <> inline int size <signed int> () {return 4;}
  685. template <> inline int size <unsigned int> () {return 4;}
  686. template <> inline int size <signed long> () {return 8;}
  687. template <> inline int size <unsigned long> () {return 8;}
  688. template <> inline int size <float> () {return 4;}
  689. template <> inline int size <double> () {return 8;}
  690. template <> inline int size <half> () {return 2;}
  691. } // namespace Xdr
  692. } // namespace Imf
  693. #endif