-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A agpl-generic_indefinite_file_store.adb
A agpl-generic_indefinite_file_store.ads M agpl-generic_file_store.adb M agpl-generic_file_store.ads
- Loading branch information
Showing
4 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
with Ada.Streams.Stream_Io; | ||
|
||
package body Agpl.Generic_Indefinite_File_Store is | ||
|
||
------------- | ||
-- To_File -- | ||
------------- | ||
|
||
procedure To_File (This : in Item; File : in String) is | ||
use Ada.Streams.Stream_Io; | ||
F : File_Type; | ||
begin | ||
Create (F, Name => File, Mode => Out_File); | ||
|
||
Item'Output (Stream (F), This); | ||
Close (F); | ||
end To_File; | ||
|
||
---------- | ||
-- Load -- | ||
---------- | ||
|
||
function Load (File : in String) return Item is | ||
use Ada.Streams.Stream_Io; | ||
F : File_Type; | ||
begin | ||
Open (F, Name => File, Mode => In_File); | ||
|
||
declare | ||
Result : constant Item := Item'Input (Stream (F)); | ||
begin | ||
Close (F); | ||
return Result; | ||
end; | ||
end Load; | ||
|
||
end Agpl.Generic_Indefinite_File_Store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
------------------------------------------------------------------------------ | ||
-- ADAGIO - ADALID - AENEA. -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (adagio@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
generic | ||
type Item (<>) is private; | ||
package Agpl.Generic_Indefinite_File_Store is | ||
|
||
pragma Elaborate_Body; | ||
|
||
type Item_Access is access all Item; | ||
|
||
procedure To_File (This : in Item; File : in String); | ||
-- This uses Item'Output | ||
-- Write a file with the dumped item. Overwrites if existing. | ||
|
||
function Load (File : in String) return Item; | ||
-- This uses Item'Input | ||
|
||
end Agpl.Generic_Indefinite_File_Store; |