Poster of Linux kernelThe best gift for a Linux geek
Xdr

Xdr

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

Xdr -  

SYNOPSIS


#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::XdrMODEm = UNKNOWN)Constructor. Takes the filename and the mode. Valid modes are ENCODE, DECODE, READ, and WRITE.

Definition at line 99 of file xdr_cxx.C.

References open().

                                                :
  mode(m),
  file_name(name),
#ifdef LIBMESH_HAVE_XDR
  xdrs(NULL),
  fp(NULL),
#endif
  in(NULL),
  out(NULL),
  comm_len(xdr_MAX_STRING_LENGTH),
  gzipped_file(false),
  bzipped_file(false)
{
  this->open(name);
}
 

Xdr::~Xdr ()Destructor. Closes the file if it is open.

Definition at line 117 of file xdr_cxx.C.

References close().

{
  this->close();
}
 

Member Function Documentation

 

XdrMODE Xdr::access_mode () const [inline]Returns the mode used to access the file. Valid modes are ENCODE, DECODE, READ, or WRITE.

Definition at line 112 of file xdr_cxx.h.

References mode.

{ return mode; }
 

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, AutoPtr< Tp >::reset(), libMeshEnums::WRITE, and xdrs.

Referenced by EquationSystems::_read_impl(), XdrIO::read(), XdrIO::write(), and ~Xdr().

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        if (xdrs)
          {
            xdr_destroy (xdrs);
            delete xdrs;
            xdrs = NULL;
          }
        
        if (fp)
          {
            fflush(fp);
            fclose(fp);
            fp = NULL;
          }
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_HAVE_XDR is defined at build time' 
                  << std::endl
                  << 'The XDR interface is not available in this installation'
                  << std::endl;

        libmesh_error();
        
#endif
        file_name = '';
        return;
      }
      
    case READ:
      {
        if (in.get() != NULL)
          {
            in.reset();    
            
            if (bzipped_file)
              remove_unzipped_file(file_name);
          }
        file_name = '';
        return;
      }

    case WRITE:
      {
        if (out.get() != NULL)
          {
            out.reset();      

            if (bzipped_file)
              zip_file(std::string(file_name.begin(), file_name.end()-4));
          }
        file_name = '';
        return;
      }

    default:
      libmesh_error();
    }
}
 

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().

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
        return;
      }

    case READ:
      {
        libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
        in->getline(comm, comm_len);
        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
        *out << '	 ' << comment << ';
        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());

        xdr_u_int(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << a << '	 ' << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        xdr_u_short(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << a << '	 ' << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        xdr_float(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << a << '	 ' << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        xdr_double(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << a << '	 ' << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        xdr_short(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << a << '	 ' << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

void Xdr::data (long double &a, const char *comment = '') [inline]Inputs or outputs a single long double, but in double precision.

Definition at line 209 of file xdr_cxx.h.

References comment(), and data().

    { double ad = a;
      data(ad, comment); }
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_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 LIBMESH_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 LIBMESH_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 LIBMESH_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];
          }

        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 << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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().

    { std::vector<double> vd(v.size());
      for (unsigned int i = 0; i != v.size(); ++i)
        vd[i] = static_cast<double>(v[i]);
      data(vd, comment);
      v.resize(vd.size());
      for (unsigned int i = 0; i != vd.size(); ++i)
        v[i] = static_cast<long double>(vd[i]);
    }
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        unsigned int length = v.size();

        data(length, '# vector length x 2 (complex)');

        std::vector< std::complex<double> >::iterator iter = v.begin();
        
        for (; iter != v.end(); ++iter)
            data(*iter, '');

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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 LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        unsigned int length=0;

        data(length, '# vector length x 2 (complex)');

        v.resize(length);

        std::vector< std::complex<double> >::iterator iter = v.begin();
        
        for (; iter != v.end(); ++iter)
            data(*iter, '');
        
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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 x 2 (complex)');

        v.resize(length);

        for (unsigned int i=0; i<v.size(); i++)
          {
            libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
        
            double _r, _i;
            *in >> _r;
            *in >> _i;
            v[i] = std::complex<double>(_r,_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 x 2 (complex)');

        for (unsigned int i=0; i<v.size(); i++)
          {
            libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
            OFSNumberscientific(*out,17,v[i]) << ' ';
          }

        *out << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());
        double
          _r=a.real(),
          _i=a.imag();
        xdr_double(xdrs, &_r);
        xdr_double(xdrs, &_i);
        a = std::complex<double>(_r,_i);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        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() << '	 ' 
            << a.imag() << '	 '
            << comment << ';
        
        return;
      }

    default:
      libmesh_error();
    }
}
 

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.

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        {
          char* sptr = new char[s.size()+1];

          for (unsigned int c=0; c<s.size(); c++)
            sptr[c] = s[c];
        
          sptr[s.size()] = ' ';
          
          xdr_string(xdrs,
                     &sptr,
                     std::strlen(sptr));

          delete [] sptr;
        }

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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 LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        {
          char* sptr = new char[xdr_MAX_STRING_LENGTH];
          
          xdr_string(xdrs,
                     &sptr,
                     xdr_MAX_STRING_LENGTH);

          s.resize(std::strlen(sptr));

          for (unsigned int c=0; c<s.size(); c++)
            s[c] = sptr[c];
          
          delete [] sptr;  
        }

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());

        in->getline(comm, comm_len);

//#ifndef LIBMESH_BROKEN_IOSTREAM
//      s.clear();
//#else
        s = '';
//#endif

        for (unsigned int c=0; c<std::strlen(comm); c++)
          {
            if (comm[c] == '	') 
              break;
            
            s.push_back(comm[c]);
          }

        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        *out << s << '	 ' << comment << ';

        return; 
      }

    default:
      libmesh_error();
    }
}
 

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().

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (is_open());

        xdr_int(xdrs, &a);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());
        
        *in >> a; in->getline(comm, comm_len);

        return;
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
        
        *out << a << '	 ' << comment << ';

        return;
      }

    default:
      libmesh_error();
    }
}
 

void Xdr::data (std::complex< long double > &a, const char *comment = '') [inline]Inputs or outputs a single complex<long double>, but in double precision.

Definition at line 245 of file xdr_cxx.h.

References comment(), and data().

    { std::complex<double> ad (a);
      data(ad, comment); }
 

template<> void Xdr::data_stream (double *val, const unsigned intlen, const unsigned intline_break)

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());

        if (len > 0)
          xdr_vector(xdrs, 
                     (char*) val,
                     len,
                     sizeof(double),
                     (xdrproc_t) xdr_double);
        
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());

        for (unsigned int i=0; i<len; i++)
          {
            libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
            *in >> val[i];
          }

        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        if (line_break == libMesh::invalid_uint)
          for (unsigned int i=0; i<len; i++)
            {
              libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
              OFSRealscientific(*out,17,val[i]) << ' ';
            }
        else
          {
            unsigned int cnt=0;
            while (cnt < len)
              {
                for (unsigned int i=0; i<std::min(line_break,len); i++)
                  {
                    libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                    OFSRealscientific(*out,17,val[cnt++]) << ' ';
                  }
                libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                *out << ';
              }
          }

        return; 
      }

    default:
      libmesh_error();
    }
}
 

template<> void Xdr::data_stream (long double *val, const unsigned intlen, const unsigned intline_break)

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());

        // FIXME[JWP]: How to implement this for long double?  Mac OS
        // X defines 'xdr_quadruple' but AFAICT, it does not exist for
        // Linux... for now, reading/writing XDR files with long
        // doubles is disabled, but you can still write long double
        // ASCII files of course.
        // if (len > 0)
        //   xdr_vector(xdrs, 
        //           (char*) val,
        //           len,
        //           sizeof(double),
        //           (xdrproc_t) xdr_quadruple);

        std::cerr << 'Writing binary XDR files with long double's is not
                  << 'currently supported on all platforms.' << std::endl;

        libmesh_error();
        
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());

        for (unsigned int i=0; i<len; i++)
          {
            libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
            *in >> val[i];
          }

        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        if (line_break == libMesh::invalid_uint)
          for (unsigned int i=0; i<len; i++)
            {
              libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
              OFSRealscientific(*out,17,val[i]) << ' ';
            }
        else
          {
            unsigned int cnt=0;
            while (cnt < len)
              {
                for (unsigned int i=0; i<std::min(line_break,len); i++)
                  {
                    libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                    OFSRealscientific(*out,17,val[cnt++]) << ' ';
                  }
                libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                *out << ';
              }
          }

        return; 
      }

    default:
      libmesh_error();
    }
}
 

template<> void Xdr::data_stream (std::complex< double > *val, const unsigned intlen, const unsigned intline_break)

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.

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());


        if (len > 0)
          {
            std::vector<double> io_buffer (2*len);
            
            // Fill io_buffer if we are writing.
            if (mode == ENCODE)
              for (unsigned int i=0, cnt=0; i<len; i++)
                {
                  io_buffer[cnt++] = val[i].real();
                  io_buffer[cnt++] = val[i].imag();
                } 
              
            xdr_vector(xdrs, 
                       (char*) &io_buffer[0],
                       2*len,
                       sizeof(double),
                       (xdrproc_t) xdr_double);
            
            // Fill val array if we are reading.
            if (mode == DECODE)
              for (unsigned int i=0, cnt=0; i<len; i++)
                {
                  val[i].real() = io_buffer[cnt++];
                  val[i].imag() = io_buffer[cnt++];
                } 
          }
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());

        for (unsigned int i=0; i<len; i++)
          {
            libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
            *in >> val[i].real() >> val[i].imag();
          }

        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        if (line_break == libMesh::invalid_uint)
          for (unsigned int i=0; i<len; i++)
            {
              libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
              OFSRealscientific(*out,17,val[i].real()) << ' ';
              OFSRealscientific(*out,17,val[i].imag()) << ' ';
            }
        else
          {
            unsigned int cnt=0;
            while (cnt < len)
              {
                for (unsigned int i=0; i<std::min(line_break,len); i++)
                  {
                    libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                    OFSRealscientific(*out,17,val[cnt].real()) << ' ';
                    OFSRealscientific(*out,17,val[cnt].imag()) << ' ';
                    cnt++;
                  }
                libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                *out << ';
              }
          }

        return; 
      }

    default:
      libmesh_error();
    }
}
 

template<typename T > void Xdr::data_stream (T *val, const unsigned intlen, const unsigned intline_break = libMesh::invalid_uint)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().

{
  switch (mode)
    {
    case ENCODE:
      {
#ifdef LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());


        xdr_vector(xdrs, 
                   (char*) val,
                   len,
                   sizeof(unsigned int),
                   (xdrproc_t) xdr_u_int);

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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 LIBMESH_HAVE_XDR

        libmesh_assert (this->is_open());

        if (len > 0)
          xdr_vector(xdrs, 
                     (char*) val,
                     len,
                     sizeof(unsigned int),
                     (xdrproc_t) xdr_u_int);
        
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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());

        for (unsigned int i=0; i<len; i++)
          {
            libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
            *in >> val[i];
          }

        return; 
      }

    case WRITE:
      {
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());

        if (line_break == libMesh::invalid_uint)
          for (unsigned int i=0; i<len; i++)
            {
              libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
              *out << val[i] << ' ';
            }
        else
          {
            unsigned int cnt=0;
            while (cnt < len)
              {
                for (unsigned int i=0; i<std::min(line_break,len); i++)
                  {
                    libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                    *out << val[cnt++] << ' ';
                  }
                libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
                *out << ';
              }
          }

        return; 
      }

    default:
      libmesh_error();
    }
}
 

bool Xdr::is_open () constReturns 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().

{
  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        if (fp)
          if (xdrs)
            return true;

        return false;

#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_HAVE_XDR is defined at build time' 
                  << std::endl
                  << 'The XDR interface is not available in this installation'
                  << std::endl;

        libmesh_error();

        return false;   

#endif

      }
      
    case READ:
      {
        if (in.get() != NULL)
          return in->good();
        return false;
      }

    case WRITE:
      {
        if (out.get() != NULL)
          return out->good();
        return false;
      }

    default:
      libmesh_error();
    }

  return false;
}
 

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, Quality::name(), out, libMeshEnums::READ, AutoPtr< Tp >::reset(), libMeshEnums::WRITE, and xdrs.

Referenced by Xdr().

{
  file_name = name;

  if (name == '')
    return;

  switch (mode)
    {
    case ENCODE:
    case DECODE:
      {
#ifdef LIBMESH_HAVE_XDR

        fp = fopen(name.c_str(), (mode == ENCODE) ? 'w' : 'r');
        libmesh_assert (fp);
        xdrs = new XDR;
        xdrstdio_create (xdrs, fp, (mode == ENCODE) ? XDR_ENCODE : XDR_DECODE);
#else
        
        std::cerr << 'ERROR: Functionality is not available.' << std::endl
                  << 'Make sure LIBMESH_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:
      {
        gzipped_file = (name.size() - name.rfind('.gz')  == 3);
        bzipped_file = (name.size() - name.rfind('.bz2') == 4);

        if (gzipped_file)
          {
#ifdef LIBMESH_HAVE_GZSTREAM
            igzstream *inf = new igzstream;
            libmesh_assert (inf != NULL);
            in.reset(inf);
            inf->open(name.c_str(), std::ios::in);
#else
            std::cerr << 'ERROR: need gzstream to handle .gz files!!!'
                      << std::endl;
            libmesh_error();
#endif
          }
        else
          {
            std::ifstream *inf = new std::ifstream;
            libmesh_assert (inf != NULL);
            in.reset(inf);
            
            std::string new_name(bzipped_file ? unzip_file(name) : name);

            inf->open(new_name.c_str(), std::ios::in);
          }

        libmesh_assert (in.get() != NULL); libmesh_assert (in->good());
        return;
      }

    case WRITE:
      {
        gzipped_file = (name.size() - name.rfind('.gz')  == 3);
        bzipped_file = (name.size() - name.rfind('.bz2') == 4);

        if (gzipped_file)
          {
#ifdef LIBMESH_HAVE_GZSTREAM
            ogzstream *outf = new ogzstream;
            libmesh_assert (outf != NULL);
            out.reset(outf);
            outf->open(name.c_str(), std::ios::out);
#else
            std::cerr << 'ERROR: need gzstream to handle .gz files!!!'
                      << std::endl;
            libmesh_error();
#endif
          }
        else
          {
            std::ofstream *outf = new std::ofstream;
            libmesh_assert (outf != NULL);
            out.reset(outf);

            std::string new_name = name;

            if (bzipped_file)
              new_name.erase(new_name.end() - 4, new_name.end());

            outf->open(new_name.c_str(), std::ios::out);
          }
        
        libmesh_assert (out.get() != NULL); libmesh_assert (out->good());
        return;
      }
      
    default:
      libmesh_error();
    }  
}
 

Xdr& Xdr::operator<< (std::vector< unsigned short int > &v) [inline]Same, but provides an ostream like interface.

Definition at line 315 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (int &a) [inline]Same, but provides an ostream like interface.

Definition at line 124 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (unsigned short int &a) [inline]Same, but provides an ostream like interface.

Definition at line 169 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::vector< int > &v) [inline]Same, but provides an ostream like interface.

Definition at line 270 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (std::vector< unsigned int > &v) [inline]Same, but provides an ostream like interface.

Definition at line 285 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (std::complex< double > &a) [inline]Same, but provides an ostream like interface.

Definition at line 234 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (float &a) [inline]Same, but provides an ostream like interface.

Definition at line 184 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::vector< short int > &v) [inline]Same, but provides an ostream like interface.

Definition at line 300 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (std::string &v) [inline]Same, but provides an ostream like interface.

Definition at line 405 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (std::vector< std::complex< double > > &v) [inline]Same, but provides an ostream like interface.

Definition at line 387 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (unsigned int &a) [inline]Same, but provides an ostream like interface.

Definition at line 139 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (double &a) [inline]Same, but provides an ostream like interface.

Definition at line 199 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::vector< double > &v) [inline]Same, but provides an ostream like interface.

Definition at line 345 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (long double &a) [inline]Same, but provides an ostream like interface.

Definition at line 216 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::vector< long double > &v) [inline]Same, but provides an ostream like interface.

Definition at line 369 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator<< (short int &a) [inline]Same, but provides an ostream like interface.

Definition at line 154 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::complex< long double > &a) [inline]Same, but provides an ostream like interface.

Definition at line 252 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(a); return *this; }
 

Xdr& Xdr::operator<< (std::vector< float > &v) [inline]Same, but provides an ostream like interface.

Definition at line 330 of file xdr_cxx.h.

References data(), and writing().

{ libmesh_assert (writing()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< unsigned short int > &v) [inline]Same, but provides an istream like interface.

Definition at line 320 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (unsigned int &a) [inline]Same, but provides an istream like interface.

Definition at line 144 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (std::complex< double > &a) [inline]Same, but provides an istream like interface.

Definition at line 239 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (short int &a) [inline]Same, but provides an istream like interface.

Definition at line 159 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (std::vector< unsigned int > &v) [inline]Same, but provides an istream like interface.

Definition at line 290 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< int > &v) [inline]Same, but provides an istream like interface.

Definition at line 275 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< float > &v) [inline]Same, but provides an istream like interface.

Definition at line 335 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< long double > &v) [inline]Same, but provides an istream like interface.

Definition at line 374 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (float &a) [inline]Same, but provides an istream like interface.

Definition at line 189 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (int &a) [inline]Same, but provides an istream like interface.

Definition at line 129 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (std::string &v) [inline]Same, but provides an istream like interface.

Definition at line 410 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::complex< long double > &a) [inline]Same, but provides an istream like interface.

Definition at line 257 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (long double &a) [inline]Same, but provides an istream like interface.

Definition at line 221 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (unsigned short int &a) [inline]Same, but provides an istream like interface.

Definition at line 174 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (double &a) [inline]Same, but provides an istream like interface.

Definition at line 204 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(a); return *this; }
 

Xdr& Xdr::operator>> (std::vector< short int > &v) [inline]Same, but provides an istream like interface.

Definition at line 305 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< std::complex< double > > &v) [inline]Same, but provides an istream like interface.

Definition at line 392 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

Xdr& Xdr::operator>> (std::vector< double > &v) [inline]Same, but provides an istream like interface.

Definition at line 350 of file xdr_cxx.h.

References data(), and reading().

{ libmesh_assert (reading()); data(v); return *this; }
 

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().

{ return ((mode == DECODE) || (mode == READ)); }
 

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().

{ return ((mode == ENCODE) || (mode == WRITE)); }
 

Member Data Documentation

 

bool Xdr::bzipped_file [private]

Definition at line 474 of file xdr_cxx.h.

Referenced by close(), and open().  

char Xdr::comm[xdr_MAX_STRING_LENGTH] [private]

Definition at line 468 of file xdr_cxx.h.

Referenced by comment(), and data().  

const int Xdr::comm_len [private]A buffer to put comment strings into.

Definition at line 467 of file xdr_cxx.h.

Referenced by comment(), and data().  

std::string Xdr::file_name [private]The file name

Definition at line 435 of file xdr_cxx.h.

Referenced by close(), and open().  

FILE* Xdr::fp [private]File pointer.

Definition at line 450 of file xdr_cxx.h.

Referenced by close(), is_open(), and open().  

bool Xdr::gzipped_file [private]Are we reading/writing bzipped or gzipped files?

Definition at line 473 of file xdr_cxx.h.

Referenced by open().  

AutoPtr<std::istream> Xdr::in [private]The input file stream.

Definition at line 457 of file xdr_cxx.h.

Referenced by close(), comment(), data(), data_stream(), is_open(), and open().  

const XdrMODE Xdr::mode [private]The mode used for accessing the file.

Definition at line 430 of file xdr_cxx.h.

Referenced by access_mode(), close(), comment(), data(), data_stream(), is_open(), open(), reading(), and writing().  

AutoPtr<std::ostream> Xdr::out [private]The output file stream.

Definition at line 462 of file xdr_cxx.h.

Referenced by close(), comment(), data(), data_stream(), is_open(), and open().  

XDR* Xdr::xdrs [private]Pointer to the standard xdr struct. See the standard header file rpc/rpc.h for more information.

Definition at line 445 of file xdr_cxx.h.

Referenced by close(), data(), data_stream(), is_open(), and open().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Private Attributes
Detailed Description
Constructor & Destructor Documentation
Xdr::Xdr (const std::string &name = '', const libMeshEnums::XdrMODEm = UNKNOWN)Constructor. Takes the filename and the mode. Valid modes are ENCODE, DECODE, READ, and WRITE.
Xdr::~Xdr ()Destructor. Closes the file if it is open.
Member Function Documentation
XdrMODE Xdr::access_mode () const [inline]Returns the mode used to access the file. Valid modes are ENCODE, DECODE, READ, or WRITE.
void Xdr::close ()Closes the file if it is open.
void Xdr::comment (std::string &comment)Writes or reads (ignores) a comment line.
void Xdr::data (unsigned int &a, const char *comment = '')Inputs or outputs a single unsigned integer.
void Xdr::data (unsigned short int &a, const char *comment = '')Inputs or outputs a single unsigned short integer.
void Xdr::data (std::vector< int > &v, const char *comment = '')Inputs or outputs a vector of integers.
void Xdr::data (float &a, const char *comment = '')Inputs or outputs a single float.
void Xdr::data (std::vector< unsigned int > &v, const char *comment = '')Inputs or outputs a vector of unsigned integers.
void Xdr::data (double &a, const char *comment = '')Inputs or outputs a single double.
void Xdr::data (std::vector< short int > &v, const char *comment = '')Inputs or outputs a vector of short integers.
void Xdr::data (std::vector< unsigned short int > &v, const char *comment = '')Inputs or outputs a vector of unsigned short integers.
void Xdr::data (std::vector< float > &v, const char *comment = '')Inputs or outputs a vector of floats.
void Xdr::data (short int &a, const char *comment = '')Inputs or outputs a single short integer.
void Xdr::data (long double &a, const char *comment = '') [inline]Inputs or outputs a single long double, but in double precision.
void Xdr::data (std::vector< double > &v, const char *comment = '')Inputs or outputs a vector of doubles.
void Xdr::data (std::vector< long double > &v, const char *comment = '') [inline]Inputs or outputs a vector of long doubles, but in double precision.
void Xdr::data (std::vector< std::complex< double > > &v, const char *comment = '')Inputs or outputs a vector of complex<double>.
void Xdr::data (std::complex< double > &a, const char *comment = '')Inputs or outputs a single complex<double>.
void Xdr::data (std::string &s, const char *comment = '')Inputs or outputs a single string.
void Xdr::data (int &a, const char *comment = '')Inputs or outputs a single integer.
void Xdr::data (std::complex< long double > &a, const char *comment = '') [inline]Inputs or outputs a single complex<long double>, but in double precision.
template<> void Xdr::data_stream (double *val, const unsigned intlen, const unsigned intline_break)
template<> void Xdr::data_stream (long double *val, const unsigned intlen, const unsigned intline_break)
template<> void Xdr::data_stream (std::complex< double > *val, const unsigned intlen, const unsigned intline_break)
template<typename T > void Xdr::data_stream (T *val, const unsigned intlen, const unsigned intline_break = libMesh::invalid_uint)Inputs or outputs a raw data stream.
bool Xdr::is_open () constReturns true if the Xdr file is open, false if it is closed.
void Xdr::open (const std::string &name)Opens the file.
Xdr& Xdr::operator<< (std::vector< unsigned short int > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (int &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (unsigned short int &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< int > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< unsigned int > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::complex< double > &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (float &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< short int > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::string &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< std::complex< double > > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (unsigned int &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (double &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< double > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (long double &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< long double > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (short int &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::complex< long double > &a) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator<< (std::vector< float > &v) [inline]Same, but provides an ostream like interface.
Xdr& Xdr::operator>> (std::vector< unsigned short int > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (unsigned int &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::complex< double > &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (short int &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< unsigned int > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< int > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< float > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< long double > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (float &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (int &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::string &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::complex< long double > &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (long double &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (unsigned short int &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (double &a) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< short int > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< std::complex< double > > &v) [inline]Same, but provides an istream like interface.
Xdr& Xdr::operator>> (std::vector< double > &v) [inline]Same, but provides an istream like interface.
bool Xdr::reading () const [inline]Returns true if the file is opened in a reading state, false otherwise.
bool Xdr::writing () const [inline]Returns true if the file is opened in a writing state, false otherwise.
Member Data Documentation
bool Xdr::bzipped_file [private]
char Xdr::comm[xdr_MAX_STRING_LENGTH] [private]
const int Xdr::comm_len [private]A buffer to put comment strings into.
std::string Xdr::file_name [private]The file name
FILE* Xdr::fp [private]File pointer.
bool Xdr::gzipped_file [private]Are we reading/writing bzipped or gzipped files?
AutoPtr<std::istream> Xdr::in [private]The input file stream.
const XdrMODE Xdr::mode [private]The mode used for accessing the file.
AutoPtr<std::ostream> Xdr::out [private]The output file stream.
XDR* Xdr::xdrs [private]Pointer to the standard xdr struct. See the standard header file rpc/rpc.h for more information.
Author

This document was created by man2html, using the manual pages.
Time: 21:58:34 GMT, April 16, 2011