Re: Access types to records containing strings

From: Xavier Serrand (xavier.serrand_at_free.fr)
Date: 02/15/05


Date: 15 Feb 2005 04:17:13 -0800

Hello Dmitry,

Why no use pointer to string !!

type T_Ptr_String is access String;

And now your strings can have the length you want ... but you should
define function to construct your strings tha way (make something like
a class in a package and use it)

It should be as or more flexible than the unbounded strings...

Is it usefull?

Xavier

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message news:<8uvcyoh3nvbe$.fy9vv8opob1a.dlg@40tude.net>...
> On Sat, 29 Jan 2005 09:58:55 +0100, Stefan Merwitz wrote:
>
> > it's me again. I need to implement a list containing strings using
> > access types. Is there a way to implement this using variable length
> > strings:
> >
> > private type list;
> > private type listobject is record
> > sContent: string(1..30);
> > Next := list;
> > end record;
> > private type list is access listobject;
> >
> > With the knowledge I have till now, I think it's only possible with
> > fixed length strings. Am I right or is there any other way?
>
> type List_Object;
> type List is access List_Object;
> type List_Object (Length : Natural) is record
> Content : String (1..Length);
> Next : List;
> end record;
>
> or else
>
> with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
> ...
> type List_Object;
> type List is access List_Object;
> type List_Object is record
> Content : Unbounded_String;
> Next : List;
> end record;



Relevant Pages

  • Re: function
    ... The logical operators all return 1 to mean true and 0 to mean false. ... when x is a pointer, ... the two strings were the same. ... the strcpy() that you had above the test, ...
    (comp.lang.c)
  • Re: basic_string ctor
    ... > Which doesn't make it right - C strings are lame at best and we all know ... They are not lame - they just have their drawbacks. ... > pointer is entirely up to the object's constructor to decide. ... Now the internal library function was like ...
    (microsoft.public.vc.stl)
  • Re: fast stable sort
    ... rather than isolating it in a separate array. ... It lumps an extra pointer in with the only one ... Building a linked list does not constitute using Oextra space. ... strings and linking the strings into an order. ...
    (comp.programming)
  • Re: GetOpenFilename()
    ... Specifies that the File Name list box allows multiple selections. ... the directory and file name strings are NULL ... You advance the pointer one character more. ...
    (microsoft.public.vc.language)
  • Re: Problem with strcat, strcpy,sprintf
    ... rigged question and therefore not worthy of an answer. ... misconceptions about what strings are and deliberately not correcting ... them for the sake of an explanation of what assignment does. ... content of a pointer is an address, not the thing it points to. ...
    (comp.lang.c)