QDaq  0.2.6
Qt-based Data Aqcuisition
 All Classes Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
bytearrayprototype.h
1 #ifndef BYTEARRAYPROTOTYPE_H
2 #define BYTEARRAYPROTOTYPE_H
3 
4 #include <QtCore/QByteArray>
5 #include <QtCore/QObject>
6 #include <QtScript/QScriptable>
7 #include <QtScript/QScriptValue>
8 
37 class ByteArrayPrototype : public QObject, public QScriptable
38 {
39 Q_OBJECT
40 public:
41  ByteArrayPrototype(QObject *parent = 0);
43 
44 public slots:
46  void chop(int n);
48  void truncate(int pos);
50  bool equals(const QByteArray &other);
52  QByteArray left(int len) const;
54  QByteArray mid(int pos, int len = -1) const;
56  QScriptValue remove(int pos, int len);
58  QByteArray right(int len) const;
59 
61  QString toLatin1String() const;
63  QScriptValue valueOf() const;
64 
65 
94  double readDoubleLE(int offset = 0) const;
96  double readDoubleBE(int offset = 0) const;
97  float readFloatLE(int offset = 0) const;
98  float readFloatBE(int offset = 0) const;
99  int readInt32LE(int offset = 0) const;
100  int readInt32BE(int offset = 0) const;
101  uint readUInt32LE(int offset = 0) const;
102  uint readUInt32BE(int offset = 0) const;
103  int readInt16LE(int offset = 0) const;
104  int readInt16BE(int offset = 0) const;
105  uint readUInt16LE(int offset = 0) const;
106  uint readUInt16BE(int offset = 0) const;
107  int readInt8(int offset = 0) const;
109 
110 
136  void writeDoubleLE(double v, int offset = 0);
138  void writeDoubleBE(double v, int offset = 0);
139  void writeFloatLE(float v, int offset = 0);
140  void writeFloatBE(float v, int offset = 0);
141  void writeInt32LE(int v, int offset = 0);
142  void writeInt32BE(int v, int offset = 0);
143  void writeUInt32LE(uint v, int offset = 0);
144  void writeUInt32BE(uint v, int offset = 0);
145  void writeInt16LE(int v, int offset = 0);
146  void writeInt16BE(int v, int offset = 0);
147  void writeUInt16LE(uint v, int offset = 0);
148  void writeUInt16BE(uint v, int offset = 0);
149  void writeInt8(int v, int offset = 0);
151 
152 private:
153  QByteArray *thisByteArray() const;
154 
155  bool checkRange(int offset, int sz) const;
156 };
158 
159 
160 #endif
QByteArray left(int len) const
Returns a ByteArray with the len leftmost bytes.
The prototype for the ByteArray class.
void truncate(int pos)
Truncates the array at pos.
QScriptValue valueOf() const
Return the data stored by the object.
QString toLatin1String() const
Convert to a String.
QByteArray right(int len) const
Returns the rightmost len bytes.
bool equals(const QByteArray &other)
Returns true if this ByteArray is equal to other.
QByteArray mid(int pos, int len=-1) const
Returns the middle part of the array from pos with length len.
void chop(int n)
Removes n bytes from the end of the byte array.