From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.69.31.75 with SMTP id kk11mr11666796pbd.8.1403906731225; Fri, 27 Jun 2014 15:05:31 -0700 (PDT) X-Received: by 10.140.97.166 with SMTP id m35mr30989qge.28.1403906731179; Fri, 27 Jun 2014 15:05:31 -0700 (PDT) Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!uq10no14222238igb.0!news-out.google.com!a8ni0qaq.1!nntp.google.com!i13no1994799qae.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 27 Jun 2014 15:05:30 -0700 (PDT) In-Reply-To: <8beec1c1-9ca2-44fc-9d7e-0cd0aa772dcc@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=79.161.178.23; posting-account=bXa9kQoAAADQ0LSY80qTyLW4hcbm0Soz NNTP-Posting-Host: 79.161.178.23 References: <8beec1c1-9ca2-44fc-9d7e-0cd0aa772dcc@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <5b4a031b-b3b3-455f-b491-e161cc24af3d@googlegroups.com> Subject: Re: Help with type definition From: hanslad@gmail.com Injection-Date: Fri, 27 Jun 2014 22:05:31 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.dca.giganews.com comp.lang.ada:187272 Date: 2014-06-27T15:05:30-07:00 List-Id: 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