| 32 | } |
| 33 | |
| 34 | void amrex::readIntData (int* data, std::size_t size, std::istream& is, |
| 35 | const IntDescriptor& id) |
| 36 | { |
| 37 | if (id == FPC::NativeIntDescriptor()) |
| 38 | { |
| 39 | if (!is.read(reinterpret_cast<char*>(data), |
| 40 | static_cast<std::streamsize>(size * id.numBytes()))) |
| 41 | { |
| 42 | amrex::Error("Failed to read integer data."); |
| 43 | } |
| 44 | } |
| 45 | else if (id.numBytes() == 2) |
| 46 | { |
| 47 | readIntData<int, std::int16_t>(data, size, is, id); |
| 48 | } |
| 49 | else if (id.numBytes() == 4) |
| 50 | { |
| 51 | readIntData<int, std::int32_t>(data, size, is, id); |
| 52 | } |
| 53 | else if (id.numBytes() == 8) |
| 54 | { |
| 55 | readIntData<int, std::int64_t>(data, size, is, id); |
| 56 | } |
| 57 | else { |
| 58 | amrex::Error("Don't know how to work with this integer type."); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void amrex::writeLongData (const Long* data, std::size_t size, std::ostream& os, |
| 63 | const IntDescriptor& id) |