comp.lang.ada
 help / color / mirror / Atom feed
From: hanslad@gmail.com
Subject: Re: Help with type definition
Date: Fri, 27 Jun 2014 15:05:30 -0700 (PDT)
Date: 2014-06-27T15:05:30-07:00	[thread overview]
Message-ID: <5b4a031b-b3b3-455f-b491-e161cc24af3d@googlegroups.com> (raw)
In-Reply-To: <8beec1c1-9ca2-44fc-9d7e-0cd0aa772dcc@googlegroups.com>

Hello again,
I still need some help with type definition in my program.
The specification of the protocol I try to implement the identifier type could be a byte string with similar specification as the string identifier type.
Is there a type in Ada for unbounded byte arrays similar to the unbounded string?

Belowis an excerpt from the protocol specification of how the bytestring is presented on the wire:

"A ByteString is encoded as sequence of bytes preceded by its length in bytes. The length is encoded as a 32-bit signed integer as described above.
If the length of the byte string is -1 then the byte string is 'null'."

 
I got a new version of my code:

package Types is

   package SU   renames Ada.Strings.Unbounded;

   type StringIdentifier is new SU.Unbounded_String;

   type ByteStringIdentifier is new ??;
   
   type IdentifierType is
     (
      Identifier_Numeric,
      Identifier_String,
      Identifier_Bytestring
     );
   for IdentifierType use
     (Identifier_Numeric => 1,
      Identifier_String  => 2,
      Identifier_ByteString  => 3,);
   for IdentifierType'Size use 8;


   type Node_Id (IdType  : IdentifierType := IdentifierType_Numeric )is record
      NamespaceIndex : Interfaces.Unsigned_16  := 0;
      case IdType is
      when Identifier_Numeric =>
         Numeric    : Interfaces.Unsigned_32 ;
      when Identifier_String =>
         String     : StringIdentifier;
      when Identifier_String =>
         ByteString     : ByteStringIdentifier;
      end case;
   end record;
end Types;



Thanks

HP


  parent reply	other threads:[~2014-06-27 22:05 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.
2014-05-16 17:57 ` Jeffrey Carter
2014-05-21 20:45 ` hanslad
2014-06-27 22:05 ` hanslad [this message]
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