From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: implementation of Bounded_String
Date: Thu, 18 Jan 2018 15:42:50 +0100
Date: 2018-01-18T15:42:50+01:00 [thread overview]
Message-ID: <p3qbp9$p7e$1@gioia.aioe.org> (raw)
In-Reply-To: 2eaf6de3-ce95-4c69-b22b-441a7ed6d5c9@googlegroups.com
On 18/01/2018 15:10, Mehdi Saada wrote:
> I suppose it's obvious but...
> If I want to reimplement IO of Bounded_String without relying on
> Unbounded_String, can I do without getting reading input one character
> after another ? Has it to do with streams ?
It has to do with whether string bounds is a part of I/O. Stream
attributes are subdivided into 'Read/'Write and 'Input/'Output. The
former are without bounds (constraints).
Text I/O is a completely different story because it is related to text.
You implement Put this way:
type Bounded_String (Length : Natural := 0) is record
Current_Length : Natural := 0;
Data : String (1..Length);
end record;
procedure Put (X : Bounded_String) is
begin
Put (X.Data (1..X.Current_Length));
end Put;
There is no reasonable Get to have, but Get_Line could have sense
procedure Get_Line (X : out Bounded_String) is
begin
Get_Line (X.Data, X.Current_Length);
end Get_Line;
Similarly you can always implement stream attributes decomposed into
stream operations of other objects.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-01-18 14:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 14:10 implementation of Bounded_String Mehdi Saada
2018-01-18 14:42 ` Dmitry A. Kazakov [this message]
2018-01-18 22:24 ` Simon Wright
2018-01-19 1:25 ` Randy Brukardt
2018-01-19 11:54 ` Mehdi Saada
2018-01-19 12:57 ` Dmitry A. Kazakov
2018-01-19 18:26 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox