| 82 | template<typename T> |
| 83 | struct ArithmeticHandler { |
| 84 | inline static void Write(Stream *strm, const T &data) { |
| 85 | if (DMLC_IO_NO_ENDIAN_SWAP) { |
| 86 | strm->Write(&data, sizeof(T)); |
| 87 | } else { |
| 88 | T copy = data; |
| 89 | ByteSwap(©, sizeof(T), 1); |
| 90 | strm->Write(©, sizeof(T)); |
| 91 | } |
| 92 | } |
| 93 | inline static bool Read(Stream *strm, T *dptr) { |
| 94 | bool ret = strm->Read((void*)dptr, sizeof(T)) == sizeof(T); // NOLINT(*) |
| 95 | if (!DMLC_IO_NO_ENDIAN_SWAP) { |