Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JAccessibleInputStream Class Reference

Accessible input stream. More...

#include <JAccessibleStream.hh>

Inheritance diagram for JLANG::JAccessibleInputStream:
JLANG::JAccessible JLANG::JThrow< JAccessible > JLANG::JASCIIFileReader< T > JLANG::JAccessibleBinaryInputStream JIO::JBinaryFileReader< T, true > JSUPPORT::JDAQFileReader< T, true >

Public Member Functions

 JAccessibleInputStream ()
 Default constructor.
 
 JAccessibleInputStream (const char *file_name)
 Constructor.
 
virtual bool is_open () const
 Check is file is open.
 
virtual void open (const char *file_name)
 Open file.
 
virtual void close ()
 Close file.
 

Static Public Member Functions

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

Static Protected Attributes

static bool do_throw
 throw option
 

Detailed Description

Accessible input stream.

This class is a simple wrapper around the std::ifstream class. It implements the JAccessible interface.

Definition at line 25 of file JAccessibleStream.hh.

Constructor & Destructor Documentation

◆ JAccessibleInputStream() [1/2]

JLANG::JAccessibleInputStream::JAccessibleInputStream ( )
inline

Default constructor.

Definition at line 33 of file JAccessibleStream.hh.

34 {}

◆ JAccessibleInputStream() [2/2]

JLANG::JAccessibleInputStream::JAccessibleInputStream ( const char * file_name)
inline

Constructor.

Parameters
file_namefile name

Definition at line 42 of file JAccessibleStream.hh.

43 {
44 open(file_name);
45 }
virtual void open(const char *file_name)
Open file.

Member Function Documentation

◆ is_open()

virtual bool JLANG::JAccessibleInputStream::is_open ( ) const
inlinevirtual

Check is file is open.

Returns
true if open; else false

Implements JLANG::JAccessible.

Definition at line 53 of file JAccessibleStream.hh.

54 {
55 return std::ifstream::is_open();
56 }

◆ open()

virtual void JLANG::JAccessibleInputStream::open ( const char * file_name)
inlinevirtual

Open file.

Parameters
file_namefile name

Implements JLANG::JAccessible.

Reimplemented in JLANG::JAccessibleBinaryInputStream.

Definition at line 64 of file JAccessibleStream.hh.

65 {
66 std::ifstream::open(file_name);
67
68 if (!this->is_open()) {
69 Throw(JFileOpenException(std::string("Error opening file ") + file_name));
70 }
71 }
virtual bool is_open() const
Check is file is open.
static void Throw(const bool option)
Definition JThrow.hh:37

◆ close()

virtual void JLANG::JAccessibleInputStream::close ( )
inlinevirtual

Close file.

Implements JLANG::JAccessible.

Definition at line 77 of file JAccessibleStream.hh.

78 {
79 std::ifstream::close();
80 }

◆ Throw() [1/2]

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 }

◆ Throw() [2/2]

static int JLANG::JThrow< JAccessible >::Throw ( const JException_t & error,
const int value = -1 )
inlinestaticinherited

Throw exception or return error.

Parameters
errorexception
valuereturn code
Returns
return code

Definition at line 51 of file JThrow.hh.

52 {
53 using namespace std;
54
55 if (do_throw) {
56 throw error;
57 }
58
59 cerr << error.what() << endl;
60
61 return value;
62 }

Member Data Documentation

◆ do_throw

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: