1#ifndef AMREX_INTCONV_H_
2#define AMREX_INTCONV_H_
3#include <AMReX_Config.H>
14 std::int16_t
swapBytes (std::int16_t value);
15 std::int32_t
swapBytes (std::int32_t value);
16 std::int64_t
swapBytes (std::int64_t value);
18 std::uint16_t
swapBytes (std::uint16_t value);
19 std::uint32_t
swapBytes (std::uint32_t value);
20 std::uint64_t
swapBytes (std::uint64_t value);
22 template <
typename To,
typename From>
23 void writeIntData (
const From* data, std::size_t size, std::ostream& os,
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))) {
37 template <
typename To,
typename From>
38 void readIntData (To* data, std::size_t size, std::istream& is,
43 for (std::size_t j = 0; j < size; ++j) {
44 if (!is.read(
reinterpret_cast<char*
>(&value),
sizeof(From))) {
47 if (swapEndian) { value =
swapBytes(value); }
48 data[j] =
static_cast<To
>(value);
static const IntDescriptor & NativeIntDescriptor()
Returns a constant reference to an IntDescriptor describing the native "int" under which AMReX was co...
Definition AMReX_FPC.cpp:76
A Descriptor of the Long Integer type.
Definition AMReX_FabConv.H:29
Ordering order() const
Returns the ordering.
Definition AMReX_FabConv.cpp:26
Definition AMReX_Amr.cpp:50
void writeIntData(const From *data, std::size_t size, std::ostream &os, const amrex::IntDescriptor &id)
Definition AMReX_IntConv.H:23
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:235
std::int16_t swapBytes(std::int16_t val)
Definition AMReX_IntConv.cpp:5
void readIntData(To *data, std::size_t size, std::istream &is, const amrex::IntDescriptor &id)
Definition AMReX_IntConv.H:38