Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QBuffer Class Reference

The QBuffer class provides a QIODevice interface for a QByteArray. More...

Inheritance diagram for QtCore.QBuffer:
Collaboration diagram for QtCore.QBuffer:

Public Member Functions

 QBuffer (QObject parent=null)
 
 
 QBuffer (QByteArray buf, QObject parent=null)
 
 
override void CreateProxy ()
 
override bool AtEnd ()
 
 
override bool CanReadLine ()
 
 
override void Close ()
 
 
override bool Open (QIODevice.OpenModeFlag openMode)
 
 
override long Pos ()
 
 
override bool Seek (long off)
 
 
new void SetData (string data, int len)
 
 
override long Size ()
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.QIODevice
 QIODevice ()
 
 
 QIODevice (QObject parent)
 
 
override void CreateProxy ()
 
virtual long BytesAvailable ()
 
 
virtual long BytesToWrite ()
 
 
new string ErrorString ()
 
 
new bool GetChar (Pointer< sbyte > c)
 
 
new bool IsOpen ()
 
 
new bool IsReadable ()
 
 
virtual bool IsSequential ()
 
 
new bool IsTextModeEnabled ()
 
 
new bool IsWritable ()
 
 
new QIODevice.OpenModeFlag OpenMode ()
 
 
new QByteArray Peek (long maxlen)
 
 
new long Peek (Pointer< sbyte > data, long maxlen)
 
 
new bool PutChar (sbyte c)
 
 
new QByteArray Read (long maxlen)
 
 
new long Read (Pointer< sbyte > data, long maxlen)
 
 
new QByteArray ReadAll ()
 
 
new QByteArray ReadLine (long maxlen=0)
 
 
new long ReadLine (Pointer< sbyte > data, long maxlen)
 
 
virtual bool Reset ()
 
 
new void SetTextModeEnabled (bool enabled)
 
 
new void UngetChar (sbyte c)
 
 
virtual bool WaitForBytesWritten (int msecs)
 
 
virtual bool WaitForReadyRead (int msecs)
 
 
new long Write (QByteArray data)
 
 
new long Write (string data)
 
 
new long Write (string data, long len)
 
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.QObject
 QObject (QObject parent=null)
 
 
new bool BlockSignals (bool b)
 
 
new
System.Collections.Generic.List
< QObject
Children ()
 
 
new bool Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
new void DeleteLater ()
 
 
new bool Disconnect (QObject receiver, string member=null)
 
 
new bool Disconnect (string signal=null, QObject receiver=null, string member=null)
 
 
new void DumpObjectInfo ()
 
 
new void DumpObjectTree ()
 
 
new
System.Collections.Generic.List
< QByteArray
DynamicPropertyNames ()
 
 
virtual bool OnEvent (QEvent arg1)
 
 
virtual bool EventFilter (QObject arg1, QEvent arg2)
 
 
new bool Inherits (string classname)
 
 
new void InstallEventFilter (QObject arg1)
 
 
new bool IsWidgetType ()
 
 
new void KillTimer (int id)
 
 
new object Property (string name)
 
 
new void RemoveEventFilter (QObject arg1)
 
 
new bool SetProperty (string name, object value)
 
 
new void SetUserData (uint id, QObjectUserData data)
 
new bool SignalsBlocked ()
 
 
new int StartTimer (int interval)
 
 
new QObjectUserData UserData (uint id)
 
new void Dispose ()
 
- Public Member Functions inherited from QtCore.Qt
delegate QTextStream FuncQTextStreamQTextStream (QTextStream qTextStream)
 
delegate string FuncStringQByteArray (QByteArray qByteArray)
 
delegate QByteArray FuncQByteArrayString (string @string)
 
delegate void ActionQtMsgTypeString (QtMsgType qtMsgType, string @string)
 
delegate QObject FuncQObject ()
 

Static Public Member Functions

static string Tr (string s, string c=null)
 
static string Tr (string s, string c, int n)
 
static string TrUtf8 (string s, string c=null)
 
static string TrUtf8 (string s, string c, int n)
 
- Static Public Member Functions inherited from QtCore.QIODevice
static string Tr (string s, string c=null)
 
static string Tr (string s, string c, int n)
 
static string TrUtf8 (string s, string c=null)
 
static string TrUtf8 (string s, string c, int n)
 
- Static Public Member Functions inherited from QtCore.QObject
static bool Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection)
 
 
static bool Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection)
 
 
static bool Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member)
 
 
static bool Disconnect (QObject sender, string signal, QObject receiver, string member)
 
 
static uint RegisterUserData ()
 
static string Tr (string s, string c=null)
 
 
static string Tr (string s, string c, int n)
 
 
static string TrUtf8 (string s, string c=null)
 
 
static string TrUtf8 (string s, string c, int n)
 
 
- Static Public Member Functions inherited from QtCore.Qt
static QDataStream Write (QDataStream s, object p)
 
static QDataStream Write (QDataStream arg1, QSizeF arg2)
 
static QTextStream Write (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Write (QDataStream arg1, QPoint arg2)
 
static QDataStream Write (QDataStream arg1, QLineF arg2)
 
static QDataStream Write (QDataStream arg1, QPointF arg2)
 
static QDataStream Write (QDataStream arg1, QChar arg2)
 
static QDataStream Write (QDataStream arg1, QByteArray arg2)
 
static QDataStream Write (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Write (QDataStream arg1, QRectF arg2)
 
static QDataStream Write (QDataStream arg1, QDateTime arg2)
 
static QDataStream Write (QDataStream arg1, QUrl arg2)
 
static QDataStream Write (QDataStream arg1, QTime arg2)
 
static QDataStream Write (QDataStream arg1, QLocale arg2)
 
static QDataStream Write (QDataStream arg1, QBitArray arg2)
 
static QDataStream Write (QDataStream arg1, QUuid arg2)
 
static QDataStream Write (QDataStream arg1, QLine arg2)
 
static QDataStream Write (QDataStream arg1, QDate arg2)
 
static QDataStream Write (QDataStream @out, QRegExp regExp)
 
static QDataStream Write (QDataStream arg1, QRect arg2)
 
static QDataStream Write (QDataStream arg1, QSize arg2)
 
static QDataStream Write (QDataStream s, QVariant.Type p)
 
static QDataStream Write (QDataStream arg1, string arg2)
 
static QDataStream Write (QDataStream @out, System.Collections.Generic.List< string > list)
 
static QDataStream Read (QDataStream arg1, QChar arg2)
 
static QDataStream Read (QDataStream arg1, QLocale arg2)
 
static QDataStream Read (QDataStream arg1, QRect arg2)
 
static QDataStream Read (QDataStream arg1, QEasingCurve arg2)
 
static QDataStream Read (QDataStream arg1, QDate arg2)
 
static QDataStream Read (QDataStream arg1, QUrl arg2)
 
static QDataStream Read (QDataStream arg1, QUuid arg2)
 
static QTextStream Read (QTextStream s, Qt.FuncQTextStreamQTextStream f)
 
static QDataStream Read (QDataStream arg1, QLineF arg2)
 
static QDataStream Read (QDataStream arg1, QRectF arg2)
 
static QDataStream Read (QDataStream arg1, QPointF arg2)
 
static QDataStream Read (QDataStream arg1, QLine arg2)
 
static QDataStream Read (QDataStream arg1, QBitArray arg2)
 
static QDataStream Read (QDataStream arg1, QSize arg2)
 
static QDataStream Read (QDataStream arg1, QDateTime arg2)
 
static QDataStream Read (QDataStream arg1, QTime arg2)
 
static QDataStream Read (QDataStream arg1, QPoint arg2)
 
static QDataStream Read (QDataStream @in, QRegExp regExp)
 
static QDataStream Read (QDataStream s, object p)
 
static QDataStream Read (QDataStream arg1, QByteArray arg2)
 
static QDataStream Read (QDataStream arg1, QSizeF arg2)
 
static QDataStream Read (QDataStream arg1, string arg2)
 
static QDataStream Read (QDataStream s, QVariant.Type p)
 
static QDataStream Read (QDataStream @in, System.Collections.Generic.List< string > list)
 
static double qAcos (double v)
 
static void qAddPostRoutine (System.Action arg1)
 
static string qAppName ()
 
static double qAsin (double v)
 
static double qAtan (double v)
 
static double qAtan2 (double x, double y)
 
static void qBadAlloc ()
 
static int qCeil (double v)
 
static ushort qChecksum (string s, uint len)
 
static QByteArray qCompress (QByteArray data)
 
static QByteArray qCompress (QByteArray data, int compressionLevel=-1)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes)
 
static QByteArray qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1)
 
static double qCos (double v)
 
static double qExp (double v)
 
static double qFabs (double v)
 
static double qFastCos (double x)
 
static double qFastSin (double x)
 
static string qFlagLocation (string method)
 
static int qFloor (double v)
 
static bool qFuzzyCompare (double p1, double p2)
 
static bool qFuzzyCompare (float p1, float p2)
 
static bool qFuzzyIsNull (double d)
 
static bool qFuzzyIsNull (float f)
 
static uint qHash (QBitArray key)
 
static uint qHash (QChar key)
 
static uint qHash (QStringRef key)
 
static uint qHash (QUrl url)
 
static uint qHash (QPersistentModelIndex index)
 
static uint qHash (QByteArray key)
 
static uint qHash (QModelIndex index)
 
static uint qHash (uint key)
 
static uint qHash (sbyte key)
 
static uint qHash (byte key)
 
static uint qHash (short key)
 
static uint qHash (NativeLong key)
 
static uint qHash (ushort key)
 
static uint qHash (long key)
 
static uint qHash (ulong key)
 
static uint qHash (int key)
 
static uint qHash (string key)
 
static uint qHash (NativeULong key)
 
static double qInf ()
 
static Qt.ActionQtMsgTypeString qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1)
 
static int qIntCast (float f)
 
static int qIntCast (double f)
 
static bool qIsFinite (double d)
 
static bool qIsFinite (float f)
 
static bool qIsInf (float f)
 
static bool qIsInf (double d)
 
static bool qIsNaN (float f)
 
static bool qIsNaN (double d)
 
static bool qIsNull (float f)
 
static bool qIsNull (double d)
 
static double qLn (double v)
 
static double qPow (double x, double y)
 
static double qQNaN ()
 
static void qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function)
 
static void qRemovePostRoutine (System.Action arg1)
 
static int qRound (double d)
 
static long qRound64 (double d)
 
static double qSNaN ()
 
static bool qSharedBuild ()
 
static double qSin (double v)
 
static double qSqrt (double v)
 
static bool qStringComparisonHelper (QStringRef s1, string s2)
 
static double qTan (double v)
 
static QByteArray qUncompress (QByteArray data)
 
static QByteArray qUncompress (Pointer< byte > data, int nbytes)
 
static string qVersion ()
 
static void Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size)
 
static QByteArray Qgetenv (string varName)
 
static bool Qputenv (string varName, QByteArray value)
 
static int Qrand ()
 
static void Qsrand (uint seed)
 
static int Qstrcmp (QByteArray str1, QByteArray str2)
 
static int Qstrcmp (QByteArray str1, string str2)
 
static int Qstrcmp (string str1, QByteArray str2)
 
static int Qstrcmp (string str1, string str2)
 
static Pointer< sbyte > Qstrcpy (Pointer< sbyte > dst, string src)
 
static Pointer< sbyte > Qstrdup (string arg1)
 
static int Qstricmp (string arg1, string arg2)
 
static uint Qstrlen (string str)
 
static int Qstrncmp (string str1, string str2, uint len)
 
static Pointer< sbyte > Qstrncpy (Pointer< sbyte > dst, string src, uint len)
 
static int Qstrnicmp (string arg1, string arg2, uint len)
 
static uint Qstrnlen (string str, uint maxlen)
 
static string QtTrId (string id, int n=-1)
 

Protected Member Functions

 QBuffer (System.Type dummy)
 
override void ConnectNotify (string arg1)
 
 
override void DisconnectNotify (string arg1)
 
 
override long ReadData (Pointer< sbyte > data, long maxlen)
 
 
override long WriteData (string data, long len)
 
 
- Protected Member Functions inherited from QtCore.QIODevice
 QIODevice (System.Type dummy)
 
new void OnAboutToClose ()
 
 
new void OnBytesWritten (long bytes)
 
 
new void OnReadChannelFinished ()
 
 
virtual long ReadLineData (Pointer< sbyte > data, long maxlen)
 
 
new void OnReadyRead ()
 
 
new void SetErrorString (string errorString)
 
 
new void SetOpenMode (QIODevice.OpenModeFlag openMode)
 
 
- Protected Member Functions inherited from QtCore.QObject
 QObject (System.Type dummy)
 
virtual void OnChildEvent (QChildEvent arg1)
 
 
virtual void OnCustomEvent (QEvent arg1)
 
 
new void OnDestroyed (QObject arg1=null)
 
 
new int Receivers (string signal)
 
 
new QObject Sender ()
 
 
new int SenderSignalIndex ()
 
 
virtual void OnTimerEvent (QTimerEvent arg1)
 
 

Properties

new QByteArray Buffer [get, set]
 
 
new QByteArray Data [get, set]
 
 
static new QMetaObject StaticMetaObject [get]
 
new IQBufferSignals Emit [get]
 
- Properties inherited from QtCore.QIODevice
Slot ReadyRead
 
 
Slot< System.Int64 > BytesWritten
 
 
Slot AboutToClose
 
 
Slot ReadChannelFinished
 
 
static new QMetaObject StaticMetaObject [get]
 
new IQIODeviceSignals Emit [get]
 
- Properties inherited from QtCore.QObject
virtual EventHandler
< QEventArgs< QChildEvent > > 
ChildEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
CustomEvent
 
 
virtual EventHandler
< QEventArgs< QEvent > > 
Event
 
 
virtual EventHandler
< QEventArgs< QTimerEvent > > 
TimerEvent
 
 
Slot< QObjectDestroyedQObject
 
Slot Destroyed
 
 
new QObject Parent [get, set]
 
 
virtual System.IntPtr SmokeObject [get, set]
 
new string ObjectName [get, set]
 
 
static new QMetaObject StaticMetaObject [get]
 
 
static new QMetaObject StaticQtMetaObject [get]
 
new IQObjectSignals Emit [get]
 

Additional Inherited Members

- Public Types inherited from QtCore.QIODevice
enum  OpenModeFlag {
  Append = 4, NotOpen = 0, ReadOnly = 1, ReadWrite = 3,
  Text = 16, Truncate = 8, Unbuffered = 32, WriteOnly = 2
}
  More...
 
- Protected Attributes inherited from QtCore.QObject
object Q_EMIT = null
 
SmokeInvocation interceptor
 
readonly List< QEventHandler > eventFilters = new List<QEventHandler>()
 

Detailed Description

The QBuffer class provides a QIODevice interface for a QByteArray.

QBuffer allows you to access a QByteArray using the QIODevice interface. The QByteArray is treated just as a standard random-accessed file. Example:

QBuffer buffer;

char ch;

buffer.open(QBuffer::ReadWrite);

buffer.write("Qt rocks!");

buffer.seek(0);

buffer.getChar(&ch); // ch == 'Q'

buffer.getChar(&ch); // ch == 't'

buffer.getChar(&ch); // ch == ' '

buffer.getChar(&ch); // ch == 'r'

By default, an internal QByteArray buffer is created for you when you create a QBuffer. You can access this buffer directly by calling buffer(). You can also use QBuffer with an existing QByteArray by calling setBuffer(), or by passing your array to QBuffer's constructor.

Call open() to open the buffer. Then call write() or putChar() to write to the buffer, and read(), readLine(), readAll(), or getChar() to read from it. size() returns the current size of the buffer, and you can seek to arbitrary positions in the buffer by calling seek(). When you are done with accessing the buffer, call close().

The following code snippet shows how to write data to a QByteArray using QDataStream and QBuffer:

QByteArray byteArray;

QBuffer buffer(&byteArray);

buffer.open(QIODevice::WriteOnly);

QDataStream out(&buffer);

out << QApplication::palette();

Effectively, we convert the application's QPalette into a byte array. Here's how to read the data from the QByteArray:

QPalette palette;

QBuffer buffer(&byteArray);

buffer.open(QIODevice::ReadOnly);

QDataStream in(&buffer);

in >> palette;

QTextStream and QDataStream also provide convenience constructors that take a QByteArray and that create a QBuffer behind the scenes.

QBuffer emits readyRead() when new data has arrived in the buffer. By connecting to this signal, you can use QBuffer to store temporary data before processing it. For example, you can pass the buffer to QFtp when downloading a file from an FTP server. Whenever a new payload of data has been downloaded, readyRead() is emitted, and you can process the data that just arrived. QBuffer also emits bytesWritten() every time new data has been written to the buffer.

See also QFile, QDataStream, QTextStream, and QByteArray.

Constructor & Destructor Documentation

QtCore.QBuffer.QBuffer ( System.Type  dummy)
protected
QtCore.QBuffer.QBuffer ( QObject  parent = null)

Constructs an empty buffer with the given parent. You can call setData() to fill the buffer with data, or you can open it in write mode and use write().

See also open().

QtCore.QBuffer.QBuffer ( QByteArray  buf,
QObject  parent = null 
)

Constructs a QBuffer that uses the QByteArray pointed to by byteArray as its internal buffer, and with the given parent. The caller is responsible for ensuring that byteArray remains valid until the QBuffer is destroyed, or until setBuffer() is called to change the buffer. QBuffer doesn't take ownership of the QByteArray.

If you open the buffer in write-only mode or read-write mode and write something into the QBuffer, byteArray will be modified.

Example:

QByteArray byteArray("abc");

QBuffer buffer(&byteArray);

buffer.open(QIODevice::WriteOnly);

buffer.seek(3);

buffer.write("def", 3);

buffer.close();

// byteArray == "abcdef"

See also open(), setBuffer(), and setData().

Member Function Documentation

override bool QtCore.QBuffer.AtEnd ( )
virtual

Reimplemented from QIODevice::atEnd().

Reimplemented from QtCore.QIODevice.

override bool QtCore.QBuffer.CanReadLine ( )
virtual

Reimplemented from QIODevice::canReadLine().

Reimplemented from QtCore.QIODevice.

override void QtCore.QBuffer.Close ( )
virtual

Reimplemented from QIODevice::close().

Reimplemented from QtCore.QIODevice.

override void QtCore.QBuffer.ConnectNotify ( string  signal)
protectedvirtual

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, use QLatin1String and the SIGNAL() macro as follows:

if (QLatin1String(signal) == SIGNAL(valueChanged(int))) {

// signal is valueChanged(int)

}

If the signal contains multiple parameters or parameters that contain spaces, call QMetaObject::normalizedSignature() on the result of the SIGNAL() macro.

Warning: This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.

See also connect() and disconnectNotify().

Reimplemented from QtCore.QObject.

override void QtCore.QBuffer.CreateProxy ( )
virtual

Reimplemented from QtCore.QObject.

override void QtCore.QBuffer.DisconnectNotify ( string  signal)
protectedvirtual

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

Warning: This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.

See also disconnect() and connectNotify().

Reimplemented from QtCore.QObject.

new void QtCore.QBuffer.Dispose ( )
override bool QtCore.QBuffer.Open ( QIODevice.OpenModeFlag  openMode)
virtual

Reimplemented from QIODevice::open().

Reimplemented from QtCore.QIODevice.

override long QtCore.QBuffer.Pos ( )
virtual

Reimplemented from QIODevice::pos().

Reimplemented from QtCore.QIODevice.

override long QtCore.QBuffer.ReadData ( Pointer< sbyte >  data,
long  maxlen 
)
protectedvirtual

Reimplemented from QIODevice::readData().

Implements QtCore.QIODevice.

override bool QtCore.QBuffer.Seek ( long  off)
virtual

Reimplemented from QIODevice::seek().

Reimplemented from QtCore.QIODevice.

new void QtCore.QBuffer.SetData ( string  data,
int  len 
)

This is an overloaded function.

Sets the contents of the internal buffer to be the first size bytes of data.

override long QtCore.QBuffer.Size ( )
virtual

Reimplemented from QIODevice::size().

Reimplemented from QtCore.QIODevice.

static string QtCore.QBuffer.Tr ( string  s,
string  c = null 
)
static
static string QtCore.QBuffer.Tr ( string  s,
string  c,
int  n 
)
static
static string QtCore.QBuffer.TrUtf8 ( string  s,
string  c = null 
)
static
static string QtCore.QBuffer.TrUtf8 ( string  s,
string  c,
int  n 
)
static
override long QtCore.QBuffer.WriteData ( string  data,
long  len 
)
protectedvirtual

Reimplemented from QIODevice::writeData().

Implements QtCore.QIODevice.

Property Documentation

new QByteArray QtCore.QBuffer.Buffer
getset

Returns a reference to the QBuffer's internal buffer. You can use it to modify the QByteArray behind the QBuffer's back.

Makes QBuffer uses the QByteArray pointed to by byteArray as its internal buffer. The caller is responsible for ensuring that byteArray remains valid until the QBuffer is destroyed, or until setBuffer() is called to change the buffer. QBuffer doesn't take ownership of the QByteArray.

Does nothing if isOpen() is true.

If you open the buffer in write-only mode or read-write mode and write something into the QBuffer, byteArray will be modified.

Example:

QByteArray byteArray("abc");

QBuffer buffer;

buffer.setBuffer(&byteArray);

buffer.open(QIODevice::WriteOnly);

buffer.seek(3);

buffer.write("def", 3);

buffer.close();

// byteArray == "abcdef"

If byteArray is 0, the buffer creates its own internal QByteArray to work on. This byte array is initially empty.

new QByteArray QtCore.QBuffer.Data
getset

Returns the data contained in the buffer.

This is the same as buffer().

Sets the contents of the internal buffer to be data. This is the same as assigning data to buffer().

Does nothing if isOpen() is true.

new IQBufferSignals QtCore.QBuffer.Emit
getprotected
new QMetaObject QtCore.QBuffer.StaticMetaObject
staticget