Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
JIO::JBinaryFileWriter< T > Class Template Reference

Object(s) writing to binary file. More...

#include <JBinaryFileWriter.hh>

Inheritance diagram for JIO::JBinaryFileWriter< T >:
JLANG::JAccessibleBinaryOutputStream JIO::JStreamWriter JIO::JWriterObjectOutput< T > JLANG::JAccessibleObjectOutput< T > JLANG::JAccessibleOutputStream JIO::JWriter JLANG::JObjectOutput< T > JLANG::JObjectOutput< T > JLANG::JAccessible JLANG::JAccessible JLANG::JBinaryOutput JLANG::JAbstractObjectStatus JLANG::JThrow< JAccessible > JLANG::JThrow< JAccessible >

Public Member Functions

 JBinaryFileWriter ()
 Default constructor. More...
 
virtual void open (const char *file_name) override
 Open file. More...
 
virtual bool is_open () const
 Check is file is open. More...
 
virtual void close ()
 Close file. More...
 
virtual bool put (const T &object) override
 Object output. More...
 

Static Public Member Functions

static void Throw (const bool option)
 Enable/disable throw option. More...
 
static int Throw (const JException &error, const int value=-1)
 Throw exception or return error. More...
 

Protected Member Functions

virtual bool getStatus () const override
 Status of writer. More...
 
virtual int write (const char *buffer, const int length) override
 Write byte array. More...
 
JWriteroperator<< (const JSerialisable &object)
 Write serialisable data object. More...
 
JWriteroperator<< (const bool value)
 
JWriteroperator<< (const char value)
 
JWriteroperator<< (const unsigned char value)
 
JWriteroperator<< (const short value)
 
JWriteroperator<< (const unsigned short value)
 
JWriteroperator<< (const int value)
 
JWriteroperator<< (const unsigned int value)
 
JWriteroperator<< (const long int value)
 
JWriteroperator<< (const unsigned long int value)
 
JWriteroperator<< (const long long int value)
 
JWriteroperator<< (const unsigned long long int value)
 
JWriteroperator<< (const float value)
 
JWriteroperator<< (const double value)
 
JWriteroperator<< (const long double value)
 
JWriteroperator<< (const JLANG::JObjectID &value)
 
JWriterstore (const JSerialisable &object)
 Write object. More...
 
template<class T >
JWriterstore (const T &object)
 Write object. More...
 
 operator bool () const
 Type conversion operator. More...
 
bool operator! () const
 Negated status of this object. More...
 

Protected Attributes

std::ostream & out
 

Static Protected Attributes

static bool do_throw
 throw option More...
 

Detailed Description

template<class T>
class JIO::JBinaryFileWriter< T >

Object(s) writing to binary file.

This class implements the JLANG::JAccessibleObjectOutput interface.

Definition at line 32 of file JBinaryFileWriter.hh.

Constructor & Destructor Documentation

template<class T>
JIO::JBinaryFileWriter< T >::JBinaryFileWriter ( )
inline

Default constructor.

Definition at line 42 of file JBinaryFileWriter.hh.

42  :
44  JStreamWriter (static_cast<std::ostream&>(*this)),
45  JWriterObjectOutput<T>(static_cast<JWriter&> (*this))
46  {}
Interface for binary output.
JAccessibleBinaryOutputStream()
Default constructor.
JStreamWriter(std::ostream &__out)
Constructor.
Definition: JStreamIO.hh:90
Implementation of object output using JIO::JWriter for single data type.

Member Function Documentation

virtual void JLANG::JAccessibleBinaryOutputStream::open ( const char *  file_name)
inlineoverridevirtualinherited

Open file.

Parameters
file_namefile name

Reimplemented from JLANG::JAccessibleOutputStream.

Definition at line 92 of file JAccessibleBinaryStream.hh.

93  {
94  std::ofstream::open(file_name, std::ios::binary);
95  }
T * open(const std::string &file_name)
Open file.
Definition: JeepToolkit.hh:306
virtual bool JLANG::JAccessibleOutputStream::is_open ( ) const
inlinevirtualinherited

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 118 of file JAccessibleStream.hh.

119  {
120  return std::ofstream::is_open();
121  }
virtual void JLANG::JAccessibleOutputStream::close ( )
inlinevirtualinherited

Close file.

Implements JLANG::JAccessible.

Definition at line 142 of file JAccessibleStream.hh.

143  {
145  }
void close(std::istream *pf)
Close file.
Definition: JeepToolkit.hh:346
static void JLANG::JThrow< JAccessible >::Throw ( const bool  option)
inlinestaticinherited

Enable/disable throw option.

Parameters
optiontrue enable; false disable

Definition at line 37 of file JThrow.hh.

38  {
39  do_throw = option;
40  }
static bool do_throw
throw option
Definition: JThrow.hh:28
static int JLANG::JThrow< JAccessible >::Throw ( const JException error,
const int  value = -1 
)
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 50 of file JThrow.hh.

51  {
52  using namespace std;
53 
54  if (do_throw) {
55  throw error;
56  }
57 
58  cerr << error.what() << endl;
59 
60  return value;
61  }
virtual const char * what() const override
Get error message.
Definition: JException.hh:48
static bool do_throw
throw option
Definition: JThrow.hh:28
virtual bool JIO::JStreamWriter::getStatus ( ) const
inlineoverridevirtualinherited

Status of writer.

Returns
status of this writer

Implements JLANG::JAbstractObjectStatus.

Definition at line 100 of file JStreamIO.hh.

101  {
102  return (bool) out;
103  }
std::ostream & out
Definition: JStreamIO.hh:121
virtual int JIO::JStreamWriter::write ( const char *  buffer,
const int  length 
)
inlineoverridevirtualinherited

Write byte array.

Parameters
bufferpointer to byte array
lengthnumber of bytes
Returns
number of bytes written

Implements JLANG::JBinaryOutput.

Definition at line 113 of file JStreamIO.hh.

114  {
115  out.write(buffer, length);
116 
117  return length;
118  }
std::ostream & out
Definition: JStreamIO.hh:121
JWriter& JIO::JWriter::operator<< ( const JSerialisable object)
inlineinherited

Write serialisable data object.

Parameters
objectserialisable data object
Returns
JWriter

Definition at line 144 of file JSerialisable.hh.

145  {
146  return object.write(*this);
147  }
JWriter& JIO::JWriter::operator<< ( const bool  value)
inlineinherited

Definition at line 150 of file JSerialisable.hh.

150 { write((const char*) &value, sizeof(bool)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const char  value)
inlineinherited

Definition at line 151 of file JSerialisable.hh.

151 { write((const char*) &value, sizeof(char)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const unsigned char  value)
inlineinherited

Definition at line 152 of file JSerialisable.hh.

152 { write((const char*) &value, sizeof(unsigned char)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const short  value)
inlineinherited

Definition at line 153 of file JSerialisable.hh.

153 { write((const char*) &value, sizeof(short)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const unsigned short  value)
inlineinherited

Definition at line 154 of file JSerialisable.hh.

154 { write((const char*) &value, sizeof(unsigned short)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const int  value)
inlineinherited

Definition at line 155 of file JSerialisable.hh.

155 { write((const char*) &value, sizeof(int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const unsigned int  value)
inlineinherited

Definition at line 156 of file JSerialisable.hh.

156 { write((const char*) &value, sizeof(unsigned int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const long int  value)
inlineinherited

Definition at line 157 of file JSerialisable.hh.

157 { write((const char*) &value, sizeof(long int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const unsigned long int  value)
inlineinherited

Definition at line 158 of file JSerialisable.hh.

158 { write((const char*) &value, sizeof(unsigned long int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const long long int  value)
inlineinherited

Definition at line 159 of file JSerialisable.hh.

159 { write((const char*) &value, sizeof(long long int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const unsigned long long int  value)
inlineinherited

Definition at line 160 of file JSerialisable.hh.

160 { write((const char*) &value, sizeof(unsigned long long int)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const float  value)
inlineinherited

Definition at line 161 of file JSerialisable.hh.

161 { write((const char*) &value, sizeof(float)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const double  value)
inlineinherited

Definition at line 162 of file JSerialisable.hh.

162 { write((const char*) &value, sizeof(double)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const long double  value)
inlineinherited

Definition at line 163 of file JSerialisable.hh.

163 { write((const char*) &value, sizeof(long double)); return *this; }
virtual int write(const char *buffer, const int length)=0
Write byte array.
JWriter& JIO::JWriter::operator<< ( const JLANG::JObjectID value)
inlineinherited

Definition at line 164 of file JSerialisable.hh.

164 { return (*this) << value.getID(); }
int getID() const
Get identifier.
Definition: JObjectID.hh:50
JWriter& JIO::JWriter::store ( const JSerialisable object)
inlineinherited

Write object.

Parameters
objectobject
Returns
this writer

Definition at line 173 of file JSerialisable.hh.

174  {
175  return object.write(*this);
176  }
template<class T >
JWriter& JIO::JWriter::store ( const T object)
inlineinherited

Write object.

Parameters
objectobject
Returns
this writer

Definition at line 186 of file JSerialisable.hh.

187  {
188  return *this << object;
189  }
JLANG::JAbstractObjectStatus::operator bool ( ) const
inlineinherited

Type conversion operator.

Returns
status of this object

Definition at line 33 of file JAbstractObjectStatus.hh.

34  {
35  return this->getStatus();
36  }
virtual bool getStatus() const =0
Get status of object.
bool JLANG::JAbstractObjectStatus::operator! ( ) const
inlineinherited

Negated status of this object.

Returns
negated status of this object

Definition at line 44 of file JAbstractObjectStatus.hh.

45  {
46  return !(this->getStatus());
47  }
virtual bool getStatus() const =0
Get status of object.
template<class T>
virtual bool JIO::JWriterObjectOutput< T >::put ( const T object)
inlineoverridevirtualinherited

Object output.

Parameters
objectobject
Returns
true if OK; else false

Implements JLANG::JObjectOutput< T >.

Definition at line 50 of file JWriterObjectOutput.hh.

51  {
52  out << object;
53 
54  return (bool) out;
55  }

Member Data Documentation

bool JLANG::JThrow< JAccessible >::do_throw
staticprotectedinherited

throw option

Set default throw option to true.

Definition at line 28 of file JThrow.hh.

std::ostream& JIO::JStreamWriter::out
protectedinherited

Definition at line 121 of file JStreamIO.hh.


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