Overview
Comment: | natools-accumulators: new set of interfaces for data accumulation |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
43826b6a6ada6b2ead37bd9a3318d3c5 |
User & Date: | nat on 2011-11-29 13:31:54 |
Other Links: | manifest | tags |
Context
2011-11-29
| ||
14:13 | natools-accumulators-string_accumulator_linked_lists: simple implementation of String_Accumulator_Stack check-in: e2088218f7 user: nat tags: trunk | |
13:31 | natools-accumulators: new set of interfaces for data accumulation check-in: 43826b6a6a user: nat tags: trunk | |
2011-11-25
| ||
10:17 | test_all: binary that runs all tests suites check-in: 422f985dc3 user: nat tags: trunk | |
Changes
Added natools-accumulators.ads version [6fdcc53c02].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ------------------------------------------------------------------------------ -- Copyright (c) 2011, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Accumulators is a collection of interfaces for data structures -- -- that allow efficient accumulation of data. -- -- -- -- String_Accumulator is meant for creation of long strings through -- -- repeated calls of Append, and later retrieval of the full buffer through -- -- one of the To_String subprograms. Length, Tail and Unappend are -- -- helper utilities that might not be very efficient but can occasionnally -- -- be useful. Hard_Reset and Soft_Reset both clear the internal state, with -- -- Soft_Reset aimed for speed while Hard_Reset aims for best memory release -- -- -- -- String_Accumulator_Stack adds a stack structure on top of -- -- String_Accumulator, to allow temporary substrings to be created using -- -- similar facilities. All operations on String_Accumulator except -- -- Hard_Reset and Soft_Reset, when applied to String_Accumulator_Stack, are -- -- meant to be forwarded to the top accumulator of the stack. Push and Pop -- -- change the stack state, while Hard_Reset and Soft_Reset apply to the -- -- whole stack, with the same semantics as for String_Accumulator. -- ------------------------------------------------------------------------------ package Natools.Accumulators is pragma Pure (Accumulators); type String_Accumulator is interface; procedure Append (To : in out String_Accumulator; Text : String) is abstract; -- Append the given String to the internal buffer procedure Hard_Reset (Acc : in out String_Accumulator) is abstract; -- Empty the internal buffer and free all possible memory function Length (Acc : String_Accumulator) return Natural is abstract; -- Return the length of the internal buffer procedure Soft_Reset (Acc : in out String_Accumulator) is abstract; -- Empty the internal buffer for reuse function Tail (Acc : String_Accumulator; Size : Natural) return String is abstract; -- Return the last characters from the internal buffer function To_String (Acc : String_Accumulator) return String is abstract; -- Output the whole internal buffer as a String procedure To_String (Acc : String_Accumulator; Output : out String) is abstract; -- Write the whole internal buffer into the String, which must be -- large enough. procedure Unappend (From : in out String_Accumulator; Text : String) is abstract; -- Remove the given suffix from the internal buffer -- Do nothing if the given text is not a prefix the internal buffer type String_Accumulator_Stack is interface and String_Accumulator; procedure Push (Acc : in out String_Accumulator_Stack) is abstract; -- Push the current internal buffer and start with an empty one procedure Pop (Acc : in out String_Accumulator_Stack) is abstract; -- Drop the current internal buffer and use the previsouly pushed one -- instead -- Raise Program_Error when trying to pop the last internal buffer end Natools.Accumulators; |