/src/FreeImage/Source/OpenEXR/IlmImf/ImfVecAttribute.cpp

https://bitbucket.org/cabalistic/ogredeps/ · C++ · 216 lines · 129 code · 44 blank · 43 comment · 0 complexity · 5bd314a6dc835477107f270f5846b492 MD5 · raw file

  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2004, 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. //-----------------------------------------------------------------------------
  35. //
  36. // class V2iAttribute
  37. // class V2fAttribute
  38. // class V2dAttribute
  39. // class V3iAttribute
  40. // class V3fAttribute
  41. // class V3dAttribute
  42. //
  43. //-----------------------------------------------------------------------------
  44. #include <ImfVecAttribute.h>
  45. namespace Imf {
  46. template <>
  47. const char *
  48. V2iAttribute::staticTypeName ()
  49. {
  50. return "v2i";
  51. }
  52. template <>
  53. void
  54. V2iAttribute::writeValueTo (OStream &os, int version) const
  55. {
  56. Xdr::write <StreamIO> (os, _value.x);
  57. Xdr::write <StreamIO> (os, _value.y);
  58. }
  59. template <>
  60. void
  61. V2iAttribute::readValueFrom (IStream &is, int size, int version)
  62. {
  63. Xdr::read <StreamIO> (is, _value.x);
  64. Xdr::read <StreamIO> (is, _value.y);
  65. }
  66. template <>
  67. const char *
  68. V2fAttribute::staticTypeName ()
  69. {
  70. return "v2f";
  71. }
  72. template <>
  73. void
  74. V2fAttribute::writeValueTo (OStream &os, int version) const
  75. {
  76. Xdr::write <StreamIO> (os, _value.x);
  77. Xdr::write <StreamIO> (os, _value.y);
  78. }
  79. template <>
  80. void
  81. V2fAttribute::readValueFrom (IStream &is, int size, int version)
  82. {
  83. Xdr::read <StreamIO> (is, _value.x);
  84. Xdr::read <StreamIO> (is, _value.y);
  85. }
  86. template <>
  87. const char *
  88. V2dAttribute::staticTypeName ()
  89. {
  90. return "v2d";
  91. }
  92. template <>
  93. void
  94. V2dAttribute::writeValueTo (OStream &os, int version) const
  95. {
  96. Xdr::write <StreamIO> (os, _value.x);
  97. Xdr::write <StreamIO> (os, _value.y);
  98. }
  99. template <>
  100. void
  101. V2dAttribute::readValueFrom (IStream &is, int size, int version)
  102. {
  103. Xdr::read <StreamIO> (is, _value.x);
  104. Xdr::read <StreamIO> (is, _value.y);
  105. }
  106. template <>
  107. const char *
  108. V3iAttribute::staticTypeName ()
  109. {
  110. return "v3i";
  111. }
  112. template <>
  113. void
  114. V3iAttribute::writeValueTo (OStream &os, int version) const
  115. {
  116. Xdr::write <StreamIO> (os, _value.x);
  117. Xdr::write <StreamIO> (os, _value.y);
  118. Xdr::write <StreamIO> (os, _value.z);
  119. }
  120. template <>
  121. void
  122. V3iAttribute::readValueFrom (IStream &is, int size, int version)
  123. {
  124. Xdr::read <StreamIO> (is, _value.x);
  125. Xdr::read <StreamIO> (is, _value.y);
  126. Xdr::read <StreamIO> (is, _value.z);
  127. }
  128. template <>
  129. const char *
  130. V3fAttribute::staticTypeName ()
  131. {
  132. return "v3f";
  133. }
  134. template <>
  135. void
  136. V3fAttribute::writeValueTo (OStream &os, int version) const
  137. {
  138. Xdr::write <StreamIO> (os, _value.x);
  139. Xdr::write <StreamIO> (os, _value.y);
  140. Xdr::write <StreamIO> (os, _value.z);
  141. }
  142. template <>
  143. void
  144. V3fAttribute::readValueFrom (IStream &is, int size, int version)
  145. {
  146. Xdr::read <StreamIO> (is, _value.x);
  147. Xdr::read <StreamIO> (is, _value.y);
  148. Xdr::read <StreamIO> (is, _value.z);
  149. }
  150. template <>
  151. const char *
  152. V3dAttribute::staticTypeName ()
  153. {
  154. return "v3d";
  155. }
  156. template <>
  157. void
  158. V3dAttribute::writeValueTo (OStream &os, int version) const
  159. {
  160. Xdr::write <StreamIO> (os, _value.x);
  161. Xdr::write <StreamIO> (os, _value.y);
  162. Xdr::write <StreamIO> (os, _value.z);
  163. }
  164. template <>
  165. void
  166. V3dAttribute::readValueFrom (IStream &is, int size, int version)
  167. {
  168. Xdr::read <StreamIO> (is, _value.x);
  169. Xdr::read <StreamIO> (is, _value.y);
  170. Xdr::read <StreamIO> (is, _value.z);
  171. }
  172. } // namespace Imf