libMesh
|
This class implements a C++ interface to the XDR (eXternal Data Representation) format. More...
#include <xdr_cxx.h>
Public Member Functions | |
Xdr (std::string name="", const XdrMODE m=UNKNOWN) | |
File-based constructor. More... | |
Xdr (std::ostream &stream) | |
Output stream based constructor. More... | |
Xdr (std::istream &stream) | |
Input stream based constructor. More... | |
~Xdr () | |
Destructor. More... | |
void | open (std::string name) |
Opens the file. More... | |
void | close () |
Closes the file if it is open. More... | |
bool | is_open () const |
bool | is_eof () |
bool | reading () const |
bool | writing () const |
XdrMODE | access_mode () const |
template<typename T > | |
void | data (T &a, std::string_view comment="") |
Inputs or outputs a single value. More... | |
template<typename T > | |
Xdr & | operator<< (T &a) |
Same, but provides an ostream like interface. More... | |
template<typename T > | |
Xdr & | operator>> (T &a) |
Same, but provides an istream like interface. More... | |
template<typename T > | |
void | data_stream (T *val, const unsigned int len, const unsigned int line_break=libMesh::invalid_uint) |
Inputs or outputs a raw data stream. More... | |
void | comment (std::string &) |
Writes or reads (ignores) a comment line. More... | |
void | set_version (int ver) |
Sets the version of the file that is being read. More... | |
int | version () const |
Gets the version of the file that is being read. More... | |
template<> | |
void | do_read (std::string &a) |
template<> | |
void | data_stream (double *val, const unsigned int len, const unsigned int line_break) |
template<> | |
void | data_stream (float *val, const unsigned int len, const unsigned int line_break) |
template<> | |
void | data_stream (long double *val, const unsigned int len, const unsigned int line_break) |
template<> | |
void | data_stream (Real *val, const unsigned int len, const unsigned int line_break) |
template<typename XFP > | |
void | _xfp_data_stream (XFP *val, const unsigned int len, #ifdef LIBMESH_HAVE_XDR xdrproc_t xdr_proc, #else void *, #endif const unsigned int line_break, const int n_digits) |
template<> | |
void | data_stream (std::complex< double > *val, const unsigned int len, const unsigned int line_break) |
template<> | |
void | data_stream (std::complex< long double > *val, const unsigned int len, const unsigned int line_break) |
Private Member Functions | |
template<typename T > | |
void | do_read (T &a) |
Helper method for reading different data types. More... | |
template<typename T > | |
void | do_read (std::complex< T > &a) |
template<typename T > | |
void | do_read (std::vector< T > &a) |
template<typename T > | |
void | do_read (std::vector< std::complex< T >> &a) |
template<typename T > | |
void | do_write (T &a) |
Helper method for writing different data types. More... | |
template<typename T > | |
void | do_write (std::complex< T > &a) |
template<typename T > | |
void | do_write (std::vector< T > &a) |
template<typename T > | |
void | do_write (std::vector< std::complex< T >> &a) |
template<typename T > | |
void | _complex_data_stream (std::complex< T > *val, const unsigned int len, const unsigned int line_break) |
Helper method for complex types. More... | |
template<typename XFP > | |
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. More... | |
Private Attributes | |
const XdrMODE | mode |
The mode used for accessing the file. More... | |
std::string | file_name |
The file name. More... | |
std::unique_ptr< XDR > | xdrs |
Pointer to the standard XDR struct. More... | |
FILE * | fp |
File pointer. More... | |
std::unique_ptr< std::istream > | in |
The input file stream. More... | |
std::unique_ptr< std::ostream > | out |
The output file stream. More... | |
const int | comm_len |
A buffer to put comment strings into. More... | |
char | comm [xdr_MAX_STRING_LENGTH] |
bool | gzipped_file |
Are we reading/writing zipped files? More... | |
bool | bzipped_file |
bool | xzipped_file |
int | version_number |
Version of the file being read. More... | |
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
XDR is useful for creating platform-independent binary files. This class was created to handle equation system output as a replacement for XdrIO since that is somewhat limited.
File-based constructor.
Takes the filename and the mode. Valid modes are ENCODE, DECODE, READ, and WRITE.
Definition at line 105 of file xdr_cxx.C.
References file_name, and open().
libMesh::Xdr::Xdr | ( | std::ostream & | stream | ) |
Output stream based constructor.
Assumes mode WRITE.
Definition at line 125 of file xdr_cxx.C.
libMesh::Xdr::Xdr | ( | std::istream & | stream | ) |
Input stream based constructor.
Assumes mode READ.
Definition at line 143 of file xdr_cxx.C.
libMesh::Xdr::~Xdr | ( | ) |
|
private |
Helper method for complex types.
Definition at line 1168 of file xdr_cxx.C.
References libMesh::DECODE, libMesh::ENCODE, in, libMesh::invalid_uint, is_open(), libMesh::libmesh_assert(), mode, out, libMesh::READ, libMesh::WRITE, and xdrs.
Referenced by data_stream().
|
private |
Helper method for extended FP types.
Referenced by data_stream().
void libMesh::Xdr::_xfp_data_stream | ( | XFP * | val, |
const unsigned int | len, | ||
#ifdef LIBMESH_HAVE_XDR xdrproc_t | xdr_proc, | ||
#else void * | , | ||
#endif const unsigned int | line_break, | ||
const int | n_digits | ||
) |
Definition at line 1010 of file xdr_cxx.C.
References libMesh::DECODE, libMesh::ENCODE, in, libMesh::invalid_uint, is_open(), libMesh::libmesh_assert(), mode, out, libMesh::READ, libMesh::WRITE, and xdrs.
|
inline |
void libMesh::Xdr::close | ( | ) |
Closes the file if it is open.
Definition at line 279 of file xdr_cxx.C.
References bzipped_file, libMesh::DECODE, libMesh::ENCODE, file_name, fp, in, mode, out, libMesh::READ, libMesh::WRITE, xdrs, and xzipped_file.
Referenced by libMesh::RBSCMEvaluation::legacy_read_offline_data_from_files(), libMesh::RBEvaluation::legacy_read_offline_data_from_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::RBParametrized::read_parameter_ranges_from_file(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::RBParametrized::write_parameter_ranges_to_file(), and ~Xdr().
void libMesh::Xdr::comment | ( | std::string & | comment_in | ) |
Writes or reads (ignores) a comment line.
Definition at line 1300 of file xdr_cxx.C.
References comm, comm_len, libMesh::DECODE, libMesh::ENCODE, in, libMesh::libmesh_assert(), mode, out, libMesh::READ, and libMesh::WRITE.
Referenced by libMesh::System::write_serialized_data().
template LIBMESH_EXPORT void libMesh::Xdr::data< Real > | ( | T & | a, |
std::string_view | comment = "" |
||
) |
Inputs or outputs a single value.
Definition at line 780 of file xdr_cxx.C.
References libMesh::DECODE, do_read(), do_write(), libMesh::ENCODE, in, is_open(), libMesh::libmesh_assert(), mode, out, libMesh::READ, libMesh::WRITE, and xdrs.
Referenced by do_read(), do_write(), operator<<(), operator>>(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::CheckpointIO::read_bc_names(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::CheckpointIO::read_integers_names(), libMesh::System::read_legacy_data(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::System::read_parallel_data(), libMesh::CheckpointIO::read_remote_elem(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::CheckpointIO::select_split_config(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::CheckpointIO::write_bc_names(), libMesh::CheckpointIO::write_bcs(), libMesh::CheckpointIO::write_connectivity(), libMesh::System::write_header(), libMesh::CheckpointIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::CheckpointIO::write_remote_elem(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::CheckpointIO::write_subdomain_names().
void libMesh::Xdr::data_stream | ( | T * | val, |
const unsigned int | len, | ||
const unsigned int | line_break = libMesh::invalid_uint |
||
) |
Inputs or outputs a raw data stream.
Definition at line 845 of file xdr_cxx.C.
References libMesh::DECODE, libMesh::ENCODE, in, libMesh::invalid_uint, is_open(), libMesh::libmesh_assert(), mode, out, libMesh::READ, libMesh::WRITE, and xdrs.
Referenced by libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::CheckpointIO::write_connectivity(), libMesh::CheckpointIO::write_nodes(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().
void libMesh::Xdr::data_stream | ( | double * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 961 of file xdr_cxx.C.
References _xfp_data_stream().
void libMesh::Xdr::data_stream | ( | float * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 976 of file xdr_cxx.C.
References _xfp_data_stream().
void libMesh::Xdr::data_stream | ( | long double * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 991 of file xdr_cxx.C.
References _xfp_data_stream().
void libMesh::Xdr::data_stream | ( | Real * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 1001 of file xdr_cxx.C.
References _xfp_data_stream().
void libMesh::Xdr::data_stream | ( | std::complex< double > * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 1152 of file xdr_cxx.C.
References _complex_data_stream().
void libMesh::Xdr::data_stream | ( | std::complex< long double > * | val, |
const unsigned int | len, | ||
const unsigned int | line_break | ||
) |
Definition at line 1160 of file xdr_cxx.C.
References _complex_data_stream().
|
private |
|
private |
|
private |
Definition at line 697 of file xdr_cxx.C.
References comm, comm_len, data(), in, and libMesh::libmesh_assert().
|
private |
Definition at line 713 of file xdr_cxx.C.
References comm, comm_len, data(), in, and libMesh::libmesh_assert().
void libMesh::Xdr::do_read | ( | std::string & | a | ) |
|
private |
Helper method for writing different data types.
Definition at line 731 of file xdr_cxx.C.
References out.
Referenced by data(), and do_write().
|
private |
Definition at line 734 of file xdr_cxx.C.
References out.
|
private |
Definition at line 740 of file xdr_cxx.C.
References data(), do_write(), libMesh::libmesh_assert(), and out.
|
private |
Definition at line 759 of file xdr_cxx.C.
References data(), do_write(), libMesh::libmesh_assert(), and out.
bool libMesh::Xdr::is_eof | ( | ) |
true
if the Xdr file being read is at End-Of-File.Definition at line 397 of file xdr_cxx.C.
References libMesh::DECODE, libMesh::ENCODE, fp, in, libMesh::libmesh_assert(), mode, libMesh::MeshTools::Subdivision::next, and libMesh::READ.
bool libMesh::Xdr::is_open | ( | ) | const |
true
if the Xdr file is open, false if it is closed. Definition at line 347 of file xdr_cxx.C.
References libMesh::DECODE, libMesh::ENCODE, fp, in, mode, out, libMesh::READ, libMesh::WRITE, and xdrs.
Referenced by _complex_data_stream(), _xfp_data_stream(), data(), data_stream(), and libMesh::System::read_parallel_data().
void libMesh::Xdr::open | ( | std::string | name | ) |
Opens the file.
Definition at line 168 of file xdr_cxx.C.
References bzipped_file, libMesh::DECODE, libMesh::ENCODE, file_name, fp, gzipped_file, in, libMesh::libmesh_assert(), mode, libMesh::Quality::name(), libMesh::out, out, libMesh::READ, libMesh::Utility::unzip_file(), libMesh::WRITE, xdrs, and xzipped_file.
Referenced by Xdr().
|
inline |
Same, but provides an ostream
like interface.
Definition at line 149 of file xdr_cxx.h.
References data(), libMesh::libmesh_assert(), and writing().
|
inline |
Same, but provides an istream
like interface.
Definition at line 155 of file xdr_cxx.h.
References data(), libMesh::libmesh_assert(), and reading().
|
inline |
true
if the file is opened in a reading state, false otherwise. Definition at line 123 of file xdr_cxx.h.
References libMesh::DECODE, mode, and libMesh::READ.
Referenced by operator>>(), libMesh::EquationSystems::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::System::read_serialized_vector(), and libMesh::System::read_serialized_vectors().
|
inline |
Sets the version of the file that is being read.
Definition at line 171 of file xdr_cxx.h.
References version_number.
Referenced by libMesh::EquationSystems::read(), and libMesh::EquationSystems::write().
|
inline |
Gets the version of the file that is being read.
Definition at line 176 of file xdr_cxx.h.
References version_number.
Referenced by libMesh::System::read_header(), and libMesh::System::read_serialized_vector().
|
inline |
true
if the file is opened in a writing state, false otherwise. Definition at line 129 of file xdr_cxx.h.
References libMesh::ENCODE, mode, and libMesh::WRITE.
Referenced by operator<<(), libMesh::EquationSystems::write(), libMesh::CheckpointIO::write_bcs(), libMesh::CheckpointIO::write_connectivity(), libMesh::System::write_header(), libMesh::CheckpointIO::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::CheckpointIO::write_remote_elem(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
The input file stream.
Definition at line 259 of file xdr_cxx.h.
Referenced by _complex_data_stream(), _xfp_data_stream(), close(), comment(), data(), data_stream(), do_read(), is_eof(), is_open(), and open().
|
private |
The mode used for accessing the file.
Definition at line 234 of file xdr_cxx.h.
Referenced by _complex_data_stream(), _xfp_data_stream(), access_mode(), close(), comment(), data(), data_stream(), is_eof(), is_open(), open(), reading(), and writing().
|
private |
The output file stream.
Definition at line 264 of file xdr_cxx.h.
Referenced by _complex_data_stream(), _xfp_data_stream(), close(), comment(), data(), data_stream(), do_write(), is_open(), and open().
|
private |
Version of the file being read.
Definition at line 280 of file xdr_cxx.h.
Referenced by set_version(), and version().
|
private |
Pointer to the standard XDR struct.
See the standard header file rpc/rpc.h for more information.
Definition at line 247 of file xdr_cxx.h.
Referenced by _complex_data_stream(), _xfp_data_stream(), close(), data(), data_stream(), is_open(), and open().
|
private |