MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / writeIntData

Method writeIntData

Src/Base/AMReX_VectorIO.cpp:6–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace amrex;
5
6void 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
34void amrex::readIntData (int* data, std::size_t size, std::istream& is,
35 const IntDescriptor& id)

Callers

nothing calls this directly

Calls 2

numBytesMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected