29#include "libmesh/xdr_cxx.h"
30#include "libmesh/libmesh_logging.h"
31#ifdef LIBMESH_HAVE_GZSTREAM
34#include "libmesh/utility.h"
36#ifdef LIBMESH_HAVE_UNISTD_H
39#ifdef LIBMESH_HAVE_PROCESS_H
47void bzip_file (std::string_view unzipped_name)
49#ifdef LIBMESH_HAVE_BZIP
50 LOG_SCOPE(
"system(bzip2)",
"XdrIO");
52 std::string system_string =
"bzip2 -f ";
53 system_string += unzipped_name;
54 if (std::system(system_string.c_str()))
55 libmesh_file_error(system_string);
57 libmesh_error_msg(
"ERROR: need bzip2/bunzip2 to create " << unzipped_name <<
".bz2");
61void xzip_file (std::string_view unzipped_name)
64 LOG_SCOPE(
"system(xz)",
"XdrIO");
66 std::string system_string =
"xz -f ";
67 system_string += unzipped_name;
68 if (std::system(system_string.c_str()))
69 libmesh_file_error(system_string);
71 libmesh_error_msg(
"ERROR: need xz to create " << unzipped_name <<
".xz");
77void remove_unzipped_file (std::string_view name)
79 std::ostringstream pid_suffix;
80 pid_suffix <<
'_' << getpid();
86 std::string new_name(
name.begin(),
name.end()-4);
87 new_name += pid_suffix.str();
88 std::remove(new_name.c_str());
92 std::string new_name(
name.begin(),
name.end()-3);
93 new_name += pid_suffix.str();
94 std::remove(new_name.c_str());
107 file_name(
std::move(name)),
108#ifdef LIBMESH_HAVE_XDR
117 version_number(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION, LIBMESH_MINOR_VERSION, LIBMESH_MICRO_VERSION))
127#ifdef LIBMESH_HAVE_XDR
131 out(
std::make_unique<
std::ostream>(stream.rdbuf())),
136 version_number(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION, LIBMESH_MINOR_VERSION, LIBMESH_MICRO_VERSION))
145#ifdef LIBMESH_HAVE_XDR
148 in(
std::make_unique<
std::istream>(stream.rdbuf())),
154 version_number(LIBMESH_VERSION_ID(LIBMESH_MAJOR_VERSION, LIBMESH_MINOR_VERSION, LIBMESH_MICRO_VERSION))
179#ifdef LIBMESH_HAVE_XDR
184 xdrs = std::make_unique<XDR>();
185 xdrstdio_create (
xdrs.get(),
fp, (
mode ==
ENCODE) ? XDR_ENCODE : XDR_DECODE);
188 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
189 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
190 <<
"The XDR interface is not available in this installation");
205#ifdef LIBMESH_HAVE_GZSTREAM
206 auto inf = std::make_unique<igzstream>();
208 inf->open(
file_name.c_str(), std::ios::in);
211 libmesh_error_msg(
"ERROR: need gzstream to handle .gz files!!!");
216 auto inf = std::make_unique<std::ifstream>();
221 inf->open(new_name.c_str(), std::ios::in);
240#ifdef LIBMESH_HAVE_GZSTREAM
241 auto outf = std::make_unique<ogzstream>();
243 outf->open(
file_name.c_str(), std::ios::out);
244 out = std::move(outf);
246 libmesh_error_msg(
"ERROR: need gzstream to handle .gz files!!!");
251 auto outf = std::make_unique<std::ofstream>();
257 new_name.erase(new_name.end() - 4, new_name.end());
260 new_name.erase(new_name.end() - 3, new_name.end());
262 outf->open(new_name.c_str(), std::ios::out);
263 out = std::move(outf);
272 libmesh_error_msg(
"Invalid mode = " <<
mode);
285#ifdef LIBMESH_HAVE_XDR
289 xdr_destroy (
xdrs.get());
301 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
302 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
303 <<
"The XDR interface is not available in this installation");
312 if (
in.get() !=
nullptr)
325 if (
out.get() !=
nullptr)
340 libmesh_error_msg(
"Invalid mode = " <<
mode);
353#ifdef LIBMESH_HAVE_XDR
363 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
364 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
365 <<
"The XDR interface is not available in this installation");
375 if (
in.get() !=
nullptr)
382 if (
out.get() !=
nullptr)
388 libmesh_error_msg(
"Invalid mode = " <<
mode);
403#ifdef LIBMESH_HAVE_XDR
411 int next = fgetc(
fp);
431 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
432 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
433 <<
"The XDR interface is not available in this installation");
449 int next =
in->peek();
474#ifdef LIBMESH_HAVE_XDR
481xdrproc_t xdr_translator();
484bool xdr_translate(XDR * x, T & a)
486 return (xdr_translator<T>())(x, &a, 0);
490bool xdr_translate(XDR * x,
494 std::copy(s.begin(), s.end(), sptr);
501 bool b = xdr_string(x, &begin, length);
504 length = cast_int<unsigned int>(std::strlen(sptr));
506 std::copy(sptr, sptr+length, s.begin());
512bool xdr_translate(XDR * x, std::complex<T> & a)
514 T r = a.real(), i = a.imag();
515 bool b1 = xdr_translate(x, r);
516 bool b2 = xdr_translate(x, i);
517 a = std::complex<T>(r,i);
522bool xdr_translate(XDR * x, std::vector<T> & a)
524 unsigned int length = cast_int<unsigned int>(a.size());
525 xdr_u_int(x, &length);
529 return xdr_vector(x,
reinterpret_cast<char *
>(a.data()), length,
sizeof(T),
530 xdr_translator<T>());
537bool xdr_translate(XDR * x, std::vector<std::complex<T>> & a)
539 unsigned int length = cast_int<unsigned int>(a.size());
540 bool b = xdr_u_int(x, &length);
543 if (!xdr_translate(x, val))
549bool xdr_translate(XDR * x, std::vector<std::string> & s)
551 unsigned int length = cast_int<unsigned int>(s.size());
552 bool b = xdr_u_int(x, &length);
555 if (!xdr_translate(x, val))
588struct function_signature;
590template<
typename returnval,
typename... Args>
591struct function_signature<returnval (*)(Args...)>
593 template <std::
size_t N>
595 static_assert(N <
sizeof...(Args),
"Function argument index too high");
596 using type =
typename std::tuple_element<N, std::tuple<Args...>>::type;
600#define libmesh_define_xdr(ourfunc, theirfunc, cxx_type) \
601 bool_t libmesh_xdr_##ourfunc(XDR * x, cxx_type * v, unsigned int) { \
603 std::remove_pointer<typename function_signature<decltype(&xdr_##theirfunc)>::template arg<1>::type>::type; \
604 static_assert(sizeof(cxx_type) == \
606 "Cannot safely cast data for use with XDR"); \
607 return xdr_##theirfunc(x, reinterpret_cast<api_type *>(v)); \
614libmesh_define_xdr(
long, longlong_t,
long long)
615libmesh_define_xdr(u_long, u_longlong_t,
unsigned long long)
617libmesh_define_xdr(
long,
long,
long)
618libmesh_define_xdr(u_long, u_long,
unsigned long)
622 #define libmesh_define_xdr(ourfunc, theirfunc, type) \
623 const xdrproc_t libmesh_xdr_##ourfunc = (xdrproc_t)xdr_##theirfunc;
625libmesh_define_xdr(
long,
long,
long)
626libmesh_define_xdr(u_long, u_long,
unsigned long)
629libmesh_define_xdr(
char,
char,
char)
630libmesh_define_xdr(
short,
short,
short)
631libmesh_define_xdr(
int,
int,
int)
632libmesh_define_xdr(longlong_t, longlong_t,
long long)
633libmesh_define_xdr(u_char, u_char,
unsigned char)
634libmesh_define_xdr(u_short, u_short,
unsigned short)
635libmesh_define_xdr(u_int, u_int,
unsigned int)
636libmesh_define_xdr(u_longlong_t, u_longlong_t,
unsigned long long)
637libmesh_define_xdr(
float,
float,
float)
638libmesh_define_xdr(
double,
double,
double)
642xdrproc_t xdr_translator<int>()
646 if (
sizeof(
int) <= 4)
647 return (xdrproc_t)(libmesh_xdr_int);
648 else if (
sizeof(
int) ==
sizeof(
long long))
649 return (xdrproc_t)(libmesh_xdr_longlong_t);
650 else if (
sizeof(
int) ==
sizeof(long))
651 return (xdrproc_t)(libmesh_xdr_long);
657xdrproc_t xdr_translator<unsigned int>()
661 if (
sizeof(
unsigned int) <= 4)
662 return (xdrproc_t)(libmesh_xdr_u_int);
663 else if (
sizeof(
unsigned int) ==
sizeof(
unsigned long))
664 return (xdrproc_t)(libmesh_xdr_u_long);
665 else if (
sizeof(
unsigned int) ==
sizeof(
unsigned long long))
666 return (xdrproc_t)(libmesh_xdr_u_longlong_t);
672xdrproc_t xdr_translator<long int>()
676 if (
sizeof(
long int) <= 4)
677 return (xdrproc_t)(libmesh_xdr_long);
678 else if (
sizeof(
long int) ==
sizeof(
long long))
679 return (xdrproc_t)(libmesh_xdr_longlong_t);
685xdrproc_t xdr_translator<unsigned long int>()
689 if (
sizeof(
unsigned long int) <= 4)
690 return (xdrproc_t)(libmesh_xdr_u_long);
691 else if (
sizeof(
unsigned long int) ==
sizeof(
unsigned long long))
692 return (xdrproc_t)(libmesh_xdr_u_longlong_t);
706xdrproc_t xdr_translator<long long>() {
return (xdrproc_t)(libmesh_xdr_longlong_t); }
709xdrproc_t xdr_translator<unsigned long long>() {
return (xdrproc_t)(libmesh_xdr_u_longlong_t); }
712xdrproc_t xdr_translator<short int>() {
return (xdrproc_t)(libmesh_xdr_short); }
715xdrproc_t xdr_translator<unsigned short int>() {
return (xdrproc_t)(libmesh_xdr_u_short); }
718xdrproc_t xdr_translator<char>() {
return (xdrproc_t)(libmesh_xdr_char); }
721xdrproc_t xdr_translator<signed char>() {
return (xdrproc_t)(libmesh_xdr_char); }
724xdrproc_t xdr_translator<unsigned char>() {
return (xdrproc_t)(libmesh_xdr_u_char); }
727xdrproc_t xdr_translator<float>() {
return (xdrproc_t)(libmesh_xdr_float); }
730xdrproc_t xdr_translator<double>() {
return (xdrproc_t)(libmesh_xdr_double); }
734xdrproc_t xdr_translator<long double>() {
return (xdrproc_t)(libmesh_xdr_double); }
736#ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
738xdrproc_t xdr_translator<Real>() {
return (xdrproc_t)(libmesh_xdr_double); }
757 a = std::complex<T>(r,i);
768 for (
unsigned int c=0, sl=std::strlen(
comm); c!=sl; c++)
772 a.push_back(
comm[c]);
779 unsigned int length=0;
780 data(length,
"# vector length");
795 unsigned int length=0;
796 data(length,
"# vector length x 2 (complex)");
799 for (std::complex<T> & a_i : a)
805 a_i = std::complex<T>(r,im);
816 *
out << a.real() <<
"\t " << a.imag();
822 std::size_t length = a.size();
823 data(length,
"# vector length");
826 *
out << std::scientific
827 << std::setprecision(std::numeric_limits<T>::max_digits10);
841 std::size_t length=a.size();
842 data(length,
"# vector length x 2 (complex)");
845 *
out << std::scientific
846 << std::setprecision(std::numeric_limits<T>::max_digits10);
848 for (std::complex<T> & a_i : a)
867#ifdef LIBMESH_HAVE_XDR
871 xdr_translate(
xdrs.get(), a);
875 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
876 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
877 <<
"The XDR interface is not available in this installation");
902 *
out << std::scientific
903 << std::setprecision(std::numeric_limits<T>::max_digits10);
909 if (comment_in !=
"")
910 *
out <<
"\t " << comment_in;
919 libmesh_error_msg(
"Invalid mode = " <<
mode);
931#ifdef LIBMESH_HAVE_XDR
935 unsigned int size_of_type = cast_int<unsigned int>(
sizeof(T));
937 xdr_vector(
xdrs.get(),
941 xdr_translator<T>());
943 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
944 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
945 <<
"The XDR interface is not available in this installation");
953#ifdef LIBMESH_HAVE_XDR
957 unsigned int size_of_type = cast_int<unsigned int>(
sizeof(T));
960 xdr_vector(
xdrs.get(),
964 xdr_translator<T>());
966 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
967 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
968 <<
"The XDR interface is not available in this installation");
979 for (
unsigned int i=0; i<len; i++)
998 *
out << std::scientific
999 << std::setprecision(std::numeric_limits<T>::max_digits10);
1002 for (
unsigned int i=0; i<len; i++)
1006 *
out << val[i] <<
" ";
1010 const unsigned imax = std::min(line_break, len);
1014 for (
unsigned int i=0; (i<imax && cnt<len); i++)
1034 libmesh_error_msg(
"Invalid mode = " <<
mode);
1045#ifdef LIBMESH_HAVE_XDR
1046 (xdrproc_t)libmesh_xdr_double,
1050 line_break, std::numeric_limits<double>::max_digits10);
1060#ifdef LIBMESH_HAVE_XDR
1061 (xdrproc_t)libmesh_xdr_float,
1065 line_break, std::numeric_limits<float>::max_digits10);
1071void Xdr::data_stream (
long double * val,
const unsigned int len,
const unsigned int line_break)
1074 (val, len,
nullptr, line_break,
1075 std::numeric_limits<long double>::max_digits10);
1079#ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
1089template <
typename XFP>
1091#ifdef LIBMESH_HAVE_XDR
1096 const unsigned int line_break,
1104#ifdef LIBMESH_HAVE_XDR
1111 xdr_vector(
xdrs.get(),
1129 std::vector<double> io_buffer (len);
1133 for (
unsigned int i=0, cnt=0; i<len; i++)
1134 io_buffer[cnt++] =
double(val[i]);
1136 xdr_vector(
xdrs.get(),
1137 reinterpret_cast<char *
>(io_buffer.data()),
1140 (xdrproc_t) libmesh_xdr_double);
1144 for (
unsigned int i=0, cnt=0; i<len; i++)
1146 val[i] = io_buffer[cnt++];
1152 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
1153 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
1154 <<
"The XDR interface is not available in this installation");
1165 for (
unsigned int i=0; i<len; i++)
1181 std::ios_base::fmtflags out_flags =
out->flags();
1186 *
out << std::scientific
1187 << std::setprecision(n_digits);
1190 for (
unsigned int i=0; i<len; i++)
1194 *
out << val[i] <<
' ';
1198 const unsigned imax = std::min(line_break, len);
1202 for (
unsigned int i=0; (i<imax && cnt<len); i++)
1219 out->flags(out_flags);
1225 libmesh_error_msg(
"Invalid mode = " <<
mode);
1232void Xdr::data_stream (std::complex<double> * val,
const unsigned int len,
const unsigned int line_break)
1240void Xdr::data_stream (std::complex<long double> * val,
const unsigned int len,
const unsigned int line_break)
1247template <
typename T>
1255#ifdef LIBMESH_HAVE_XDR
1267 std::vector<double> io_buffer (2*len);
1271 for (
unsigned int i=0, cnt=0; i<len; i++)
1273 io_buffer[cnt++] = val[i].real();
1274 io_buffer[cnt++] = val[i].imag();
1277 xdr_vector(
xdrs.get(),
1278 reinterpret_cast<char *
>(io_buffer.data()),
1281 (xdrproc_t) libmesh_xdr_double);
1285 for (
unsigned int i=0, cnt=0; i<len; i++)
1287 double re = io_buffer[cnt++];
1288 double im = io_buffer[cnt++];
1289 val[i] = std::complex<T>(re, im);
1294 libmesh_error_msg(
"ERROR: Functionality is not available.\n" \
1295 <<
"Make sure LIBMESH_HAVE_XDR is defined at build time\n" \
1296 <<
"The XDR interface is not available in this installation");
1307 for (
unsigned int i=0; i<len; i++)
1313 val[i] = std::complex<T>(re,im);
1326 std::ios_base::fmtflags out_flags =
out->flags();
1334 *
out << std::scientific
1335 << std::setprecision(std::numeric_limits<T>::max_digits10);
1338 for (
unsigned int i=0; i<len; i++)
1342 *
out << val[i].real() <<
' ' << val[i].imag() <<
' ';
1346 const unsigned imax = std::min(line_break, len);
1350 for (
unsigned int i=0; (i<imax && cnt<len); i++)
1354 *
out << val[cnt].real() <<
' ' << val[cnt].imag();
1368 out->flags(out_flags);
1374 libmesh_error_msg(
"Invalid mode = " <<
mode);
1402 *
out <<
"\t " << comment_in <<
'\n';
1407 libmesh_error_msg(
"Invalid mode = " <<
mode);
1416template LIBMESH_EXPORT
void Xdr::data<int> (
int &, std::string_view);
1417template LIBMESH_EXPORT
void Xdr::data<unsigned int> (
unsigned int &, std::string_view);
1418template LIBMESH_EXPORT
void Xdr::data<unsigned short int> (
unsigned short int &, std::string_view);
1419template LIBMESH_EXPORT
void Xdr::data<short int> (
short int &, std::string_view);
1420template LIBMESH_EXPORT
void Xdr::data<unsigned long int> (
unsigned long int &, std::string_view);
1421template LIBMESH_EXPORT
void Xdr::data<unsigned long long> (
unsigned long long &, std::string_view);
1422template LIBMESH_EXPORT
void Xdr::data<long int> (
long int &, std::string_view);
1423template LIBMESH_EXPORT
void Xdr::data<long long> (
long long &, std::string_view);
1424template LIBMESH_EXPORT
void Xdr::data<char> (
char &, std::string_view);
1425template LIBMESH_EXPORT
void Xdr::data<signed char> (
signed char &, std::string_view);
1426template LIBMESH_EXPORT
void Xdr::data<unsigned char> (
unsigned char &, std::string_view);
1427template LIBMESH_EXPORT
void Xdr::data<float> (
float &, std::string_view);
1428template LIBMESH_EXPORT
void Xdr::data<double> (
double &, std::string_view);
1429template LIBMESH_EXPORT
void Xdr::data<long double> (
long double &, std::string_view);
1430template LIBMESH_EXPORT
void Xdr::data<std::complex<float>> (std::complex<float> &, std::string_view);
1431template LIBMESH_EXPORT
void Xdr::data<std::complex<double>> (std::complex<double> &, std::string_view);
1432template LIBMESH_EXPORT
void Xdr::data<std::complex<long double>> (std::complex<long double> &, std::string_view);
1433template LIBMESH_EXPORT
void Xdr::data<std::string> (std::string &, std::string_view);
1434template LIBMESH_EXPORT
void Xdr::data<std::vector<int>> (std::vector<int> &, std::string_view);
1435template LIBMESH_EXPORT
void Xdr::data<std::vector<unsigned int>> (std::vector<unsigned int> &, std::string_view);
1436template LIBMESH_EXPORT
void Xdr::data<std::vector<short int>> (std::vector<short int> &, std::string_view);
1437template LIBMESH_EXPORT
void Xdr::data<std::vector<unsigned short int>> (std::vector<unsigned short int> &, std::string_view);
1438template LIBMESH_EXPORT
void Xdr::data<std::vector<long int>> (std::vector<long int> &, std::string_view);
1439template LIBMESH_EXPORT
void Xdr::data<std::vector<long long>> (std::vector<long long> &, std::string_view);
1440template LIBMESH_EXPORT
void Xdr::data<std::vector<unsigned long int>> (std::vector<unsigned long int> &, std::string_view);
1441template LIBMESH_EXPORT
void Xdr::data<std::vector<unsigned long long>> (std::vector<unsigned long long> &, std::string_view);
1442template LIBMESH_EXPORT
void Xdr::data<std::vector<char>> (std::vector<char> &, std::string_view);
1443template LIBMESH_EXPORT
void Xdr::data<std::vector<signed char>> (std::vector<signed char> &, std::string_view);
1444template LIBMESH_EXPORT
void Xdr::data<std::vector<unsigned char>> (std::vector<unsigned char> &, std::string_view);
1445template LIBMESH_EXPORT
void Xdr::data<std::vector<float>> (std::vector<float> &, std::string_view);
1446template LIBMESH_EXPORT
void Xdr::data<std::vector<double>> (std::vector<double> &, std::string_view);
1447template LIBMESH_EXPORT
void Xdr::data<std::vector<long double>> (std::vector<long double> &, std::string_view);
1448template LIBMESH_EXPORT
void Xdr::data<std::vector<std::complex<float>>> (std::vector<std::complex<float>> &, std::string_view);
1449template LIBMESH_EXPORT
void Xdr::data<std::vector<std::complex<double>>> (std::vector<std::complex<double>> &, std::string_view);
1450template LIBMESH_EXPORT
void Xdr::data<std::vector<std::complex<long double>>> (std::vector<std::complex<long double>> &, std::string_view);
1451template LIBMESH_EXPORT
void Xdr::data<std::vector<std::string>> (std::vector<std::string> &, std::string_view);
1452template LIBMESH_EXPORT
void Xdr::data_stream<unsigned char> (
unsigned char * val,
const unsigned int len,
const unsigned int line_break);
1453template LIBMESH_EXPORT
void Xdr::data_stream<short int> (
short int * val,
const unsigned int len,
const unsigned int line_break);
1454template LIBMESH_EXPORT
void Xdr::data_stream<int> (
int * val,
const unsigned int len,
const unsigned int line_break);
1455template LIBMESH_EXPORT
void Xdr::data_stream<long long> (
long long * val,
const unsigned int len,
const unsigned int line_break);
1456template LIBMESH_EXPORT
void Xdr::data_stream<unsigned short int> (
unsigned short int * val,
const unsigned int len,
const unsigned int line_break);
1457template LIBMESH_EXPORT
void Xdr::data_stream<unsigned int> (
unsigned int * val,
const unsigned int len,
const unsigned int line_break);
1458template LIBMESH_EXPORT
void Xdr::data_stream<unsigned long int> (
unsigned long int * val,
const unsigned int len,
const unsigned int line_break);
1459template LIBMESH_EXPORT
void Xdr::data_stream<unsigned long long> (
unsigned long long * val,
const unsigned int len,
const unsigned int line_break);
1461#ifdef LIBMESH_DEFAULT_QUADRUPLE_PRECISION
1462template LIBMESH_EXPORT
void Xdr::data<Real> (
Real &, std::string_view);
1463template LIBMESH_EXPORT
void Xdr::data<std::complex<Real>> (std::complex<Real> &, std::string_view);
1464template LIBMESH_EXPORT
void Xdr::data<std::vector<Real>> (std::vector<Real> &, std::string_view);
1465template LIBMESH_EXPORT
void Xdr::data<std::vector<std::complex<Real>>> (std::vector<std::complex<Real>> &, std::string_view);
void _xfp_data_stream(XFP *val, const unsigned int len, #ifdef LIBMESH_HAVE_XDR xdrproc_t #else void *#endif xdr_proc, const unsigned int line_break, const int n_digits)
Helper method for extended FP types.
std::string file_name
The file name.
void _complex_data_stream(std::complex< T > *val, const unsigned int len, const unsigned int line_break)
Helper method for complex types.
void data_stream(T *val, const unsigned int len, const unsigned int line_break=libMesh::invalid_uint)
Inputs or outputs a raw data stream.
const int comm_len
A buffer to put comment strings into.
Xdr(std::string name="", const XdrMODE m=UNKNOWN)
File-based constructor.
char comm[xdr_MAX_STRING_LENGTH]
const XdrMODE mode
The mode used for accessing the file.
void do_write(T &a)
Helper method for writing different data types.
void comment(std::string &)
Writes or reads (ignores) a comment line.
std::unique_ptr< XDR > xdrs
Pointer to the standard XDR struct.
bool gzipped_file
Are we reading/writing zipped files?
std::unique_ptr< std::istream > in
The input file stream.
std::unique_ptr< std::ostream > out
The output file stream.
void do_read(T &a)
Helper method for reading different data types.
void open(std::string name)
Opens the file.
void close()
Closes the file if it is open.
void data(T &a, std::string_view comment="")
Inputs or outputs a single value.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
bool ends_with(std::string_view superstring, std::string_view suffix)
Look for a substring at the very end of a string.
std::string unzip_file(std::string_view name)
Create an unzipped copy of a bz2 or xz file, returning the name of the now-unzipped file that can be ...
The libMesh namespace provides an interface to certain functionality in the library.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
XdrMODE
Defines an enum for read/write mode in Xdr format.
const unsigned int xdr_MAX_STRING_LENGTH