Xdr Class Reference
#include <xdr_cxx.h>
Public Member Functions | |
| Xdr (const std::string &name="", const libMeshEnums::XdrMODE m=UNKNOWN) | |
| ~Xdr () | |
| void | open (const std::string &name) |
| void | close () |
| bool | is_open () const |
| bool | reading () const |
| bool | writing () const |
| XdrMODE | access_mode () const |
| void | data (int &a, const char *comment="") |
| Xdr & | operator<< (int &a) |
| Xdr & | operator>> (int &a) |
| void | data (unsigned int &a, const char *comment="") |
| Xdr & | operator<< (unsigned int &a) |
| Xdr & | operator>> (unsigned int &a) |
| void | data (short int &a, const char *comment="") |
| Xdr & | operator<< (short int &a) |
| Xdr & | operator>> (short int &a) |
| void | data (unsigned short int &a, const char *comment="") |
| Xdr & | operator<< (unsigned short int &a) |
| Xdr & | operator>> (unsigned short int &a) |
| void | data (float &a, const char *comment="") |
| Xdr & | operator<< (float &a) |
| Xdr & | operator>> (float &a) |
| void | data (double &a, const char *comment="") |
| Xdr & | operator<< (double &a) |
| Xdr & | operator>> (double &a) |
| void | data (long double &a, const char *comment="") |
| Xdr & | operator<< (long double &a) |
| Xdr & | operator>> (long double &a) |
| void | data (std::complex< double > &a, const char *comment="") |
| Xdr & | operator<< (std::complex< double > &a) |
| Xdr & | operator>> (std::complex< double > &a) |
| void | data (std::complex< long double > &a, const char *comment="") |
| Xdr & | operator<< (std::complex< long double > &a) |
| Xdr & | operator>> (std::complex< long double > &a) |
| void | data (std::vector< int > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< int > &v) |
| Xdr & | operator>> (std::vector< int > &v) |
| void | data (std::vector< unsigned int > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< unsigned int > &v) |
| Xdr & | operator>> (std::vector< unsigned int > &v) |
| void | data (std::vector< short int > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< short int > &v) |
| Xdr & | operator>> (std::vector< short int > &v) |
| void | data (std::vector< unsigned short int > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< unsigned short int > &v) |
| Xdr & | operator>> (std::vector< unsigned short int > &v) |
| void | data (std::vector< float > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< float > &v) |
| Xdr & | operator>> (std::vector< float > &v) |
| void | data (std::vector< double > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< double > &v) |
| Xdr & | operator>> (std::vector< double > &v) |
| void | data (std::vector< long double > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< long double > &v) |
| Xdr & | operator>> (std::vector< long double > &v) |
| void | data (std::vector< std::complex< double > > &v, const char *comment="") |
| Xdr & | operator<< (std::vector< std::complex< double > > &v) |
| Xdr & | operator>> (std::vector< std::complex< double > > &v) |
| void | data (std::string &s, const char *comment="") |
| Xdr & | operator<< (std::string &v) |
| Xdr & | operator>> (std::string &v) |
| template<typename T > | |
| void | data_stream (T *val, const unsigned int len, const unsigned int line_break=libMesh::invalid_uint) |
| void | comment (std::string &) |
| template<> | |
| void | data_stream (double *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 (std::complex< double > *val, const unsigned int len, const unsigned int line_break) |
Private Attributes | |
| const XdrMODE | mode |
| std::string | file_name |
| XDR * | xdrs |
| FILE * | fp |
| AutoPtr< std::istream > | in |
| AutoPtr< std::ostream > | out |
| const int | comm_len |
| char | comm [xdr_MAX_STRING_LENGTH] |
| bool | gzipped_file |
| bool | bzipped_file |
Detailed Description
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.Definition at line 64 of file xdr_cxx.h.
Constructor & Destructor Documentation
| Xdr::Xdr | ( | const std::string & | name = "", |
|
| const libMeshEnums::XdrMODE | m = UNKNOWN | |||
| ) |
Constructor. Takes the filename and the mode. Valid modes are ENCODE, DECODE, READ, and WRITE.
| Xdr::~Xdr | ( | ) |
Member Function Documentation
| XdrMODE Xdr::access_mode | ( | ) | const [inline] |
| void Xdr::close | ( | ) |
Closes the file if it is open.
Definition at line 233 of file xdr_cxx.C.
References bzipped_file, libMeshEnums::DECODE, libMeshEnums::ENCODE, file_name, fp, AutoPtr< Tp >::get(), in, mode, out, libMeshEnums::READ, remove_unzipped_file(), AutoPtr< Tp >::reset(), libMeshEnums::WRITE, xdrs, and zip_file().
Referenced by EquationSystems::_read_impl(), XdrIO::read(), XdrIO::write(), and ~Xdr().
00234 { 00235 switch (mode) 00236 { 00237 case ENCODE: 00238 case DECODE: 00239 { 00240 #ifdef LIBMESH_HAVE_XDR 00241 00242 if (xdrs) 00243 { 00244 xdr_destroy (xdrs); 00245 delete xdrs; 00246 xdrs = NULL; 00247 } 00248 00249 if (fp) 00250 { 00251 fflush(fp); 00252 fclose(fp); 00253 fp = NULL; 00254 } 00255 #else 00256 00257 std::cerr << "ERROR: Functionality is not available." << std::endl 00258 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00259 << std::endl 00260 << "The XDR interface is not available in this installation" 00261 << std::endl; 00262 00263 libmesh_error(); 00264 00265 #endif 00266 file_name = ""; 00267 return; 00268 } 00269 00270 case READ: 00271 { 00272 if (in.get() != NULL) 00273 { 00274 in.reset(); 00275 00276 if (bzipped_file) 00277 remove_unzipped_file(file_name); 00278 } 00279 file_name = ""; 00280 return; 00281 } 00282 00283 case WRITE: 00284 { 00285 if (out.get() != NULL) 00286 { 00287 out.reset(); 00288 00289 if (bzipped_file) 00290 zip_file(std::string(file_name.begin(), file_name.end()-4)); 00291 } 00292 file_name = ""; 00293 return; 00294 } 00295 00296 default: 00297 libmesh_error(); 00298 } 00299 }
| void Xdr::comment | ( | std::string & | comment | ) |
Writes or reads (ignores) a comment line.
Definition at line 2037 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, mode, out, libMeshEnums::READ, and libMeshEnums::WRITE.
Referenced by data(), System::read_serialized_data(), and System::write_serialized_data().
02038 { 02039 switch (mode) 02040 { 02041 case ENCODE: 02042 case DECODE: 02043 { 02044 return; 02045 } 02046 02047 case READ: 02048 { 02049 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 02050 in->getline(comm, comm_len); 02051 return; 02052 } 02053 02054 case WRITE: 02055 { 02056 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 02057 *out << "\t " << comment << '\n'; 02058 return; 02059 } 02060 02061 default: 02062 libmesh_error(); 02063 } 02064 }
| void Xdr::data | ( | std::string & | s, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single string.
Definition at line 1543 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01544 { 01545 switch (mode) 01546 { 01547 case ENCODE: 01548 { 01549 #ifdef LIBMESH_HAVE_XDR 01550 01551 libmesh_assert (is_open()); 01552 01553 { 01554 char* sptr = new char[s.size()+1]; 01555 01556 for (unsigned int c=0; c<s.size(); c++) 01557 sptr[c] = s[c]; 01558 01559 sptr[s.size()] = '\0'; 01560 01561 xdr_string(xdrs, 01562 &sptr, 01563 std::strlen(sptr)); 01564 01565 delete [] sptr; 01566 } 01567 01568 #else 01569 01570 std::cerr << "ERROR: Functionality is not available." << std::endl 01571 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01572 << std::endl 01573 << "The XDR interface is not available in this installation" 01574 << std::endl; 01575 01576 libmesh_error(); 01577 01578 #endif 01579 return; 01580 } 01581 01582 case DECODE: 01583 { 01584 #ifdef LIBMESH_HAVE_XDR 01585 01586 libmesh_assert (is_open()); 01587 01588 { 01589 char* sptr = new char[xdr_MAX_STRING_LENGTH]; 01590 01591 xdr_string(xdrs, 01592 &sptr, 01593 xdr_MAX_STRING_LENGTH); 01594 01595 s.resize(std::strlen(sptr)); 01596 01597 for (unsigned int c=0; c<s.size(); c++) 01598 s[c] = sptr[c]; 01599 01600 delete [] sptr; 01601 } 01602 01603 #else 01604 01605 std::cerr << "ERROR: Functionality is not available." << std::endl 01606 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01607 << std::endl 01608 << "The XDR interface is not available in this installation" 01609 << std::endl; 01610 01611 libmesh_error(); 01612 01613 #endif 01614 return; 01615 } 01616 01617 case READ: 01618 { 01619 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01620 01621 in->getline(comm, comm_len); 01622 01623 //#ifndef LIBMESH_BROKEN_IOSTREAM 01624 // s.clear(); 01625 //#else 01626 s = ""; 01627 //#endif 01628 01629 for (unsigned int c=0; c<std::strlen(comm); c++) 01630 { 01631 if (comm[c] == '\t') 01632 break; 01633 01634 s.push_back(comm[c]); 01635 } 01636 01637 return; 01638 } 01639 01640 case WRITE: 01641 { 01642 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01643 01644 *out << s << "\t " << comment << '\n'; 01645 01646 return; 01647 } 01648 01649 default: 01650 libmesh_error(); 01651 } 01652 }
| void Xdr::data | ( | std::vector< std::complex< double > > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of complex<double>.
Definition at line 1425 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, and libMeshEnums::WRITE.
01426 { 01427 switch (mode) 01428 { 01429 case ENCODE: 01430 { 01431 #ifdef LIBMESH_HAVE_XDR 01432 01433 libmesh_assert (is_open()); 01434 01435 unsigned int length = v.size(); 01436 01437 data(length, "# vector length x 2 (complex)"); 01438 01439 std::vector< std::complex<double> >::iterator iter = v.begin(); 01440 01441 for (; iter != v.end(); ++iter) 01442 data(*iter, ""); 01443 01444 #else 01445 01446 std::cerr << "ERROR: Functionality is not available." << std::endl 01447 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01448 << std::endl 01449 << "The XDR interface is not available in this installation" 01450 << std::endl; 01451 01452 libmesh_error(); 01453 01454 #endif 01455 return; 01456 } 01457 01458 case DECODE: 01459 { 01460 #ifdef LIBMESH_HAVE_XDR 01461 01462 libmesh_assert (is_open()); 01463 01464 unsigned int length=0; 01465 01466 data(length, "# vector length x 2 (complex)"); 01467 01468 v.resize(length); 01469 01470 std::vector< std::complex<double> >::iterator iter = v.begin(); 01471 01472 for (; iter != v.end(); ++iter) 01473 data(*iter, ""); 01474 01475 #else 01476 01477 std::cerr << "ERROR: Functionality is not available." << std::endl 01478 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01479 << std::endl 01480 << "The XDR interface is not available in this installation" 01481 << std::endl; 01482 01483 libmesh_error(); 01484 01485 #endif 01486 return; 01487 } 01488 01489 case READ: 01490 { 01491 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01492 01493 unsigned int length=0; 01494 01495 data(length, "# vector length x 2 (complex)"); 01496 01497 v.resize(length); 01498 01499 for (unsigned int i=0; i<v.size(); i++) 01500 { 01501 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01502 01503 double _r, _i; 01504 *in >> _r; 01505 *in >> _i; 01506 v[i] = std::complex<double>(_r,_i); 01507 } 01508 01509 in->getline(comm, comm_len); 01510 01511 return; 01512 } 01513 01514 case WRITE: 01515 { 01516 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01517 01518 unsigned int length=v.size(); 01519 01520 data(length, "# vector length x 2 (complex)"); 01521 01522 for (unsigned int i=0; i<v.size(); i++) 01523 { 01524 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01525 OFSNumberscientific(*out,17,v[i]) << " "; 01526 } 01527 01528 *out << "\t " << comment << '\n'; 01529 01530 return; 01531 } 01532 01533 default: 01534 libmesh_error(); 01535 } 01536 }
| void Xdr::data | ( | std::vector< long double > & | v, | |
| const char * | comment = "" | |||
| ) | [inline] |
Inputs or outputs a vector of long doubles, but in double precision.
Definition at line 356 of file xdr_cxx.h.
References comment(), and data().
00357 { std::vector<double> vd(v.size()); 00358 for (unsigned int i = 0; i != v.size(); ++i) 00359 vd[i] = static_cast<double>(v[i]); 00360 data(vd, comment); 00361 v.resize(vd.size()); 00362 for (unsigned int i = 0; i != vd.size(); ++i) 00363 v[i] = static_cast<long double>(vd[i]); 00364 }
| void Xdr::data | ( | std::vector< double > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of doubles.
Definition at line 1300 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01301 { 01302 switch (mode) 01303 { 01304 case ENCODE: 01305 { 01306 #ifdef LIBMESH_HAVE_XDR 01307 01308 libmesh_assert (this->is_open()); 01309 01310 unsigned int length = v.size(); 01311 01312 this->data(length, "# vector length"); 01313 01314 xdr_vector(xdrs, 01315 (char*) &v[0], 01316 length, 01317 sizeof(double), 01318 (xdrproc_t) xdr_double); 01319 01320 #else 01321 01322 std::cerr << "ERROR: Functionality is not available." << std::endl 01323 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01324 << std::endl 01325 << "The XDR interface is not available in this installation" 01326 << std::endl; 01327 01328 libmesh_error(); 01329 01330 #endif 01331 return; 01332 } 01333 01334 case DECODE: 01335 { 01336 #ifdef LIBMESH_HAVE_XDR 01337 01338 libmesh_assert (this->is_open()); 01339 01340 unsigned int length=0; 01341 01342 this->data(length, "# vector length"); 01343 01344 v.resize(length); 01345 01346 // Note: GCC 3.4.1 will crash in debug mode here if length 01347 // is zero and you attempt to access the zeroth index of v. 01348 if (length > 0) 01349 xdr_vector(xdrs, 01350 (char*) &v[0], 01351 length, 01352 sizeof(double), 01353 (xdrproc_t) xdr_double); 01354 01355 #else 01356 01357 std::cerr << "ERROR: Functionality is not available." << std::endl 01358 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01359 << std::endl 01360 << "The XDR interface is not available in this installation" 01361 << std::endl; 01362 01363 libmesh_error(); 01364 01365 #endif 01366 return; 01367 } 01368 01369 case READ: 01370 { 01371 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01372 01373 unsigned int length=0; 01374 01375 this->data(length, "# vector length"); 01376 01377 // If you were expecting to read in a vector at this 01378 // point, it's not going to happen if length == 0! 01379 // libmesh_assert (length != 0); 01380 01381 v.resize(length); 01382 01383 for (unsigned int i=0; i<v.size(); i++) 01384 { 01385 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01386 *in >> v[i]; 01387 } 01388 01389 in->getline(comm, comm_len); 01390 01391 return; 01392 } 01393 01394 case WRITE: 01395 { 01396 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01397 01398 unsigned int length=v.size(); 01399 01400 data(length, "# vector length"); 01401 01402 for (unsigned int i=0; i<v.size(); i++) 01403 { 01404 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01405 OFSRealscientific(*out,17,v[i]) << " "; 01406 } 01407 01408 01409 01410 *out << "\t " << comment << '\n'; 01411 01412 return; 01413 } 01414 01415 default: 01416 libmesh_error(); 01417 } 01418 }
| void Xdr::data | ( | std::vector< float > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of floats.
Definition at line 1187 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01188 { 01189 switch (mode) 01190 { 01191 case ENCODE: 01192 { 01193 #ifdef LIBMESH_HAVE_XDR 01194 01195 libmesh_assert (is_open()); 01196 01197 unsigned int length = v.size(); 01198 01199 data(length, "# vector length"); 01200 01201 xdr_vector(xdrs, 01202 (char*) &v[0], 01203 length, 01204 sizeof(float), 01205 (xdrproc_t) xdr_float); 01206 01207 #else 01208 01209 std::cerr << "ERROR: Functionality is not available." << std::endl 01210 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01211 << std::endl 01212 << "The XDR interface is not available in this installation" 01213 << std::endl; 01214 01215 libmesh_error(); 01216 01217 #endif 01218 return; 01219 } 01220 01221 case DECODE: 01222 { 01223 #ifdef LIBMESH_HAVE_XDR 01224 01225 libmesh_assert (is_open()); 01226 01227 unsigned int length=0; 01228 01229 data(length, "# vector length"); 01230 01231 v.resize(length); 01232 01233 xdr_vector(xdrs, 01234 (char*) &v[0], 01235 length, 01236 sizeof(float), 01237 (xdrproc_t) xdr_float); 01238 01239 #else 01240 01241 std::cerr << "ERROR: Functionality is not available." << std::endl 01242 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01243 << std::endl 01244 << "The XDR interface is not available in this installation" 01245 << std::endl; 01246 01247 libmesh_error(); 01248 01249 #endif 01250 return; 01251 } 01252 01253 case READ: 01254 { 01255 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01256 01257 unsigned int length=0; 01258 01259 data(length, "# vector length"); 01260 01261 v.resize(length); 01262 01263 for (unsigned int i=0; i<v.size(); i++) 01264 { 01265 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01266 *in >> v[i]; 01267 } 01268 01269 in->getline(comm, comm_len); 01270 01271 return; 01272 } 01273 01274 case WRITE: 01275 { 01276 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01277 01278 unsigned int length=v.size(); 01279 01280 data(length, "# vector length"); 01281 01282 for (unsigned int i=0; i<v.size(); i++) 01283 { 01284 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01285 OFSRealscientific(*out,17,v[i]) << " "; 01286 } 01287 01288 *out << "\t " << comment << '\n'; 01289 01290 return; 01291 } 01292 01293 default: 01294 libmesh_error(); 01295 } 01296 }
| void Xdr::data | ( | std::vector< unsigned short int > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of unsigned short integers.
Definition at line 1074 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01075 { 01076 switch (mode) 01077 { 01078 case ENCODE: 01079 { 01080 #ifdef LIBMESH_HAVE_XDR 01081 01082 libmesh_assert (is_open()); 01083 01084 unsigned int length = v.size(); 01085 01086 data(length, "# vector length"); 01087 01088 xdr_vector(xdrs, 01089 (char*) &v[0], 01090 length, 01091 sizeof(unsigned short int), 01092 (xdrproc_t) xdr_u_short); 01093 01094 #else 01095 01096 std::cerr << "ERROR: Functionality is not available." << std::endl 01097 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01098 << std::endl 01099 << "The XDR interface is not available in this installation" 01100 << std::endl; 01101 01102 libmesh_error(); 01103 01104 #endif 01105 return; 01106 } 01107 01108 case DECODE: 01109 { 01110 #ifdef LIBMESH_HAVE_XDR 01111 01112 libmesh_assert (is_open()); 01113 01114 unsigned int length=0; 01115 01116 data(length, "# vector length"); 01117 01118 v.resize(length); 01119 01120 xdr_vector(xdrs, 01121 (char*) &v[0], 01122 length, 01123 sizeof(unsigned short int), 01124 (xdrproc_t) xdr_u_short); 01125 01126 #else 01127 01128 std::cerr << "ERROR: Functionality is not available." << std::endl 01129 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01130 << std::endl 01131 << "The XDR interface is not available in this installation" 01132 << std::endl; 01133 01134 libmesh_error(); 01135 01136 #endif 01137 return; 01138 } 01139 01140 case READ: 01141 { 01142 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01143 01144 unsigned int length=0; 01145 01146 data(length, "# vector length"); 01147 01148 v.resize(length); 01149 01150 for (unsigned int i=0; i<v.size(); i++) 01151 { 01152 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01153 *in >> v[i]; 01154 } 01155 01156 in->getline(comm, comm_len); 01157 01158 return; 01159 } 01160 01161 case WRITE: 01162 { 01163 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01164 01165 unsigned int length=v.size(); 01166 01167 data(length, "# vector length"); 01168 01169 for (unsigned int i=0; i<v.size(); i++) 01170 { 01171 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01172 *out << v[i] << " "; 01173 } 01174 01175 *out << "\t " << comment << '\n'; 01176 01177 return; 01178 } 01179 01180 default: 01181 libmesh_error(); 01182 } 01183 }
| void Xdr::data | ( | std::vector< short int > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of short integers.
Definition at line 961 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00962 { 00963 switch (mode) 00964 { 00965 case ENCODE: 00966 { 00967 #ifdef LIBMESH_HAVE_XDR 00968 00969 libmesh_assert (is_open()); 00970 00971 unsigned int length = v.size(); 00972 00973 data(length, "# vector length"); 00974 00975 xdr_vector(xdrs, 00976 (char*) &v[0], 00977 length, 00978 sizeof(short int), 00979 (xdrproc_t) xdr_short); 00980 00981 #else 00982 00983 std::cerr << "ERROR: Functionality is not available." << std::endl 00984 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00985 << std::endl 00986 << "The XDR interface is not available in this installation" 00987 << std::endl; 00988 00989 libmesh_error(); 00990 00991 #endif 00992 return; 00993 } 00994 00995 case DECODE: 00996 { 00997 #ifdef LIBMESH_HAVE_XDR 00998 00999 libmesh_assert (is_open()); 01000 01001 unsigned int length=0; 01002 01003 data(length, "# vector length"); 01004 01005 v.resize(length); 01006 01007 xdr_vector(xdrs, 01008 (char*) &v[0], 01009 length, 01010 sizeof(short int), 01011 (xdrproc_t) xdr_short); 01012 01013 #else 01014 01015 std::cerr << "ERROR: Functionality is not available." << std::endl 01016 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01017 << std::endl 01018 << "The XDR interface is not available in this installation" 01019 << std::endl; 01020 01021 libmesh_error(); 01022 01023 #endif 01024 return; 01025 } 01026 01027 case READ: 01028 { 01029 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01030 01031 unsigned int length=0; 01032 01033 data(length, "# vector length"); 01034 01035 v.resize(length); 01036 01037 for (unsigned int i=0; i<v.size(); i++) 01038 { 01039 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01040 *in >> v[i]; 01041 } 01042 01043 in->getline(comm, comm_len); 01044 01045 return; 01046 } 01047 01048 case WRITE: 01049 { 01050 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01051 01052 unsigned int length=v.size(); 01053 01054 data(length, "# vector length"); 01055 01056 for (unsigned int i=0; i<v.size(); i++) 01057 { 01058 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01059 *out << v[i] << " "; 01060 } 01061 01062 *out << "\t " << comment << '\n'; 01063 01064 return; 01065 } 01066 01067 default: 01068 libmesh_error(); 01069 } 01070 }
| void Xdr::data | ( | std::vector< unsigned int > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of unsigned integers.
Definition at line 848 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00849 { 00850 switch (mode) 00851 { 00852 case ENCODE: 00853 { 00854 #ifdef LIBMESH_HAVE_XDR 00855 00856 libmesh_assert (is_open()); 00857 00858 unsigned int length = v.size(); 00859 00860 data(length, "# vector length"); 00861 00862 xdr_vector(xdrs, 00863 (char*) &v[0], 00864 length, 00865 sizeof(unsigned int), 00866 (xdrproc_t) xdr_u_int); 00867 00868 #else 00869 00870 std::cerr << "ERROR: Functionality is not available." << std::endl 00871 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00872 << std::endl 00873 << "The XDR interface is not available in this installation" 00874 << std::endl; 00875 00876 libmesh_error(); 00877 00878 #endif 00879 return; 00880 } 00881 00882 case DECODE: 00883 { 00884 #ifdef LIBMESH_HAVE_XDR 00885 00886 libmesh_assert (is_open()); 00887 00888 unsigned int length=0; 00889 00890 data(length, "# vector length"); 00891 00892 v.resize(length); 00893 00894 xdr_vector(xdrs, 00895 (char*) &v[0], 00896 length, 00897 sizeof(unsigned int), 00898 (xdrproc_t) xdr_u_int); 00899 00900 #else 00901 00902 std::cerr << "ERROR: Functionality is not available." << std::endl 00903 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00904 << std::endl 00905 << "The XDR interface is not available in this installation" 00906 << std::endl; 00907 00908 libmesh_error(); 00909 00910 #endif 00911 return; 00912 } 00913 00914 case READ: 00915 { 00916 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00917 00918 unsigned int length=0; 00919 00920 data(length, "# vector length"); 00921 00922 v.resize(length); 00923 00924 for (unsigned int i=0; i<v.size(); i++) 00925 { 00926 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00927 *in >> v[i]; 00928 } 00929 00930 in->getline(comm, comm_len); 00931 00932 return; 00933 } 00934 00935 case WRITE: 00936 { 00937 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00938 00939 unsigned int length=v.size(); 00940 00941 data(length, "# vector length"); 00942 00943 for (unsigned int i=0; i<v.size(); i++) 00944 { 00945 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00946 *out << v[i] << " "; 00947 } 00948 00949 *out << "\t " << comment << '\n'; 00950 00951 return; 00952 } 00953 00954 default: 00955 libmesh_error(); 00956 } 00957 }
| void Xdr::data | ( | std::vector< int > & | v, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a vector of integers.
Definition at line 735 of file xdr_cxx.C.
References comm, comm_len, data(), libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00736 { 00737 switch (mode) 00738 { 00739 case ENCODE: 00740 { 00741 #ifdef LIBMESH_HAVE_XDR 00742 00743 libmesh_assert (is_open()); 00744 00745 unsigned int length = v.size(); 00746 00747 data(length, "# vector length"); 00748 00749 xdr_vector(xdrs, 00750 (char*) &v[0], 00751 length, 00752 sizeof(int), 00753 (xdrproc_t) xdr_int); 00754 00755 #else 00756 00757 std::cerr << "ERROR: Functionality is not available." << std::endl 00758 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00759 << std::endl 00760 << "The XDR interface is not available in this installation" 00761 << std::endl; 00762 00763 libmesh_error(); 00764 00765 #endif 00766 return; 00767 } 00768 00769 case DECODE: 00770 { 00771 #ifdef LIBMESH_HAVE_XDR 00772 00773 libmesh_assert (is_open()); 00774 00775 unsigned int length=0; 00776 00777 data(length, "# vector length"); 00778 00779 v.resize(length); 00780 00781 xdr_vector(xdrs, 00782 (char*) &v[0], 00783 length, 00784 sizeof(int), 00785 (xdrproc_t) xdr_int); 00786 00787 #else 00788 00789 std::cerr << "ERROR: Functionality is not available." << std::endl 00790 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00791 << std::endl 00792 << "The XDR interface is not available in this installation" 00793 << std::endl; 00794 00795 libmesh_error(); 00796 00797 #endif 00798 return; 00799 } 00800 00801 case READ: 00802 { 00803 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00804 00805 unsigned int length=0; 00806 00807 data(length, "# vector length"); 00808 00809 v.resize(length); 00810 00811 for (unsigned int i=0; i<v.size(); i++) 00812 { 00813 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00814 *in >> v[i]; 00815 } 00816 00817 in->getline(comm, comm_len); 00818 00819 return; 00820 } 00821 00822 case WRITE: 00823 { 00824 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00825 00826 unsigned int length=v.size(); 00827 00828 data(length, "# vector length"); 00829 00830 for (unsigned int i=0; i<v.size(); i++) 00831 { 00832 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00833 *out << v[i] << " "; 00834 } 00835 00836 *out << "\t " << comment << '\n'; 00837 00838 return; 00839 } 00840 00841 default: 00842 libmesh_error(); 00843 } 00844 }
| void Xdr::data | ( | std::complex< long double > & | a, | |
| const char * | comment = "" | |||
| ) | [inline] |
| void Xdr::data | ( | std::complex< double > & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single complex<double>.
Definition at line 671 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00672 { 00673 switch (mode) 00674 { 00675 case ENCODE: 00676 case DECODE: 00677 { 00678 #ifdef LIBMESH_HAVE_XDR 00679 00680 libmesh_assert (is_open()); 00681 double 00682 _r=a.real(), 00683 _i=a.imag(); 00684 xdr_double(xdrs, &_r); 00685 xdr_double(xdrs, &_i); 00686 a = std::complex<double>(_r,_i); 00687 00688 #else 00689 00690 std::cerr << "ERROR: Functionality is not available." << std::endl 00691 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00692 << std::endl 00693 << "The XDR interface is not available in this installation" 00694 << std::endl; 00695 00696 libmesh_error(); 00697 00698 #endif 00699 return; 00700 } 00701 00702 case READ: 00703 { 00704 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00705 00706 double _r, _i; 00707 *in >> _r; 00708 *in >> _i; 00709 a = std::complex<double>(_r,_i); 00710 in->getline(comm, comm_len); 00711 00712 return; 00713 } 00714 00715 case WRITE: 00716 { 00717 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00718 00719 *out << a.real() << "\t " 00720 << a.imag() << "\t " 00721 << comment << '\n'; 00722 00723 return; 00724 } 00725 00726 default: 00727 libmesh_error(); 00728 } 00729 }
| void Xdr::data | ( | long double & | a, | |
| const char * | comment = "" | |||
| ) | [inline] |
| void Xdr::data | ( | double & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single double.
Definition at line 617 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00618 { 00619 switch (mode) 00620 { 00621 case ENCODE: 00622 case DECODE: 00623 { 00624 #ifdef LIBMESH_HAVE_XDR 00625 00626 libmesh_assert (is_open()); 00627 00628 xdr_double(xdrs, &a); 00629 00630 #else 00631 00632 std::cerr << "ERROR: Functionality is not available." << std::endl 00633 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00634 << std::endl 00635 << "The XDR interface is not available in this installation" 00636 << std::endl; 00637 00638 libmesh_error(); 00639 00640 #endif 00641 return; 00642 } 00643 00644 case READ: 00645 { 00646 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00647 00648 *in >> a; in->getline(comm, comm_len); 00649 00650 return; 00651 } 00652 00653 case WRITE: 00654 { 00655 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00656 00657 *out << a << "\t " << comment << '\n'; 00658 00659 return; 00660 } 00661 00662 default: 00663 libmesh_error(); 00664 } 00665 }
| void Xdr::data | ( | float & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single float.
Definition at line 565 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00566 { 00567 switch (mode) 00568 { 00569 case ENCODE: 00570 case DECODE: 00571 { 00572 #ifdef LIBMESH_HAVE_XDR 00573 00574 libmesh_assert (is_open()); 00575 00576 xdr_float(xdrs, &a); 00577 00578 #else 00579 00580 std::cerr << "ERROR: Functionality is not available." << std::endl 00581 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00582 << std::endl 00583 << "The XDR interface is not available in this installation" 00584 << std::endl; 00585 00586 libmesh_error(); 00587 00588 #endif 00589 return; 00590 } 00591 00592 case READ: 00593 { 00594 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00595 00596 *in >> a; in->getline(comm, comm_len); 00597 00598 return; 00599 } 00600 00601 case WRITE: 00602 { 00603 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00604 00605 *out << a << "\t " << comment << '\n'; 00606 00607 return; 00608 } 00609 00610 default: 00611 libmesh_error(); 00612 } 00613 }
| void Xdr::data | ( | unsigned short int & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single unsigned short integer.
Definition at line 513 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00514 { 00515 switch (mode) 00516 { 00517 case ENCODE: 00518 case DECODE: 00519 { 00520 #ifdef LIBMESH_HAVE_XDR 00521 00522 libmesh_assert (is_open()); 00523 00524 xdr_u_short(xdrs, &a); 00525 00526 #else 00527 00528 std::cerr << "ERROR: Functionality is not available." << std::endl 00529 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00530 << std::endl 00531 << "The XDR interface is not available in this installation" 00532 << std::endl; 00533 00534 libmesh_error(); 00535 00536 #endif 00537 return; 00538 } 00539 00540 case READ: 00541 { 00542 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00543 00544 *in >> a; in->getline(comm, comm_len); 00545 00546 return; 00547 } 00548 00549 case WRITE: 00550 { 00551 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00552 00553 *out << a << "\t " << comment << '\n'; 00554 00555 return; 00556 } 00557 00558 default: 00559 libmesh_error(); 00560 } 00561 }
| void Xdr::data | ( | short int & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single short integer.
Definition at line 461 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00462 { 00463 switch (mode) 00464 { 00465 case ENCODE: 00466 case DECODE: 00467 { 00468 #ifdef LIBMESH_HAVE_XDR 00469 00470 libmesh_assert (is_open()); 00471 00472 xdr_short(xdrs, &a); 00473 00474 #else 00475 00476 std::cerr << "ERROR: Functionality is not available." << std::endl 00477 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00478 << std::endl 00479 << "The XDR interface is not available in this installation" 00480 << std::endl; 00481 00482 libmesh_error(); 00483 00484 #endif 00485 return; 00486 } 00487 00488 case READ: 00489 { 00490 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00491 00492 *in >> a; in->getline(comm, comm_len); 00493 00494 return; 00495 } 00496 00497 case WRITE: 00498 { 00499 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00500 00501 *out << a << "\t " << comment << '\n'; 00502 00503 return; 00504 } 00505 00506 default: 00507 libmesh_error(); 00508 } 00509 }
| void Xdr::data | ( | unsigned int & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single unsigned integer.
Definition at line 409 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
00410 { 00411 switch (mode) 00412 { 00413 case ENCODE: 00414 case DECODE: 00415 { 00416 #ifdef LIBMESH_HAVE_XDR 00417 00418 libmesh_assert (this->is_open()); 00419 00420 xdr_u_int(xdrs, &a); 00421 00422 #else 00423 00424 std::cerr << "ERROR: Functionality is not available." << std::endl 00425 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00426 << std::endl 00427 << "The XDR interface is not available in this installation" 00428 << std::endl; 00429 00430 libmesh_error(); 00431 00432 #endif 00433 return; 00434 } 00435 00436 case READ: 00437 { 00438 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00439 00440 *in >> a; in->getline(comm, comm_len); 00441 00442 return; 00443 } 00444 00445 case WRITE: 00446 { 00447 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00448 00449 *out << a << "\t " << comment << '\n'; 00450 00451 return; 00452 } 00453 00454 default: 00455 libmesh_error(); 00456 } 00457 }
| void Xdr::data | ( | int & | a, | |
| const char * | comment = "" | |||
| ) |
Inputs or outputs a single integer.
Definition at line 357 of file xdr_cxx.C.
References comm, comm_len, libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, is_open(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
Referenced by EquationSystems::_read_impl(), data(), operator<<(), operator>>(), XdrIO::read(), System::read_header(), System::read_legacy_data(), System::read_parallel_data(), XdrIO::read_serialized_bcs(), XdrIO::read_serialized_connectivity(), System::read_serialized_vector(), MeshData::read_xdr(), XdrIO::write(), EquationSystems::write(), System::write_header(), System::write_parallel_data(), XdrIO::write_serialized_bcs(), XdrIO::write_serialized_connectivity(), System::write_serialized_vector(), and MeshData::write_xdr().
00358 { 00359 switch (mode) 00360 { 00361 case ENCODE: 00362 case DECODE: 00363 { 00364 #ifdef LIBMESH_HAVE_XDR 00365 00366 libmesh_assert (is_open()); 00367 00368 xdr_int(xdrs, &a); 00369 00370 #else 00371 00372 std::cerr << "ERROR: Functionality is not available." << std::endl 00373 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00374 << std::endl 00375 << "The XDR interface is not available in this installation" 00376 << std::endl; 00377 00378 libmesh_error(); 00379 00380 #endif 00381 return; 00382 } 00383 00384 case READ: 00385 { 00386 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00387 00388 *in >> a; in->getline(comm, comm_len); 00389 00390 return; 00391 } 00392 00393 case WRITE: 00394 { 00395 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00396 00397 *out << a << "\t " << comment << '\n'; 00398 00399 return; 00400 } 00401 00402 default: 00403 libmesh_error(); 00404 } 00405 }
| void Xdr::data_stream | ( | std::complex< double > * | val, | |
| const unsigned int | len, | |||
| const unsigned int | line_break | |||
| ) | [inline] |
Definition at line 1935 of file xdr_cxx.C.
References libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, libMesh::invalid_uint, is_open(), std::min(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01936 { 01937 switch (mode) 01938 { 01939 case ENCODE: 01940 case DECODE: 01941 { 01942 #ifdef LIBMESH_HAVE_XDR 01943 01944 libmesh_assert (this->is_open()); 01945 01946 01947 if (len > 0) 01948 { 01949 std::vector<double> io_buffer (2*len); 01950 01951 // Fill io_buffer if we are writing. 01952 if (mode == ENCODE) 01953 for (unsigned int i=0, cnt=0; i<len; i++) 01954 { 01955 io_buffer[cnt++] = val[i].real(); 01956 io_buffer[cnt++] = val[i].imag(); 01957 } 01958 01959 xdr_vector(xdrs, 01960 (char*) &io_buffer[0], 01961 2*len, 01962 sizeof(double), 01963 (xdrproc_t) xdr_double); 01964 01965 // Fill val array if we are reading. 01966 if (mode == DECODE) 01967 for (unsigned int i=0, cnt=0; i<len; i++) 01968 { 01969 val[i].real() = io_buffer[cnt++]; 01970 val[i].imag() = io_buffer[cnt++]; 01971 } 01972 } 01973 #else 01974 01975 std::cerr << "ERROR: Functionality is not available." << std::endl 01976 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01977 << std::endl 01978 << "The XDR interface is not available in this installation" 01979 << std::endl; 01980 01981 libmesh_error(); 01982 01983 #endif 01984 return; 01985 } 01986 01987 case READ: 01988 { 01989 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01990 01991 for (unsigned int i=0; i<len; i++) 01992 { 01993 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01994 *in >> val[i].real() >> val[i].imag(); 01995 } 01996 01997 return; 01998 } 01999 02000 case WRITE: 02001 { 02002 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 02003 02004 if (line_break == libMesh::invalid_uint) 02005 for (unsigned int i=0; i<len; i++) 02006 { 02007 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 02008 OFSRealscientific(*out,17,val[i].real()) << " "; 02009 OFSRealscientific(*out,17,val[i].imag()) << " "; 02010 } 02011 else 02012 { 02013 unsigned int cnt=0; 02014 while (cnt < len) 02015 { 02016 for (unsigned int i=0; i<std::min(line_break,len); i++) 02017 { 02018 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 02019 OFSRealscientific(*out,17,val[cnt].real()) << " "; 02020 OFSRealscientific(*out,17,val[cnt].imag()) << " "; 02021 cnt++; 02022 } 02023 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 02024 *out << '\n'; 02025 } 02026 } 02027 02028 return; 02029 } 02030 02031 default: 02032 libmesh_error(); 02033 } 02034 }
| void Xdr::data_stream | ( | long double * | val, | |
| const unsigned int | len, | |||
| const unsigned int | line_break | |||
| ) | [inline] |
Definition at line 1844 of file xdr_cxx.C.
References libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, libMesh::invalid_uint, is_open(), std::min(), mode, out, libMeshEnums::READ, and libMeshEnums::WRITE.
01845 { 01846 switch (mode) 01847 { 01848 case ENCODE: 01849 case DECODE: 01850 { 01851 #ifdef LIBMESH_HAVE_XDR 01852 01853 libmesh_assert (this->is_open()); 01854 01855 // FIXME[JWP]: How to implement this for long double? Mac OS 01856 // X defines 'xdr_quadruple' but AFAICT, it does not exist for 01857 // Linux... for now, reading/writing XDR files with long 01858 // doubles is disabled, but you can still write long double 01859 // ASCII files of course. 01860 // if (len > 0) 01861 // xdr_vector(xdrs, 01862 // (char*) val, 01863 // len, 01864 // sizeof(double), 01865 // (xdrproc_t) xdr_quadruple); 01866 01867 std::cerr << "Writing binary XDR files with long double's is not\n" 01868 << "currently supported on all platforms." << std::endl; 01869 01870 libmesh_error(); 01871 01872 #else 01873 01874 std::cerr << "ERROR: Functionality is not available." << std::endl 01875 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01876 << std::endl 01877 << "The XDR interface is not available in this installation" 01878 << std::endl; 01879 01880 libmesh_error(); 01881 01882 #endif 01883 return; 01884 } 01885 01886 case READ: 01887 { 01888 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01889 01890 for (unsigned int i=0; i<len; i++) 01891 { 01892 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01893 *in >> val[i]; 01894 } 01895 01896 return; 01897 } 01898 01899 case WRITE: 01900 { 01901 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01902 01903 if (line_break == libMesh::invalid_uint) 01904 for (unsigned int i=0; i<len; i++) 01905 { 01906 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01907 OFSRealscientific(*out,17,val[i]) << " "; 01908 } 01909 else 01910 { 01911 unsigned int cnt=0; 01912 while (cnt < len) 01913 { 01914 for (unsigned int i=0; i<std::min(line_break,len); i++) 01915 { 01916 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01917 OFSRealscientific(*out,17,val[cnt++]) << " "; 01918 } 01919 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01920 *out << '\n'; 01921 } 01922 } 01923 01924 return; 01925 } 01926 01927 default: 01928 libmesh_error(); 01929 } 01930 }
| void Xdr::data_stream | ( | double * | val, | |
| const unsigned int | len, | |||
| const unsigned int | line_break | |||
| ) | [inline] |
Definition at line 1764 of file xdr_cxx.C.
References libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, libMesh::invalid_uint, is_open(), std::min(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
01765 { 01766 switch (mode) 01767 { 01768 case ENCODE: 01769 case DECODE: 01770 { 01771 #ifdef LIBMESH_HAVE_XDR 01772 01773 libmesh_assert (this->is_open()); 01774 01775 if (len > 0) 01776 xdr_vector(xdrs, 01777 (char*) val, 01778 len, 01779 sizeof(double), 01780 (xdrproc_t) xdr_double); 01781 01782 #else 01783 01784 std::cerr << "ERROR: Functionality is not available." << std::endl 01785 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01786 << std::endl 01787 << "The XDR interface is not available in this installation" 01788 << std::endl; 01789 01790 libmesh_error(); 01791 01792 #endif 01793 return; 01794 } 01795 01796 case READ: 01797 { 01798 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01799 01800 for (unsigned int i=0; i<len; i++) 01801 { 01802 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01803 *in >> val[i]; 01804 } 01805 01806 return; 01807 } 01808 01809 case WRITE: 01810 { 01811 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01812 01813 if (line_break == libMesh::invalid_uint) 01814 for (unsigned int i=0; i<len; i++) 01815 { 01816 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01817 OFSRealscientific(*out,17,val[i]) << " "; 01818 } 01819 else 01820 { 01821 unsigned int cnt=0; 01822 while (cnt < len) 01823 { 01824 for (unsigned int i=0; i<std::min(line_break,len); i++) 01825 { 01826 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01827 OFSRealscientific(*out,17,val[cnt++]) << " "; 01828 } 01829 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01830 *out << '\n'; 01831 } 01832 } 01833 01834 return; 01835 } 01836 01837 default: 01838 libmesh_error(); 01839 } 01840 }
| void Xdr::data_stream | ( | T * | val, | |
| const unsigned int | len, | |||
| const unsigned int | line_break = libMesh::invalid_uint | |||
| ) | [inline] |
Inputs or outputs a raw data stream.
Definition at line 1657 of file xdr_cxx.C.
References libMeshEnums::DECODE, libMeshEnums::ENCODE, AutoPtr< Tp >::get(), in, libMesh::invalid_uint, is_open(), std::min(), mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
Referenced by XdrIO::read_serialized_bcs(), System::read_serialized_blocked_dof_objects(), XdrIO::read_serialized_connectivity(), XdrIO::read_serialized_nodes(), XdrIO::write_serialized_bcs(), System::write_serialized_blocked_dof_objects(), XdrIO::write_serialized_connectivity(), and XdrIO::write_serialized_nodes().
01658 { 01659 switch (mode) 01660 { 01661 case ENCODE: 01662 { 01663 #ifdef LIBMESH_HAVE_XDR 01664 01665 libmesh_assert (this->is_open()); 01666 01667 01668 xdr_vector(xdrs, 01669 (char*) val, 01670 len, 01671 sizeof(unsigned int), 01672 (xdrproc_t) xdr_u_int); 01673 01674 #else 01675 01676 std::cerr << "ERROR: Functionality is not available." << std::endl 01677 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01678 << std::endl 01679 << "The XDR interface is not available in this installation" 01680 << std::endl; 01681 01682 libmesh_error(); 01683 01684 #endif 01685 return; 01686 } 01687 01688 case DECODE: 01689 { 01690 #ifdef LIBMESH_HAVE_XDR 01691 01692 libmesh_assert (this->is_open()); 01693 01694 if (len > 0) 01695 xdr_vector(xdrs, 01696 (char*) val, 01697 len, 01698 sizeof(unsigned int), 01699 (xdrproc_t) xdr_u_int); 01700 01701 #else 01702 01703 std::cerr << "ERROR: Functionality is not available." << std::endl 01704 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 01705 << std::endl 01706 << "The XDR interface is not available in this installation" 01707 << std::endl; 01708 01709 libmesh_error(); 01710 01711 #endif 01712 return; 01713 } 01714 01715 case READ: 01716 { 01717 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01718 01719 for (unsigned int i=0; i<len; i++) 01720 { 01721 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 01722 *in >> val[i]; 01723 } 01724 01725 return; 01726 } 01727 01728 case WRITE: 01729 { 01730 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01731 01732 if (line_break == libMesh::invalid_uint) 01733 for (unsigned int i=0; i<len; i++) 01734 { 01735 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01736 *out << val[i] << " "; 01737 } 01738 else 01739 { 01740 unsigned int cnt=0; 01741 while (cnt < len) 01742 { 01743 for (unsigned int i=0; i<std::min(line_break,len); i++) 01744 { 01745 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01746 *out << val[cnt++] << " "; 01747 } 01748 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 01749 *out << '\n'; 01750 } 01751 } 01752 01753 return; 01754 } 01755 01756 default: 01757 libmesh_error(); 01758 } 01759 }
| bool Xdr::is_open | ( | ) | const |
Returns true if the Xdr file is open, false if it is closed.
Definition at line 303 of file xdr_cxx.C.
References libMeshEnums::DECODE, libMeshEnums::ENCODE, fp, AutoPtr< Tp >::get(), in, mode, out, libMeshEnums::READ, libMeshEnums::WRITE, and xdrs.
Referenced by data(), data_stream(), and System::read_parallel_data().
00304 { 00305 switch (mode) 00306 { 00307 case ENCODE: 00308 case DECODE: 00309 { 00310 #ifdef LIBMESH_HAVE_XDR 00311 00312 if (fp) 00313 if (xdrs) 00314 return true; 00315 00316 return false; 00317 00318 #else 00319 00320 std::cerr << "ERROR: Functionality is not available." << std::endl 00321 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00322 << std::endl 00323 << "The XDR interface is not available in this installation" 00324 << std::endl; 00325 00326 libmesh_error(); 00327 00328 return false; 00329 00330 #endif 00331 00332 } 00333 00334 case READ: 00335 { 00336 if (in.get() != NULL) 00337 return in->good(); 00338 return false; 00339 } 00340 00341 case WRITE: 00342 { 00343 if (out.get() != NULL) 00344 return out->good(); 00345 return false; 00346 } 00347 00348 default: 00349 libmesh_error(); 00350 } 00351 00352 return false; 00353 }
| void Xdr::open | ( | const std::string & | name | ) |
Opens the file.
Definition at line 124 of file xdr_cxx.C.
References bzipped_file, libMeshEnums::DECODE, libMeshEnums::ENCODE, file_name, fp, AutoPtr< Tp >::get(), gzipped_file, in, mode, out, libMeshEnums::READ, AutoPtr< Tp >::reset(), unzip_file(), libMeshEnums::WRITE, and xdrs.
00125 { 00126 file_name = name; 00127 00128 if (name == "") 00129 return; 00130 00131 switch (mode) 00132 { 00133 case ENCODE: 00134 case DECODE: 00135 { 00136 #ifdef LIBMESH_HAVE_XDR 00137 00138 fp = fopen(name.c_str(), (mode == ENCODE) ? "w" : "r"); 00139 libmesh_assert (fp); 00140 xdrs = new XDR; 00141 xdrstdio_create (xdrs, fp, (mode == ENCODE) ? XDR_ENCODE : XDR_DECODE); 00142 #else 00143 00144 std::cerr << "ERROR: Functionality is not available." << std::endl 00145 << "Make sure LIBMESH_HAVE_XDR is defined at build time" 00146 << std::endl 00147 << "The XDR interface is not available in this installation" 00148 << std::endl; 00149 00150 libmesh_error(); 00151 00152 #endif 00153 return; 00154 00155 } 00156 00157 case READ: 00158 { 00159 gzipped_file = (name.size() - name.rfind(".gz") == 3); 00160 bzipped_file = (name.size() - name.rfind(".bz2") == 4); 00161 00162 if (gzipped_file) 00163 { 00164 #ifdef LIBMESH_HAVE_GZSTREAM 00165 igzstream *inf = new igzstream; 00166 libmesh_assert (inf != NULL); 00167 in.reset(inf); 00168 inf->open(name.c_str(), std::ios::in); 00169 #else 00170 std::cerr << "ERROR: need gzstream to handle .gz files!!!" 00171 << std::endl; 00172 libmesh_error(); 00173 #endif 00174 } 00175 else 00176 { 00177 std::ifstream *inf = new std::ifstream; 00178 libmesh_assert (inf != NULL); 00179 in.reset(inf); 00180 00181 std::string new_name(bzipped_file ? unzip_file(name) : name); 00182 00183 inf->open(new_name.c_str(), std::ios::in); 00184 } 00185 00186 libmesh_assert (in.get() != NULL); libmesh_assert (in->good()); 00187 return; 00188 } 00189 00190 case WRITE: 00191 { 00192 gzipped_file = (name.size() - name.rfind(".gz") == 3); 00193 bzipped_file = (name.size() - name.rfind(".bz2") == 4); 00194 00195 if (gzipped_file) 00196 { 00197 #ifdef LIBMESH_HAVE_GZSTREAM 00198 ogzstream *outf = new ogzstream; 00199 libmesh_assert (outf != NULL); 00200 out.reset(outf); 00201 outf->open(name.c_str(), std::ios::out); 00202 #else 00203 std::cerr << "ERROR: need gzstream to handle .gz files!!!" 00204 << std::endl; 00205 libmesh_error(); 00206 #endif 00207 } 00208 else 00209 { 00210 std::ofstream *outf = new std::ofstream; 00211 libmesh_assert (outf != NULL); 00212 out.reset(outf); 00213 00214 std::string new_name = name; 00215 00216 if (bzipped_file) 00217 new_name.erase(new_name.end() - 4, new_name.end()); 00218 00219 outf->open(new_name.c_str(), std::ios::out); 00220 } 00221 00222 libmesh_assert (out.get() != NULL); libmesh_assert (out->good()); 00223 return; 00224 } 00225 00226 default: 00227 libmesh_error(); 00228 } 00229 }
| Xdr& Xdr::operator<< | ( | std::string & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< std::complex< double > > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< long double > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< double > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< float > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< unsigned short int > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< short int > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< unsigned int > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::vector< int > & | v | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::complex< long double > & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | std::complex< double > & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | long double & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | double & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | float & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | unsigned short int & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | short int & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | unsigned int & | a | ) | [inline] |
| Xdr& Xdr::operator<< | ( | int & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::string & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< std::complex< double > > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< long double > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< double > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< float > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< unsigned short int > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< short int > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< unsigned int > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::vector< int > & | v | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::complex< long double > & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | std::complex< double > & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | long double & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | double & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | float & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | unsigned short int & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | short int & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | unsigned int & | a | ) | [inline] |
| Xdr& Xdr::operator>> | ( | int & | a | ) | [inline] |
| bool Xdr::reading | ( | ) | const [inline] |
Returns true if the file is opened in a reading state, false otherwise.
Definition at line 100 of file xdr_cxx.h.
References libMeshEnums::DECODE, mode, and libMeshEnums::READ.
Referenced by EquationSystems::_read_impl(), operator>>(), System::read_header(), System::read_legacy_data(), System::read_parallel_data(), XdrIO::read_serialized_bcs(), XdrIO::read_serialized_connectivity(), XdrIO::read_serialized_nodes(), and System::read_serialized_vector().
| bool Xdr::writing | ( | ) | const [inline] |
Returns true if the file is opened in a writing state, false otherwise.
Definition at line 106 of file xdr_cxx.h.
References libMeshEnums::ENCODE, mode, and libMeshEnums::WRITE.
Referenced by operator<<(), EquationSystems::write(), System::write_header(), System::write_parallel_data(), XdrIO::write_serialized_bcs(), XdrIO::write_serialized_connectivity(), and System::write_serialized_vector().
Member Data Documentation
bool Xdr::bzipped_file [private] |
char Xdr::comm[xdr_MAX_STRING_LENGTH] [private] |
const int Xdr::comm_len [private] |
std::string Xdr::file_name [private] |
FILE* Xdr::fp [private] |
bool Xdr::gzipped_file [private] |
const XdrMODE Xdr::mode [private] |
XDR* Xdr::xdrs [private] |
The documentation for this class was generated from the following files: