fork download
  1. template <class T>
  2. inline BinaryFileReader & operator>>( T & value )
  3. {
  4. readIn( &value, sizeof( value ) );
  5. if ( mFlipBytes )
  6. {
  7. if ( sizeof( value ) == 4 )
  8. {
  9. value = ( ( value >> 24 ) & 0x000000FF ) |
  10. ( ( value >> 8 ) & 0x0000FF00 ) |
  11. ( ( value << 8 ) & 0x00FF0000 ) |
  12. ( ( value << 24 ) & 0xFF000000 );
  13. }
  14. else if ( sizeof( value ) == 2 )
  15. {
  16. value = ( ( value >> 8 ) ) |
  17. ( ( value << 8 ) );
  18. }
  19. else if ( sizeof( value ) == 1 )
  20. {
  21. // (empty purposely) do not need to reverse
  22. }
  23. else
  24. {
  25. Debug( "Undefined!" );
  26. }
  27. }
  28. return *this;
  29. }
  30. inline BinaryFileReader & operator>>( uint64 & value )
  31. {
  32. readIn( &value, sizeof( value ) );
  33. if ( mFlipBytes )
  34. {
  35. value = ((value >> 56) & 0x00000000000000FFLL) |
  36. ((value >> 40) & 0x000000000000FF00LL) |
  37. ((value >> 24) & 0x0000000000FF0000LL) |
  38. ((value >> 8) & 0x00000000FF000000LL) |
  39. ((value << 8) & 0x000000FF00000000LL) |
  40. ((value << 24) & 0x0000FF0000000000LL) |
  41. ((value << 40) & 0x00FF000000000000LL) |
  42. ((value << 56) & 0xFF00000000000000LL);
  43. }
  44. return *this;
  45. }
  46. inline BinaryFileReader & operator>>( int64 & value )
  47. {
  48. readIn( &value, sizeof( value ) );
  49. if ( mFlipBytes )
  50. {
  51. value = ((value >> 56) & 0x00000000000000FFLL) |
  52. ((value >> 40) & 0x000000000000FF00LL) |
  53. ((value >> 24) & 0x0000000000FF0000LL) |
  54. ((value >> 8) & 0x00000000FF000000LL) |
  55. ((value << 8) & 0x000000FF00000000LL) |
  56. ((value << 24) & 0x0000FF0000000000LL) |
  57. ((value << 40) & 0x00FF000000000000LL) |
  58. ((value << 56) & 0xFF00000000000000LL);
  59. }
  60. return *this;
  61. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty