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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d0fa2610a6bea4ec X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Nested declares, constant size arrays and clarity Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <87641n92tc.fsf@ludovic-brenta.org> <87zlyz6rnt.fsf@ludovic-brenta.org> Date: Thu, 4 Oct 2007 14:45:00 +0200 Message-ID: <1bykilw2jy8k3.1p7sr9xc5wl7i.dlg@40tude.net> NNTP-Posting-Date: 04 Oct 2007 14:39:09 CEST NNTP-Posting-Host: 681d73f4.newsspool3.arcor-online.net X-Trace: DXC=eCc\ASG5i8H[kmHKHnaEnMMcF=Q^Z^V3H4Fo<]lROoRA^;5]aA^R6>B?LhR9QA>>nJ[6LHn;2LCVN7enW;^6ZC`DIXm65S@:3>Og1@@2i;dCSH X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:2295 Date: 2007-10-04T14:39:09+02:00 List-Id: On Thu, 04 Oct 2007 13:33:10 +0200, Ludovic Brenta wrote: > Mateusz Papiernik writes: > >> With strings I also have to work some way. As for now I'm using >> Unbounded_Strings, because easy implementations of functions like >> split (I'm parsing CSV file). Is it a good practice to use U_S, or >> should I fall back to normal strings and fight with implementation? > > I guess that depends on whether the input lines have a fixed length or > not. The main disadvantage of Unbounded_Strings are that they are > much slower than regular Strings. Others are lack of array interface, absence of slices, and inability to use custom storage pools to allocate the body. I never use Unbounded_String for parsing. The input line buffer can be easily reused to accommodate varying strings. The right line boundary would be not S'Last, but some variable <= S'Last. Alternatively a string slice can be passed down to the parser. Something like that would be necessary to do anyway to strip LF/CRs. CSV formats are very easy to do with regular String, IMO much easier than with Unbounded_String. You might take a look at http://www.dmitry-kazakov.de/ada/strings_edit.htm No split or other forms of tokenizing is needed. Instead of that the fields are scanned from left to right and the cursor position in the string) is advanced to the position following the field. When it reaches the right boundary, another line is read into the buffer, and the cursor is reset. That's it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de