Jpp  18.4.0
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 | Static Protected Attributes | List of all members
JLANG::JASCIIFileWriter< T > Class Template Reference

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

#include <JASCIIFileWriter.hh>

Inheritance diagram for JLANG::JASCIIFileWriter< T >:
JLANG::JAccessibleOutputStream JLANG::JStreamObjectOutput< T > JLANG::JAccessibleObjectOutput< T > JLANG::JAccessible JLANG::JObjectOutput< T > JLANG::JObjectOutput< T > JLANG::JAccessible JLANG::JThrow< JAccessible > JLANG::JThrow< JAccessible >

Public Member Functions

 JASCIIFileWriter ()
 Default constructor. More...
 
 JASCIIFileWriter (const char *file_name)
 Constructor. More...
 
 JASCIIFileWriter (const char *file_name, const std::string &sep)
 Constructor. More...
 
virtual bool is_open () const
 Check is file is open. More...
 
virtual void open (const char *file_name)
 Open file. More...
 
virtual void close ()
 Close file. More...
 
virtual bool put (const T &object) override
 Object output. More...
 
const std::stringgetSeparator () const
 Get token separator. More...
 
void setSeparator (const std::string &sep)
 Set token separator. 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...
 

Static Protected Attributes

static bool do_throw
 throw option More...
 

Detailed Description

template<class T>
class JLANG::JASCIIFileWriter< T >

Object(s) writing to ASCII file.

This class implements the JAccessibleObjectOutput interface.

Definition at line 27 of file JASCIIFileWriter.hh.

Constructor & Destructor Documentation

template<class T >
JLANG::JASCIIFileWriter< T >::JASCIIFileWriter ( )
inline

Default constructor.

Definition at line 36 of file JASCIIFileWriter.hh.

36  :
38  JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
39  {}
JAccessibleOutputStream()
Default constructor.
Template implementation of stream output for single data type.
template<class T >
JLANG::JASCIIFileWriter< T >::JASCIIFileWriter ( const char *  file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 47 of file JASCIIFileWriter.hh.

47  :
48  JAccessibleOutputStream(file_name),
49  JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), "")
50  {}
JAccessibleOutputStream()
Default constructor.
Template implementation of stream output for single data type.
template<class T >
JLANG::JASCIIFileWriter< T >::JASCIIFileWriter ( const char *  file_name,
const std::string sep 
)
inline

Constructor.

Parameters
file_namefile name
septoken separator

Definition at line 59 of file JASCIIFileWriter.hh.

60  :
61  JAccessibleOutputStream(file_name),
62  JStreamObjectOutput<T>(static_cast<std::ostream&>(*this), sep)
63  {}
JAccessibleOutputStream()
Default constructor.
Template implementation of stream output for single data type.

Member Function Documentation

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::open ( const char *  file_name)
inlinevirtualinherited

Open file.

Parameters
file_namefile name

Implements JLANG::JAccessible.

Reimplemented in JLANG::JAccessibleBinaryOutputStream.

Definition at line 129 of file JAccessibleStream.hh.

130  {
131  std::ofstream::open(file_name);
132 
133  if (!this->is_open()) {
134  Throw(JFileOpenException(std::string("Error opening file ") + file_name));
135  }
136  }
Exception for opening of file.
Definition: JException.hh:358
virtual bool is_open() const
Check is file is open.
T * open(const std::string &file_name)
Open file.
Definition: JeepToolkit.hh:346
then awk string
static void Throw(const bool option)
Enable/disable throw option.
Definition: JThrow.hh:37
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:386
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:64
static bool do_throw
throw option
Definition: JThrow.hh:28
template<class T>
virtual bool JLANG::JStreamObjectOutput< T >::put ( const T object)
inlineoverridevirtualinherited

Object output.

Parameters
objectobject
Returns
true if OK; else false

Implements JLANG::JObjectOutput< T >.

Definition at line 51 of file JStreamObjectOutput.hh.

52  {
53  __out << object << __sep;
54 
55  return (bool) __out;
56  }
template<class T>
const std::string& JLANG::JStreamObjectOutput< T >::getSeparator ( ) const
inlineinherited

Get token separator.

Returns
separator

Definition at line 64 of file JStreamObjectOutput.hh.

65  {
66  return this->__sep;
67  }
template<class T>
void JLANG::JStreamObjectOutput< T >::setSeparator ( const std::string sep)
inlineinherited

Set token separator.

Parameters
sepseparator

Definition at line 75 of file JStreamObjectOutput.hh.

76  {
77  this->__sep = sep;
78  }

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.


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