Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
JIO::JByteArrayWriter Class Reference

Byte array binary output. More...

#include <JByteArrayIO.hh>

Inheritance diagram for JIO::JByteArrayWriter:
JIO::JWriter std::vector< char > JLANG::JBinaryOutput JLANG::JAbstractObjectStatus JNET::JSocketOutputChannel< JPrefix_t >

Public Member Functions

 JByteArrayWriter (const int size=65536)
 Constructor. More...
 
virtual bool getStatus () const
 Status of writer. More...
 
void clear ()
 Clear buffer. More...
 
int tellp () const
 Get write position. More...
 
void seekp (const int pos)
 Set write position. More...
 
virtual int write (const char *buffer, const int length)
 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)
 
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

int __pos
 

Detailed Description

Byte array binary output.

This class implements the JWriter interface.

Definition at line 157 of file JByteArrayIO.hh.

Constructor & Destructor Documentation

JIO::JByteArrayWriter::JByteArrayWriter ( const int  size = 65536)
inline

Constructor.

Parameters
sizereserved number of bytes

Definition at line 167 of file JByteArrayIO.hh.

167  :
169  __pos(0)
170  {
171  reserve(size);
172  }

Member Function Documentation

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

Status of writer.

Returns
status of this writer

Implements JLANG::JAbstractObjectStatus.

Definition at line 180 of file JByteArrayIO.hh.

181  {
182  return true;
183  }
void JIO::JByteArrayWriter::clear ( )
inline

Clear buffer.

Definition at line 189 of file JByteArrayIO.hh.

190  {
192 
193  __pos = 0;
194  }
int JIO::JByteArrayWriter::tellp ( ) const
inline

Get write position.

Returns
write position

Definition at line 202 of file JByteArrayIO.hh.

203  {
204  return __pos;
205  }
void JIO::JByteArrayWriter::seekp ( const int  pos)
inline

Set write position.

Parameters
poswrite position

Definition at line 213 of file JByteArrayIO.hh.

214  {
215  __pos = pos;
216  }
virtual int JIO::JByteArrayWriter::write ( const char *  buffer,
const int  length 
)
inlinevirtual

Write byte array.

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

Implements JLANG::JBinaryOutput.

Definition at line 226 of file JByteArrayIO.hh.

227  {
228  if (__pos + length > (int) this->size()) {
229  this->resize(__pos + length);
230  }
231 
232  memcpy(this->data() + __pos, buffer, length);
233 
234  __pos += length;
235 
236  return length;
237  }
JWriter& JIO::JWriter::operator<< ( const JSerialisable object)
inlineinherited

Write serialisable data object.

Parameters
objectserialisable data object
Returns
JWriter

Definition at line 142 of file JSerialisable.hh.

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

Definition at line 148 of file JSerialisable.hh.

148 { 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 149 of file JSerialisable.hh.

149 { 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 150 of file JSerialisable.hh.

150 { 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 151 of file JSerialisable.hh.

151 { 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 152 of file JSerialisable.hh.

152 { 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 153 of file JSerialisable.hh.

153 { 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 154 of file JSerialisable.hh.

154 { 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 155 of file JSerialisable.hh.

155 { 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 156 of file JSerialisable.hh.

156 { 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 157 of file JSerialisable.hh.

157 { 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 158 of file JSerialisable.hh.

158 { 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 159 of file JSerialisable.hh.

159 { 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 160 of file JSerialisable.hh.

160 { 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 161 of file JSerialisable.hh.

161 { 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::store ( const JSerialisable object)
inlineinherited

Write object.

Parameters
objectobject
Returns
this writer

Definition at line 170 of file JSerialisable.hh.

171  {
172  return object.write(*this);
173  }
template<class T >
JWriter& JIO::JWriter::store ( const T object)
inlineinherited

Write object.

Parameters
objectobject
Returns
this writer

Definition at line 183 of file JSerialisable.hh.

184  {
185  return *this << object;
186  }
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.

Member Data Documentation

int JIO::JByteArrayWriter::__pos
protected

Definition at line 241 of file JByteArrayIO.hh.


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