| 4 | using namespace amrex; |
| 5 | |
| 6 | void amrex::writeIntData (const int* data, std::size_t size, std::ostream& os, |
| 7 | const IntDescriptor& id) |
| 8 | { |
| 9 | if (id == FPC::NativeIntDescriptor()) |
| 10 | { |
| 11 | if (!os.write(reinterpret_cast<char const*>(data), |
| 12 | static_cast<std::streamsize>(size*sizeof(int)))) |
| 13 | { |
| 14 | amrex::Error("Failed to write integer data."); |
| 15 | } |
| 16 | } |
| 17 | else if (id.numBytes() == 2) |
| 18 | { |
| 19 | writeIntData<std::int16_t, int>(data, size, os, id); |
| 20 | } |
| 21 | else if (id.numBytes() == 4) |
| 22 | { |
| 23 | writeIntData<std::int32_t, int>(data, size, os, id); |
| 24 | } |
| 25 | else if (id.numBytes() == 8) |
| 26 | { |
| 27 | writeIntData<std::int64_t, int>(data, size, os, id); |
| 28 | } |
| 29 | else { |
| 30 | amrex::Error("Don't know how to work with this integer type."); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | void amrex::readIntData (int* data, std::size_t size, std::istream& is, |
| 35 | const IntDescriptor& id) |