Jpp
Public Member Functions | Protected Attributes | List of all members
JIO::JByteArrayReader Class Reference

Byte array binary input. More...

#include <JByteArrayIO.hh>

Inheritance diagram for JIO::JByteArrayReader:
JIO::JReader JLANG::JBinaryInput JLANG::JAbstractObjectStatus JNET::JSocketInputChannel< JPrefix_t >

Public Member Functions

 JByteArrayReader ()
 Default constructor. More...
 
 JByteArrayReader (const char *buffer, const int length=0)
 Constructor. More...
 
int size () const
 Get size. More...
 
const char * data () const
 Get data. More...
 
int getRemainingSize () const
 Get remaining size. More...
 
const char * getRemainingData () const
 Get remaining data. More...
 
int tellg () const
 Get read position. More...
 
void seekg (const int pos)
 Set read position. More...
 
virtual bool getStatus () const
 Status of reader. More...
 
virtual int read (char *buffer, const int length)
 Read byte array. More...
 
virtual void clear ()
 Clear status of reader. More...
 
JReaderoperator>> (JSerialisable &object)
 Read serialisable data object. More...
 
JReaderoperator>> (bool &value)
 
JReaderoperator>> (char &value)
 
JReaderoperator>> (unsigned char &value)
 
JReaderoperator>> (short &value)
 
JReaderoperator>> (unsigned short &value)
 
JReaderoperator>> (int &value)
 
JReaderoperator>> (unsigned int &value)
 
JReaderoperator>> (long int &value)
 
JReaderoperator>> (unsigned long int &value)
 
JReaderoperator>> (long long int &value)
 
JReaderoperator>> (unsigned long long int &value)
 
JReaderoperator>> (float &value)
 
JReaderoperator>> (double &value)
 
JReaderoperator>> (long double &value)
 
JReaderload (JSerialisable &object)
 Read object. More...
 
template<class T >
JReaderload (T &object)
 Read object. More...
 
 operator bool () const
 Type conversion operator. More...
 
bool operator! () const
 Negated status of this object. More...
 

Protected Attributes

const char * __data
 
int __size
 
int __pos
 

Detailed Description

Byte array binary input.

This class implements the JReader interface.

Definition at line 25 of file JByteArrayIO.hh.

Constructor & Destructor Documentation

◆ JByteArrayReader() [1/2]

JIO::JByteArrayReader::JByteArrayReader ( )
inline

Default constructor.

Definition at line 32 of file JByteArrayIO.hh.

32  :
33  __data(NULL),
34  __size(0),
35  __pos (0)
36  {}

◆ JByteArrayReader() [2/2]

JIO::JByteArrayReader::JByteArrayReader ( const char *  buffer,
const int  length = 0 
)
inline

Constructor.

Parameters
bufferpointer to input data
lengthnumber of bytes

Definition at line 45 of file JByteArrayIO.hh.

45  :
46  __data(buffer),
47  __size(length),
48  __pos (0)
49  {}

Member Function Documentation

◆ size()

int JIO::JByteArrayReader::size ( ) const
inline

Get size.

Returns
number of bytes

Definition at line 57 of file JByteArrayIO.hh.

58  {
59  return __size;
60  }

◆ data()

const char* JIO::JByteArrayReader::data ( ) const
inline

Get data.

Returns
pointer to data

Definition at line 68 of file JByteArrayIO.hh.

69  {
70  return __data;
71  }

◆ getRemainingSize()

int JIO::JByteArrayReader::getRemainingSize ( ) const
inline

Get remaining size.

Returns
number of bytes

Definition at line 79 of file JByteArrayIO.hh.

80  {
81  return __size - __pos;
82  }

◆ getRemainingData()

const char* JIO::JByteArrayReader::getRemainingData ( ) const
inline

Get remaining data.

Returns
pointer to remaining data

Definition at line 90 of file JByteArrayIO.hh.

91  {
92  return __data + __pos;
93  }

◆ tellg()

int JIO::JByteArrayReader::tellg ( ) const
inline

Get read position.

Returns
read position

Definition at line 101 of file JByteArrayIO.hh.

102  {
103  return __pos;
104  }

◆ seekg()

void JIO::JByteArrayReader::seekg ( const int  pos)
inline

Set read position.

Parameters
posread position

Definition at line 112 of file JByteArrayIO.hh.

113  {
114  __pos = pos;
115  }

◆ getStatus()

virtual bool JIO::JByteArrayReader::getStatus ( ) const
inlinevirtual

Status of reader.

Returns
status of this reader

Implements JLANG::JAbstractObjectStatus.

Definition at line 123 of file JByteArrayIO.hh.

124  {
125  return __size - __pos >= 0;
126  }

◆ read()

virtual int JIO::JByteArrayReader::read ( char *  buffer,
const int  length 
)
inlinevirtual

Read byte array.

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

Implements JLANG::JBinaryInput.

Definition at line 136 of file JByteArrayIO.hh.

137  {
138  memcpy(buffer, __data + __pos, length);
139 
140  __pos += length;
141 
142  return length;
143  }

◆ clear()

virtual void JIO::JReader::clear ( )
inlinevirtualinherited

Clear status of reader.

Reimplemented in JIO::JBufferedReader, and JIO::JStreamReader.

Definition at line 70 of file JSerialisable.hh.

71  {}

◆ operator>>() [1/15]

JReader& JIO::JReader::operator>> ( JSerialisable object)
inlineinherited

Read serialisable data object.

Parameters
objectserialisable data object
Returns
JReader

Definition at line 80 of file JSerialisable.hh.

81  {
82  return object.read(*this);
83  }

◆ operator>>() [2/15]

JReader& JIO::JReader::operator>> ( bool &  value)
inlineinherited

Definition at line 86 of file JSerialisable.hh.

86 { read((char*) &value, sizeof(bool)); return *this; }

◆ operator>>() [3/15]

JReader& JIO::JReader::operator>> ( char &  value)
inlineinherited

Definition at line 87 of file JSerialisable.hh.

87 { read((char*) &value, sizeof(char)); return *this; }

◆ operator>>() [4/15]

JReader& JIO::JReader::operator>> ( unsigned char &  value)
inlineinherited

Definition at line 88 of file JSerialisable.hh.

88 { read((char*) &value, sizeof(unsigned char)); return *this; }

◆ operator>>() [5/15]

JReader& JIO::JReader::operator>> ( short &  value)
inlineinherited

Definition at line 89 of file JSerialisable.hh.

89 { read((char*) &value, sizeof(short)); return *this; }

◆ operator>>() [6/15]

JReader& JIO::JReader::operator>> ( unsigned short &  value)
inlineinherited

Definition at line 90 of file JSerialisable.hh.

90 { read((char*) &value, sizeof(unsigned short)); return *this; }

◆ operator>>() [7/15]

JReader& JIO::JReader::operator>> ( int &  value)
inlineinherited

Definition at line 91 of file JSerialisable.hh.

91 { read((char*) &value, sizeof(int)); return *this; }

◆ operator>>() [8/15]

JReader& JIO::JReader::operator>> ( unsigned int &  value)
inlineinherited

Definition at line 92 of file JSerialisable.hh.

92 { read((char*) &value, sizeof(unsigned int)); return *this; }

◆ operator>>() [9/15]

JReader& JIO::JReader::operator>> ( long int &  value)
inlineinherited

Definition at line 93 of file JSerialisable.hh.

93 { read((char*) &value, sizeof(long int)); return *this; }

◆ operator>>() [10/15]

JReader& JIO::JReader::operator>> ( unsigned long int &  value)
inlineinherited

Definition at line 94 of file JSerialisable.hh.

94 { read((char*) &value, sizeof(unsigned long int)); return *this; }

◆ operator>>() [11/15]

JReader& JIO::JReader::operator>> ( long long int &  value)
inlineinherited

Definition at line 95 of file JSerialisable.hh.

95 { read((char*) &value, sizeof(long long int)); return *this; }

◆ operator>>() [12/15]

JReader& JIO::JReader::operator>> ( unsigned long long int &  value)
inlineinherited

Definition at line 96 of file JSerialisable.hh.

96 { read((char*) &value, sizeof(unsigned long long int)); return *this; }

◆ operator>>() [13/15]

JReader& JIO::JReader::operator>> ( float &  value)
inlineinherited

Definition at line 97 of file JSerialisable.hh.

97 { read((char*) &value, sizeof(float)); return *this; }

◆ operator>>() [14/15]

JReader& JIO::JReader::operator>> ( double &  value)
inlineinherited

Definition at line 98 of file JSerialisable.hh.

98 { read((char*) &value, sizeof(double)); return *this; }

◆ operator>>() [15/15]

JReader& JIO::JReader::operator>> ( long double &  value)
inlineinherited

Definition at line 99 of file JSerialisable.hh.

99 { read((char*) &value, sizeof(long double)); return *this; }

◆ load() [1/2]

JReader& JIO::JReader::load ( JSerialisable object)
inlineinherited

Read object.

Parameters
objectobject
Returns
this reader

Definition at line 108 of file JSerialisable.hh.

109  {
110  return object.read(*this);
111  }

◆ load() [2/2]

template<class T >
JReader& JIO::JReader::load ( T &  object)
inlineinherited

Read object.

Parameters
objectobject
Returns
this reader

Definition at line 121 of file JSerialisable.hh.

122  {
123  return *this >> object;
124  }

◆ operator bool()

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  }

◆ operator!()

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  }

Member Data Documentation

◆ __data

const char* JIO::JByteArrayReader::__data
protected

Definition at line 147 of file JByteArrayIO.hh.

◆ __size

int JIO::JByteArrayReader::__size
protected

Definition at line 148 of file JByteArrayIO.hh.

◆ __pos

int JIO::JByteArrayReader::__pos
protected

Definition at line 149 of file JByteArrayIO.hh.


The documentation for this class was generated from the following file:
JIO::JByteArrayReader::__size
int __size
Definition: JByteArrayIO.hh:148
JLANG::JBinaryInput::read
virtual int read(char *buffer, const int length)=0
Read byte array.
JIO::JByteArrayReader::__data
const char * __data
Definition: JByteArrayIO.hh:147
JLANG::JAbstractObjectStatus::getStatus
virtual bool getStatus() const =0
Get status of object.
JIO::JByteArrayReader::__pos
int __pos
Definition: JByteArrayIO.hh:149