From: "G.B." <rm-dash-bau-haus@dash.futureapps.de>
Subject: Re: Help with type definition
Date: Fri, 16 May 2014 14:29:13 +0200
Date: 2014-05-16T14:29:13+02:00 [thread overview]
Message-ID: <53760499$0$6666$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <8beec1c1-9ca2-44fc-9d7e-0cd0aa772dcc@googlegroups.com>
On 16.05.14 09:37, hanslad@gmail.com wrote:
> Hello,
> I need an advise on how to define a type in my project.
> I want to implement a network protocol with the following definition on the type "string":
>
> "All String values are encoded as a sequence of UTF8 characters without a null terminator and preceded by the length in bytes.
> The length in bytes is encoded as Int32.
Does Int32 stand for a type that has exactly 32 bits
and is signed? Then, Integer is not a suitable candidate
on the Ada side, because Integer is implementation defined
(and may well be 16 bits on a 32 bits platform).
Similarly, predefined type String may not be suitable
because String is indexed by Positive, which is a subtype
of Integer.
If all is well, though, I'd choose Interfaces.Integer_32.
Or just define some type if the benefits (and requirements)
stated for Interfaces.Integer_32 by the LRM are not that important.
type Int32 is range -2^31 .. +2**31-1;
for Int32'Size use 32;
Do you read octets? Some conversion might be needed
in any case, so you might as well try Storage_Array
instead of String, and then convert (or re-interpret)
as needed.
Your pointer-to-string type can be an "access constant" if
the strings so allocated do not need any overwrites.
Can you reuse a string buffer and pass it to processing
routines?
next prev parent reply other threads:[~2014-05-16 12:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 7:37 Help with type definition hanslad
2014-05-16 7:54 ` Dmitry A. Kazakov
2014-05-16 10:03 ` G.B.
2014-05-16 11:26 ` Jacob Sparre Andersen
2014-05-16 15:38 ` Shark8
2014-05-16 15:50 ` Simon Wright
2014-05-16 16:30 ` Shark8
2014-05-16 11:29 ` Jacob Sparre Andersen
2014-05-16 12:29 ` G.B. [this message]
2014-05-16 17:57 ` Jeffrey Carter
2014-05-21 20:45 ` hanslad
2014-06-27 22:05 ` hanslad
2014-06-28 7:26 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox