| 21 | |
| 22 | template <typename To, typename From> |
| 23 | void writeIntData (const From* data, std::size_t size, std::ostream& os, |
| 24 | const amrex::IntDescriptor& id) |
| 25 | { |
| 26 | To value; |
| 27 | bool swapEndian = (id.order() != amrex::FPC::NativeIntDescriptor().order()); |
| 28 | for (std::size_t j = 0; j < size; ++j) { |
| 29 | value = static_cast<To>(data[j]); |
| 30 | if (swapEndian) { value = swapBytes(value); } |
| 31 | if (!os.write(reinterpret_cast<char const*>(&value), sizeof(To))) { |
| 32 | amrex::Error("Failed to write integer data."); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | template <typename To, typename From> |
| 38 | void readIntData (To* data, std::size_t size, std::istream& is, |
no test coverage detected