WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZByteArray.h
Go to the documentation of this file.
1 /*
2 * Zuble - A run-time system for QML/Javascript applications
3 * Copyright (C) 2013, 2014 Bob Dinitto
4 *
5 * Filename: ZByteArray.h
6 * Created on: 11/9/2014
7 * Author: Bob Dinitto
8 *
9 * Zuble is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 */
24 
25 #ifndef ZBYTEARRAY_H
26 #define ZBYTEARRAY_H
27 
28 #include <QObject>
29 #include <QVariant>
30 #include <QSharedPointer>
31 #include "zglobal.h"
32 
33 namespace Zbl
34 {
35 
41 class ZByteArray : public QObject
42 {
43  friend class ZFile;
44  friend class ZTextStream;
45  Q_OBJECT
46 public:
47  explicit ZByteArray(QObject *parent = 0);
48  explicit ZByteArray(const QByteArray& byteArray, QObject *parent = 0);
49  explicit ZByteArray(ZqByteArrayPtr byteArray, QObject *parent = 0);
50 
52 
57  static void registerType();
58 
59  Q_PROPERTY(uint size READ getSize)
60  Q_PROPERTY(bool isEmpty READ isEmpty)
61 
62  int getSize() const;
63  bool isEmpty();
64 
65  Q_INVOKABLE void jAppend(QList<int> data);
66  Q_INVOKABLE void stringAppend(const QString& text);
67  Q_INVOKABLE QList<int> toArray();
68  Q_INVOKABLE QString getString();
69 
70  Q_INVOKABLE int at(int index) const;
71 
72  Q_INVOKABLE void clear();
73 
74  Q_INVOKABLE QString toHexString() const;
75 
76 
77 
78  // append(string, number, array of strings, array of numbers, ZByteArray)
79  // appendString(string)
80  // appendStrings(string[])
81  // appendInt(number)
82  // appendInts(number[s])
83  // appendFloat(number)
84  // appendFloats(number[])
85  // prepend(string, number, array of strings, array of numbers, ZByteArray)
86  // insert(string, number, array of strings, array of numbers, ZByteArray)
87  // getByte(index): returns number
88  // getChar(index): returns string
89  // getString(index, len[zero=line]): returns multi-character string
90  // toString: returns multi-char string
91  // toArray: returns number array
92  // chop(size)
93  // clear
94 
95 
96 signals:
97 
98 public slots:
99 
100 
101 protected:
102 
104 
105 };
106 
107 
108 } // Zbl
109 
110 #endif // ZBYTEARRAY_H
This class supports streaming of text and binary data.
Definition: ZByteArray.h:41
static void registerType()
Registers ZByteArray as a QML type.
Definition: ZByteArray.cpp:54
int getSize() const
Definition: ZByteArray.cpp:60
Q_INVOKABLE QString toHexString() const
Definition: ZByteArray.cpp:89
Q_INVOKABLE int at(int index) const
Definition: ZByteArray.cpp:74
A javascript wrapper for QFile.
Definition: ZFile.h:53
Definition: ZAndGate.cpp:6
Q_INVOKABLE void stringAppend(const QString &text)
Definition: ZByteArray.cpp:119
ZByteArray(QObject *parent=0)
Definition: ZByteArray.cpp:32
Q_INVOKABLE QString getString()
Definition: ZByteArray.cpp:138
QSharedPointer< QByteArray > ZqByteArrayPtr
Definition: zglobal.h:166
Q_INVOKABLE void jAppend(QList< int > data)
Definition: ZByteArray.cpp:110
ZqByteArrayPtr qByteArray()
Definition: ZByteArray.h:51
Reads and writes UTF-8 text to an i/o stream.
Definition: ZTextStream.h:49
ZqByteArrayPtr m_ba
Definition: ZByteArray.h:103
Q_INVOKABLE void clear()
Definition: ZByteArray.cpp:81
Q_INVOKABLE QList< int > toArray()
Definition: ZByteArray.cpp:127