Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JFileIO.hh
Go to the documentation of this file.
1#ifndef __JIO__JFILEIO__
2#define __JIO__JFILEIO__
3
4#include <fcntl.h>
5
7#include "JLang/JFile.hh"
8
9
10/**
11 * \author mdejong
12 */
13
14namespace JIO {}
15namespace JPP { using namespace JIO; }
16
17namespace JIO {
18
19 using JLANG::JFile;
20
21
22 /**
23 * Binary input based on a file descriptor.
24 * This class implements the JReader interface.
25 */
27 public JReader
28 {
29 public:
30 /**
31 * Constructor.
32 *
33 * \param file file
34 */
35 JFileReader(const JFile& file) :
36 in(file)
37 {}
38
39
40 /**
41 * Status of reader.
42 *
43 * \return status of this reader
44 */
45 virtual bool getStatus() const override
46 {
47 return in.good();
48 }
49
50
51 /**
52 * Read byte array.
53 *
54 * \param buffer pointer to byte array
55 * \param length number of bytes
56 * \return number of bytes read
57 */
58 virtual int read(char* buffer, const int length) override
59 {
60 return in.read(buffer, length);
61 }
62
63 protected:
65 };
66
67
68 /**
69 * Binary output based on a file descriptor.
70 * This class implements the JWriter interface.
71 */
72 class JFileWriter :
73 public JWriter
74 {
75 public:
76 /**
77 * Constructor.
78 *
79 * \param file file
80 */
81 JFileWriter(const JFile& file) :
82 out(file)
83 {}
84
85
86 /**
87 * Status of writer.
88 *
89 * \return status of this writer
90 */
91 virtual bool getStatus() const override
92 {
93 return out.good();
94 }
95
96
97 /**
98 * Write byte array.
99 *
100 * \param buffer pointer to byte array
101 * \param length number of bytes
102 * \return number of bytes written
103 */
104 virtual int write(const char* buffer, const int length) override
105 {
106 return out.write(buffer, length);
107 }
108
109 protected:
111 };
112}
113
114#endif
Binary input based on a file descriptor.
Definition JFileIO.hh:28
virtual int read(char *buffer, const int length) override
Read byte array.
Definition JFileIO.hh:58
virtual bool getStatus() const override
Status of reader.
Definition JFileIO.hh:45
JFileReader(const JFile &file)
Constructor.
Definition JFileIO.hh:35
Binary output based on a file descriptor.
Definition JFileIO.hh:74
virtual int write(const char *buffer, const int length) override
Write byte array.
Definition JFileIO.hh:104
virtual bool getStatus() const override
Status of writer.
Definition JFileIO.hh:91
JFileWriter(const JFile &file)
Constructor.
Definition JFileIO.hh:81
Interface for binary input.
Interface for binary output.
The JFile class extends the JAbstractFile class.
Definition JFile.hh:30
virtual bool good() const
Check status.
Definition JFile.hh:130
virtual int write(const char *buffer, const int length)
Write data to file.
Definition JFile.hh:93
virtual int read(char *buffer, const int length)
Read data from file.
Definition JFile.hh:80
Auxiliary classes and methods for binary I/O.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).