📄 xdr_cxx.c
字号:
#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); double _r, _i; *in >> _r; *in >> _i; a = std::complex<double>(_r,_i); in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); *out << a.real() << "\t " << a.imag() << "\t " << comment << '\n'; return; } default: libmesh_error(); }}#endif // USE_COMPLEX_NUMBERSvoid Xdr::data (std::vector<int>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length = v.size(); data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(int), (xdrproc_t) xdr_int); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length=0; data(length, "# vector length"); v.resize(length); xdr_vector(xdrs, (char*) &v[0], length, sizeof(int), (xdrproc_t) xdr_int); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; data(length, "# vector length"); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i]; } in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); unsigned int length=v.size(); data(length, "# vector length"); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); *out << v[i] << " "; } *out << "\t " << comment << '\n'; return; } default: libmesh_error(); }}void Xdr::data (std::vector<unsigned int>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length = v.size(); data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(unsigned int), (xdrproc_t) xdr_u_int); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length=0; data(length, "# vector length"); v.resize(length); xdr_vector(xdrs, (char*) &v[0], length, sizeof(unsigned int), (xdrproc_t) xdr_u_int);#else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; data(length, "# vector length"); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i]; } in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); unsigned int length=v.size(); data(length, "# vector length"); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); *out << v[i] << " "; } *out << "\t " << comment << '\n'; return; } default: libmesh_error(); }}void Xdr::data (std::vector<short int>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length = v.size(); data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(short int), (xdrproc_t) xdr_short); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length=0; data(length, "# vector length"); v.resize(length); xdr_vector(xdrs, (char*) &v[0], length, sizeof(short int), (xdrproc_t) xdr_short); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; data(length, "# vector length"); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i]; } in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); unsigned int length=v.size(); data(length, "# vector length"); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); *out << v[i] << " "; } *out << "\t " << comment << '\n'; return; } default: libmesh_error(); }}void Xdr::data (std::vector<unsigned short int>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length = v.size(); data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(unsigned short int), (xdrproc_t) xdr_u_short);#else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length=0; data(length, "# vector length"); v.resize(length); xdr_vector(xdrs, (char*) &v[0], length, sizeof(unsigned short int), (xdrproc_t) xdr_u_short); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; data(length, "# vector length"); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i]; } in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); unsigned int length=v.size(); data(length, "# vector length"); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); *out << v[i] << " "; } *out << "\t " << comment << '\n'; return; } default: libmesh_error(); }}void Xdr::data (std::vector<float>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length = v.size(); data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(float), (xdrproc_t) xdr_float);#else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (is_open()); unsigned int length=0; data(length, "# vector length"); v.resize(length); xdr_vector(xdrs, (char*) &v[0], length, sizeof(float), (xdrproc_t) xdr_float); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; data(length, "# vector length"); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i]; } in->getline(comm, comm_len); return; } case WRITE: { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); unsigned int length=v.size(); data(length, "# vector length"); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); OFSRealscientific(*out,17,v[i]) << " "; } *out << "\t " << comment << '\n'; return; } default: libmesh_error(); }}void Xdr::data (std::vector<double>& v, const char* comment){ switch (mode) { case ENCODE: {#ifdef HAVE_XDR libmesh_assert (this->is_open()); unsigned int length = v.size(); this->data(length, "# vector length"); xdr_vector(xdrs, (char*) &v[0], length, sizeof(double), (xdrproc_t) xdr_double);#else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case DECODE: {#ifdef HAVE_XDR libmesh_assert (this->is_open()); unsigned int length=0; this->data(length, "# vector length"); v.resize(length); // Note: GCC 3.4.1 will crash in debug mode here if length // is zero and you attempt to access the zeroth index of v. if (length > 0) xdr_vector(xdrs, (char*) &v[0], length, sizeof(double), (xdrproc_t) xdr_double); #else std::cerr << "ERROR: Functionality is not available." << std::endl << "Make sure HAVE_XDR is defined at build time" << std::endl << "The XDR interface is not available in this installation" << std::endl; libmesh_error();#endif return; } case READ: { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); unsigned int length=0; this->data(length, "# vector length"); // If you were expecting to read in a vector at this // point, it's not going to happen if length == 0! // libmesh_assert (length != 0); v.resize(length); for (unsigned int i=0; i<v.size(); i++) { libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); *in >> v[i];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -