Back to index

salome-med  6.5.0
Classes | Public Member Functions | Private Member Functions | Private Attributes
MEDMEM_ENSIGHT::_BinaryFileWriter Class Reference

Writer of binary files. More...

#include <MEDMEM_EnsightUtils.hxx>

List of all members.

Classes

class  _RealData
 Container of temporary data converting any data to floats. More...

Public Member Functions

 _BinaryFileWriter (const string &fileName) throw (MEDEXCEPTION)
 Constructor of _BinaryFileWriter opens its file.
 ~_BinaryFileWriter ()
 write a string
void addString (const char *str) throw (MEDEXCEPTION)
 write a string
void addString (const string &str) throw (MEDEXCEPTION)
 write an integer value
void addInt (const int value) throw (MEDEXCEPTION)
 write integer values
void addInt (const int *data, int nbValues) throw (MEDEXCEPTION)
 write integer values
void addInt (const vector< int > &data) throw (MEDEXCEPTION)
 write any data as floats
template<typename T >
void addReal (const T *data, int nbValues) throw (MEDEXCEPTION)
 write any data as floats
template<class TValueIterator >
void addReal (vector< TValueIterator > &componentIt, const int nbValues, const medModeSwitch interlace) throw (MEDEXCEPTION)

Private Member Functions

template<typename T >
void add (const T *data, int nbValues) throw (MEDEXCEPTION)

Private Attributes

int _file
 descriptor
MEDEXCEPTION _exception
 ready to raise exception

Detailed Description

Writer of binary files.

Definition at line 826 of file MEDMEM_EnsightUtils.hxx.


Constructor & Destructor Documentation

MEDMEM_ENSIGHT::_BinaryFileWriter::_BinaryFileWriter ( const string &  fileName) throw (MEDEXCEPTION)

Constructor of _BinaryFileWriter opens its file.

Definition at line 2877 of file MEDMEM_EnsightUtils.cxx.

  : _exception(STRING("Can't write into ") << fileName)
{
#ifdef WNT
  _file = ::_open (fileName.c_str(), _O_WRONLY|_O_BINARY|_O_TRUNC);
#else
  _file = ::open (fileName.c_str(), O_WRONLY|O_TRUNC); //length shall be truncated to 0
#endif

  if (_file < 0)
    throw _exception;
}

write a string

Destructor of _BinaryFileWriter closes its file.

Definition at line 2896 of file MEDMEM_EnsightUtils.cxx.

{
  if (_file >= 0)
    ::close (_file);
}

Member Function Documentation

template<typename T >
void MEDMEM_ENSIGHT::_BinaryFileWriter::add ( const T *  data,
int  nbValues 
) throw (MEDEXCEPTION) [inline, private]

Definition at line 877 of file MEDMEM_EnsightUtils.hxx.

  {
#ifdef WNT
#else
    ssize_t nbWritten = ::write( _file, (const void *) data, nbValues * sizeof(T));
    if ( nbWritten < 0 ) throw _exception;
#endif
  }
void MEDMEM_ENSIGHT::_BinaryFileWriter::addInt ( const int  value) throw (MEDEXCEPTION) [inline]

write integer values

Definition at line 841 of file MEDMEM_EnsightUtils.hxx.

Here is the call graph for this function:

void MEDMEM_ENSIGHT::_BinaryFileWriter::addInt ( const int *  data,
int  nbValues 
) throw (MEDEXCEPTION) [inline]

write integer values

Definition at line 845 of file MEDMEM_EnsightUtils.hxx.

Here is the call graph for this function:

void MEDMEM_ENSIGHT::_BinaryFileWriter::addInt ( const vector< int > &  data) throw (MEDEXCEPTION) [inline]

write any data as floats

Definition at line 849 of file MEDMEM_EnsightUtils.hxx.

Here is the call graph for this function:

template<typename T >
void MEDMEM_ENSIGHT::_BinaryFileWriter::addReal ( const T *  data,
int  nbValues 
) throw (MEDEXCEPTION) [inline]

write any data as floats

Definition at line 854 of file MEDMEM_EnsightUtils.hxx.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TValueIterator >
void MEDMEM_ENSIGHT::_BinaryFileWriter::addReal ( vector< TValueIterator > &  componentIt,
const int  nbValues,
const medModeSwitch  interlace 
) throw (MEDEXCEPTION) [inline]

Definition at line 862 of file MEDMEM_EnsightUtils.hxx.

  {
    _RealData realData( componentIt, nbValues, interlace );
    add( realData.values(), nbValues * componentIt.size() );
  }

Here is the call graph for this function:

void MEDMEM_ENSIGHT::_BinaryFileWriter::addString ( const char *  str) throw (MEDEXCEPTION)

write a string

Write string.

Definition at line 2908 of file MEDMEM_EnsightUtils.cxx.

{
  size_t len = strlen( str );
  if ((int) len > MAX_LINE_LENGTH )
    throw MEDEXCEPTION
      (LOCALIZED(STRING("_BinaryFileWriter::addString(), too long string (>80):\n") << str));

  string buffer( str, len );
  // avoid "Syscall param write(buf) points to uninitialised byte(s)" error by valgrind
  buffer += string(MAX_LINE_LENGTH, ' ');
  buffer[ len ] = '\0';
  buffer[ MAX_LINE_LENGTH-1 ] = '\0'; // to have line-end within

  add( buffer.c_str(), MAX_LINE_LENGTH );
}

Here is the call graph for this function:

void MEDMEM_ENSIGHT::_BinaryFileWriter::addString ( const string &  str) throw (MEDEXCEPTION) [inline]

write an integer value

Definition at line 837 of file MEDMEM_EnsightUtils.hxx.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

ready to raise exception

write any data to file

Definition at line 873 of file MEDMEM_EnsightUtils.hxx.

descriptor

Definition at line 872 of file MEDMEM_EnsightUtils.hxx.


The documentation for this class was generated from the following files: