<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
I have to pass the structure of bit-fields over the D-Bus connection<br>
<br>
e.g.<br>
<br>
struct XXX<br>
{<br>
uint state1 : 2;<br>
...<br>
uint stateN : 5:<br>
}<br>
<br>
I thought (because of possible endianity) the ByteArray will be the
best transport for it. <br>
<br>
So I'd like to use the <br>
<br>
char buff[n];<br>
<br>
and cast it to the struct XXX pointer<br>
<br>
XXX *xxxStructPtr = ((XXX *)(buff));<br>
<br>
xxxStructPtr->state1 = myStateEnum;<br>
...<br>
<br>
After filling the buffer I have to pass it to the QByteArray, I
thought the fromRawData(buff,n) will be most appropriate for it.<br>
<br>
What I've been wondering, was if I can use the QByteArray directly
as a "buffer", i.e to cast it to get the pointer to my XXX struct. <br>
<br>
Or maybe there is a quite different solution for it?<br>
<br>
Thanks for your help<br>
<br>
bogdan<br>
<br>
<br>
<br>
<br>
<br>
<br>
On 2/8/2012 21:53, Thiago Macieira wrote:
<blockquote cite="mid:3400271.sBiDfZ2E7M@tjmaciei-mobl2" type="cite">
<pre wrap="">On Wednesday, 8 de February de 2012 21.34.45, Bogdan Lotko wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I am not sure if the QByteArray will allow such a cast, so I'll probably
use the buffer as in the example.
</pre>
</blockquote>
<pre wrap="">
Or you could just find out if it does and then decide whether to use it using
actual facts.
Since there was no mention of "cast" in the previous conversation, "such a
cast" doesn't make sense. It is not referring to a cast discussed in the past.
If you had said what you wanted to do, I could have already answered you.
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
dbus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/dbus">http://lists.freedesktop.org/mailman/listinfo/dbus</a>
</pre>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<p><b>Bogdan Lotko</b></p>
<a class="moz-txt-link-abbreviated"
href="mailto:b.lotko@chello.at">b.lotko@chello.at</a>
<br>
Phone: +43 1 2852458
<br>
Mobile: +43 676 6615012
</div>
</body>
</html>