summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-11-09 17:05:44 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2021-11-09 17:05:44 +1300
commit36b0cbf19bd44c94bbe5aa67730347290f20628c (patch)
treed2171132faa9dc6b2ffe99e87b7bbef102c9a9c0 /src
parentb18a53cfaea8c3cf9e838e2a1cc8000a18324234 (diff)
Refactored packages
Diffstat (limited to 'src')
-rw-r--r--src/deck_convert.adb57
-rw-r--r--src/deck_convert_gui.adb64
-rw-r--r--src/deck_convert_gui.ads3
-rw-r--r--src/deckdata-csv.adb (renamed from src/csv.adb)20
-rw-r--r--src/deckdata-csv.ads (renamed from src/csv.ads)28
-rw-r--r--src/deckdata-fmd.adb (renamed from src/fmd.adb)24
-rw-r--r--src/deckdata-fmd.ads (renamed from src/fmd.ads)31
-rw-r--r--src/deckdata-io.adb (renamed from src/deck_io.adb)35
-rw-r--r--src/deckdata-io.ads (renamed from src/deck_io.ads)32
-rw-r--r--src/deckdata-process.adb54
-rw-r--r--src/deckdata-process.ads15
-rw-r--r--src/deckdata.ads (renamed from src/datatypes.ads)18
12 files changed, 169 insertions, 212 deletions
diff --git a/src/deck_convert.adb b/src/deck_convert.adb
index 665fa5e..9eed9c7 100644
--- a/src/deck_convert.adb
+++ b/src/deck_convert.adb
@@ -14,13 +14,13 @@ with
Ada.Directories,
Ada.Strings.Unbounded,
Ada.Text_IO,
- Datatypes,
- Deck_IO;
+ Deckdata.IO,
+ Deckdata.Process;
use
Ada.Text_IO,
- Datatypes;
+ Deckdata;
procedure Deck_Convert is
@@ -50,39 +50,6 @@ procedure Deck_Convert is
renames SU.To_String;
- procedure Strip_Formatting
- (Notes : in out Note_Vector)
- is
- procedure Strip
- (Text : in out Note;
- Item : in String)
- is
- Position : Natural;
- begin
- for F of Text.Fields loop
- loop
- Position := SU.Index
- (Source => SU.Unbounded_String (F),
- Pattern => Item,
- Going => Ada.Strings.Forward,
- Mapping => Charhand.To_Lower'Access);
- exit when Position = 0;
- SU.Delete (SU.Unbounded_String (F), Position, Position + Item'Length - 1);
- end loop;
- end loop;
- end Strip;
-
- Formatting : array (Positive range <>) of SU.Unbounded_String :=
- (+"<b>", +"</b>", +"<strong>", +"</strong>", +"<i>", +"</i>", +"<em>", +"</em>",
- +"<mark>", +"</mark>", +"<small>", +"</small>", +"<del>", +"</del>",
- +"<ins>", +"</ins>", +"<sub>", +"</sub>", +"<sup>", +"</sup>");
- begin
- for N of Notes loop
- for S of Formatting loop
- Strip (N, -S);
- end loop;
- end loop;
- end Strip_Formatting;
Config : GCom.Command_Line_Configuration;
@@ -105,7 +72,7 @@ procedure Deck_Convert is
Output_Name : SU.Unbounded_String;
- Deck : Deck_IO.Deck_Handle;
+ Deck : Deckdata.IO.Deck_Handle;
Models : Model_Map;
Notes : Note_Vector;
Media : Media_Collection;
@@ -226,22 +193,22 @@ begin
if Verbose then
Put (Standard_Error, "Opening input deck database...");
end if;
- Deck_IO.Open_Database (-Input_Name, Deck);
+ Deckdata.IO.Open_Database (-Input_Name, Deck);
if Verbose then
Put_Line (Standard_Error, " Done");
Put (Standard_Error, "Querying models...");
end if;
- Deck_IO.Query_Models (Deck, Models);
+ Deckdata.IO.Query_Models (Deck, Models);
if Verbose then
Put_Line (Standard_Error, " Done");
Put (Standard_Error, "Querying notes...");
end if;
- Deck_IO.Query_Notes (Deck, Notes);
+ Deckdata.IO.Query_Notes (Deck, Notes);
if Verbose then
Put_Line (Standard_Error, " Done");
Put (Standard_Error, "Closing database...");
end if;
- Deck_IO.Close_Database (Deck);
+ Deckdata.IO.Close_Database (Deck);
if Verbose then
Put_Line (Standard_Error, " Done");
New_Line (Standard_Error);
@@ -251,7 +218,7 @@ begin
if Verbose then
Put (Standard_Error, "Stripping formatting from deck notes...");
end if;
- Strip_Formatting (Notes);
+ Deckdata.Process.Strip_Formatting (Notes);
if Verbose then
Put_Line (Standard_Error, " Done");
New_Line (Standard_Error);
@@ -266,7 +233,7 @@ begin
if Verbose then
Put (Standard_Error, "Writing output to CSV...");
end if;
- Deck_IO.Write_CSV (Contain_Dir, Simple_Name, Models, Notes, Overwrite);
+ Deckdata.IO.Write_CSV (Contain_Dir, Simple_Name, Models, Notes, Overwrite);
if Verbose then
Put_Line (Standard_Error, " Done");
end if;
@@ -274,12 +241,12 @@ begin
if Verbose then
Put (Standard_Error, "Reading media...");
end if;
- Deck_IO.Read_Media_Collection (-Input_Name, Media);
+ Deckdata.IO.Read_Media_Collection (-Input_Name, Media);
if Verbose then
Put_Line (Standard_Error, " Done");
Put (Standard_Error, "Writing output to Fresh Memory Dictionary...");
end if;
- Deck_IO.Write_FMD (Contain_Dir, Simple_Name, Models, Notes, Media, Overwrite);
+ Deckdata.IO.Write_FMD (Contain_Dir, Simple_Name, Models, Notes, Media, Overwrite);
if Verbose then
Put_Line (Standard_Error, " Done");
end if;
diff --git a/src/deck_convert_gui.adb b/src/deck_convert_gui.adb
index 0c352ed..65bc21d 100644
--- a/src/deck_convert_gui.adb
+++ b/src/deck_convert_gui.adb
@@ -1,5 +1,8 @@
+-- This source is licensed under the Sunset License v1.0
+
+
with
Ada.Characters.Handling,
@@ -7,8 +10,8 @@ with
Ada.Exceptions,
Ada.Strings.Unbounded,
Ada.Text_IO,
- Datatypes,
- Deck_IO,
+ Deckdata.IO,
+ Deckdata.Process,
FLTK.Dialogs,
FLTK.Widgets.Boxes,
FLTK.Widgets.Buttons.Enter,
@@ -21,7 +24,7 @@ with
use
Ada.Text_IO,
- Datatypes;
+ Deckdata;
package body Deck_Convert_GUI is
@@ -158,43 +161,6 @@ package body Deck_Convert_GUI is
- procedure Strip_Formatting
- (Notes : in out Note_Vector)
- is
- procedure Strip
- (Text : in out Note;
- Item : in String)
- is
- Position : Natural;
- begin
- for F of Text.Fields loop
- loop
- Position := SU.Index
- (Source => SU.Unbounded_String (F),
- Pattern => Item,
- Going => Ada.Strings.Forward,
- Mapping => Charhand.To_Lower'Access);
- exit when Position = 0;
- SU.Delete (SU.Unbounded_String (F), Position, Position + Item'Length - 1);
- end loop;
- end loop;
- end Strip;
-
- Formatting : array (Positive range <>) of SU.Unbounded_String :=
- (+"<b>", +"</b>", +"<strong>", +"</strong>", +"<i>", +"</i>", +"<em>", +"</em>",
- +"<mark>", +"</mark>", +"<small>", +"</small>", +"<del>", +"</del>",
- +"<ins>", +"</ins>", +"<sub>", +"</sub>", +"<sup>", +"</sup>");
- begin
- for N of Notes loop
- for S of Formatting loop
- Strip (N, -S);
- end loop;
- end loop;
- end Strip_Formatting;
-
-
-
-
task body Worker is
use type FLTK.Widgets.Buttons.State;
use type SU.Unbounded_String;
@@ -206,7 +172,7 @@ package body Deck_Convert_GUI is
Overwrite : Boolean;
Strip_Form : Boolean;
- Deck : Deck_IO.Deck_Handle;
+ Deck : Deckdata.IO.Deck_Handle;
Models : Model_Map;
Notes : Note_Vector;
Media : Media_Collection;
@@ -258,28 +224,28 @@ package body Deck_Convert_GUI is
Status_Box.Set_Label_Color (Status_Black);
Status_Box.Set_Label ("MESSAGE: Opening input deck database...");
Status_Box.Redraw_Label;
- Deck_IO.Open_Database (-Input_Name, Deck);
+ Deckdata.IO.Open_Database (-Input_Name, Deck);
My_Progress.Set_Value (15.0);
My_Progress.Redraw;
Status_Box.Set_Label ("MESSAGE: Querying models...");
Status_Box.Redraw_Label;
- Deck_IO.Query_Models (Deck, Models);
+ Deckdata.IO.Query_Models (Deck, Models);
My_Progress.Set_Value (30.0);
My_Progress.Redraw;
Status_Box.Set_Label ("MESSAGE: Querying notes...");
Status_Box.Redraw_Label;
- Deck_IO.Query_Notes (Deck, Notes);
+ Deckdata.IO.Query_Notes (Deck, Notes);
My_Progress.Set_Value (45.0);
My_Progress.Redraw;
Status_Box.Set_Label ("MESSAGE: Closing database...");
Status_Box.Redraw_Label;
- Deck_IO.Close_Database (Deck);
+ Deckdata.IO.Close_Database (Deck);
My_Progress.Set_Value (60.0);
My_Progress.Redraw;
if Strip_Form then
Status_Box.Set_Label ("MESSAGE: Stripping formatting from notes...");
Status_Box.Redraw_Label;
- Strip_Formatting (Notes);
+ Deckdata.Process.Strip_Formatting (Notes);
My_Progress.Set_Value (70.0);
My_Progress.Redraw;
end if;
@@ -290,7 +256,7 @@ package body Deck_Convert_GUI is
if Deck_Format = "csv" then
Status_Box.Set_Label ("MESSAGE: Writing output to csv...");
Status_Box.Redraw_Label;
- Deck_IO.Write_CSV (Contain_Dir, Simple_Name, Models, Notes, Overwrite);
+ Deckdata.IO.Write_CSV (Contain_Dir, Simple_Name, Models, Notes, Overwrite);
My_Progress.Set_Value (100.0);
My_Progress.Redraw;
Status_Box.Set_Label ("STATUS: Complete success!");
@@ -299,12 +265,12 @@ package body Deck_Convert_GUI is
elsif Deck_Format = "fmd" then
Status_Box.Set_Label ("MESSAGE: Reading media...");
Status_Box.Redraw_Label;
- Deck_IO.Read_Media_Collection (-Input_Name, Media);
+ Deckdata.IO.Read_Media_Collection (-Input_Name, Media);
My_Progress.Set_Value (85.0);
My_Progress.Redraw;
Status_Box.Set_Label ("MESSAGE: Writing output to fmd...");
Status_Box.Redraw_Label;
- Deck_IO.Write_FMD
+ Deckdata.IO.Write_FMD
(Contain_Dir, Simple_Name, Models, Notes, Media, Overwrite);
My_Progress.Set_Value (100.0);
My_Progress.Redraw;
diff --git a/src/deck_convert_gui.ads b/src/deck_convert_gui.ads
index 3273060..be118d5 100644
--- a/src/deck_convert_gui.ads
+++ b/src/deck_convert_gui.ads
@@ -1,5 +1,8 @@
+-- This source is licensed under the Sunset License v1.0
+
+
package Deck_Convert_GUI is
procedure Show;
diff --git a/src/csv.adb b/src/deckdata-csv.adb
index 656f99f..4789469 100644
--- a/src/csv.adb
+++ b/src/deckdata-csv.adb
@@ -8,15 +8,14 @@ with
Ada.Characters.Latin_1,
Ada.Strings.Fixed,
Ada.Strings.Maps,
- Ada.Text_IO,
- Datatypes;
+ Ada.Text_IO;
use
Ada.Text_IO;
-package body CSV is
+package body Deckdata.CSV is
package Latin renames Ada.Characters.Latin_1;
@@ -69,10 +68,10 @@ package body CSV is
procedure Put_Header
(File_Handle : in Ada.Text_IO.File_Type;
- Titles : in Datatypes.Field_ID_Vector) is
+ Titles : in Field_ID_Vector) is
begin
- for Position in Datatypes.Field_Ordinal range
- Titles.First_Index .. Datatypes.Field_Ordinal'Pred (Titles.Last_Index)
+ for Position in Field_Ordinal range
+ Titles.First_Index .. Field_Ordinal'Pred (Titles.Last_Index)
loop
Put_Cell (File_Handle, SU.Unbounded_String (Titles.Element (Position)));
Put (File_Handle, Separator_Char);
@@ -84,19 +83,18 @@ package body CSV is
procedure Put_Row
(File_Handle : in Ada.Text_IO.File_Type;
- Cells : in Datatypes.Field_Vector;
+ Cells : in Field_Vector;
Quantity : in Positive)
is
- use type Datatypes.Field_Ordinal;
Counter : Positive := 1;
- Position : Datatypes.Field_Ordinal := Cells.First_Index;
+ Position : Field_Ordinal := Cells.First_Index;
begin
while Counter < Quantity loop
if Position <= Cells.Last_Index then
Put_Cell (File_Handle, SU.Unbounded_String (Cells.Element (Position)));
end if;
Put (File_Handle, Separator_Char);
- Position := Datatypes.Field_Ordinal'Succ (Position);
+ Position := Field_Ordinal'Succ (Position);
Counter := Counter + 1;
end loop;
if Position <= Cells.Last_Index then
@@ -106,6 +104,6 @@ package body CSV is
end Put_Row;
-end CSV;
+end Deckdata.CSV;
diff --git a/src/csv.ads b/src/deckdata-csv.ads
index c2df2e9..f05cba1 100644
--- a/src/csv.ads
+++ b/src/deckdata-csv.ads
@@ -7,8 +7,7 @@ with
Ada.Containers.Vectors,
Ada.Strings.Unbounded,
- Ada.Text_IO,
- Datatypes;
+ Ada.Text_IO;
generic
@@ -17,7 +16,7 @@ generic
Quote_Char : Character := '"';
Escape_Char : Character := '\';
-package CSV is
+package Deckdata.CSV is
procedure Put_Cell
@@ -31,32 +30,15 @@ package CSV is
procedure Put_Header
(File_Handle : in Ada.Text_IO.File_Type;
- Titles : in Datatypes.Field_ID_Vector);
+ Titles : in Field_ID_Vector);
procedure Put_Row
(File_Handle : in Ada.Text_IO.File_Type;
- Cells : in Datatypes.Field_Vector;
+ Cells : in Field_Vector;
Quantity : in Positive);
-private
-
-
- package SU renames Ada.Strings.Unbounded;
-
-
- function "+"
- (S : in String)
- return SU.Unbounded_String
- renames SU.To_Unbounded_String;
-
- function "-"
- (US : in SU.Unbounded_String)
- return String
- renames SU.To_String;
-
-
-end CSV;
+end Deckdata.CSV;
diff --git a/src/fmd.adb b/src/deckdata-fmd.adb
index ae037f4..10040a0 100644
--- a/src/fmd.adb
+++ b/src/deckdata-fmd.adb
@@ -8,15 +8,14 @@ with
Ada.Characters.Latin_1,
Ada.Strings.Fixed,
Ada.Strings.Maps,
- Ada.Text_IO,
- Datatypes;
+ Ada.Text_IO;
use
Ada.Text_IO;
-package body FMD is
+package body Deckdata.FMD is
package Latin renames Ada.Characters.Latin_1;
@@ -46,7 +45,7 @@ package body FMD is
procedure Put_Fields
(File_Handle : in Ada.Text_IO.File_Type;
- Field_IDs : in Datatypes.Field_ID_Vector)
+ Field_IDs : in Field_ID_Vector)
is
Text : SU.Unbounded_String;
begin
@@ -70,16 +69,16 @@ package body FMD is
procedure Put_Pack
(File_Handle : in Ada.Text_IO.File_Type;
- Q_Data : in Datatypes.Field_ID_Vector;
- A_Data : in Datatypes.Field_ID_Vector)
+ Q_Data : in Field_ID_Vector;
+ A_Data : in Field_ID_Vector)
is
Text : SU.Unbounded_String;
begin
Put_Line (File_Handle, (8 * ' ') & "<pack>");
Text := Prep (SU.Unbounded_String (Q_Data.First_Element));
Put_Line (File_Handle, (12 * ' ') & "<qst>" & (-Text) & "</qst>");
- for I in Datatypes.Field_Ordinal range
- Datatypes.Field_Ordinal'Succ (Q_Data.First_Index) .. Q_Data.Last_Index
+ for I in Field_Ordinal
+ range Field_Ordinal'Succ (Q_Data.First_Index) .. Q_Data.Last_Index
loop
Text := Prep (SU.Unbounded_String (Q_Data.Element (I)));
-- Fresh Memory unfortunately cannot cope with multiple question fields
@@ -111,12 +110,11 @@ package body FMD is
procedure Put_Entry
(File_Handle : in Ada.Text_IO.File_Type;
- Data : in Datatypes.Field_Vector;
+ Data : in Field_Vector;
Quantity : in Positive)
is
- use type Datatypes.Field_Ordinal;
Counter : Positive := 1;
- Position : Datatypes.Field_Ordinal := Data.First_Index;
+ Position : Field_Ordinal := Data.First_Index;
Text : SU.Unbounded_String;
begin
Put_Line (File_Handle, (8 * ' ') & "<e>");
@@ -127,7 +125,7 @@ package body FMD is
else
Put_Line (File_Handle, (12 * ' ') & "<f></f>");
end if;
- Position := Datatypes.Field_Ordinal'Succ (Position);
+ Position := Field_Ordinal'Succ (Position);
Counter := Counter + 1;
end loop;
Put_Line (File_Handle, (8 * ' ') & "</e>");
@@ -209,6 +207,6 @@ package body FMD is
end Prep;
-end FMD;
+end Deckdata.FMD;
diff --git a/src/fmd.ads b/src/deckdata-fmd.ads
index 610aa88..bf251f3 100644
--- a/src/fmd.ads
+++ b/src/deckdata-fmd.ads
@@ -7,8 +7,7 @@ with
Ada.Containers.Vectors,
Ada.Strings.Unbounded,
- Ada.Text_IO,
- Datatypes;
+ Ada.Text_IO;
private with
@@ -16,7 +15,7 @@ private with
Ada.Strings.Maps;
-package FMD is
+package Deckdata.FMD is
procedure Put_Header
@@ -28,7 +27,7 @@ package FMD is
procedure Put_Fields
(File_Handle : in Ada.Text_IO.File_Type;
- Field_IDs : in Datatypes.Field_ID_Vector);
+ Field_IDs : in Field_ID_Vector);
@@ -38,8 +37,8 @@ package FMD is
procedure Put_Pack
(File_Handle : in Ada.Text_IO.File_Type;
- Q_Data : in Datatypes.Field_ID_Vector;
- A_Data : in Datatypes.Field_ID_Vector)
+ Q_Data : in Field_ID_Vector;
+ A_Data : in Field_ID_Vector)
with Pre => not Q_Data.Is_Empty and not A_Data.Is_Empty;
procedure End_Pack_Section
@@ -53,7 +52,7 @@ package FMD is
procedure Put_Entry
(File_Handle : in Ada.Text_IO.File_Type;
- Data : in Datatypes.Field_Vector;
+ Data : in Field_Vector;
Quantity : in Positive);
procedure End_Entry_Section
@@ -69,22 +68,6 @@ package FMD is
private
- package SU renames Ada.Strings.Unbounded;
-
-
- function "+"
- (S : in String)
- return SU.Unbounded_String
- renames SU.To_Unbounded_String;
-
- function "-"
- (US : in SU.Unbounded_String)
- return String
- renames SU.To_String;
-
-
-
-
procedure Replace_All
(Text : in out SU.Unbounded_String;
Char : in Character;
@@ -101,6 +84,6 @@ private
return SU.Unbounded_String;
-end FMD;
+end Deckdata.FMD;
diff --git a/src/deck_io.adb b/src/deckdata-io.adb
index 3b48a10..e152ee0 100644
--- a/src/deck_io.adb
+++ b/src/deckdata-io.adb
@@ -10,19 +10,14 @@ with
Ada.Strings.Fixed,
Ada.Strings.Maps,
Ada.Text_IO,
- CSV,
- Datatypes,
- FMD,
+ Deckdata.CSV,
+ Deckdata.FMD,
GNAT.Regpat,
GNATCOLL.JSON,
UnZip;
-use
- Datatypes;
-
-
-package body Deck_IO is
+package body Deckdata.IO is
package Latin renames Ada.Characters.Latin_1;
@@ -34,15 +29,6 @@ package body Deck_IO is
package JS renames GNATCOLL.JSON;
- function "+"
- (S : in String)
- return SU.Unbounded_String
- renames SU.To_Unbounded_String;
-
- function "-"
- (US : in SU.Unbounded_String)
- return String
- renames SU.To_String;
function To_Unbounded_String
@@ -53,7 +39,7 @@ package body Deck_IO is
end To_Unbounded_String;
function To_Unbounded_String
- (Item : in Datatypes.Field)
+ (Item : in Field)
return SU.Unbounded_String is
begin
return SU.Unbounded_String (Item);
@@ -301,11 +287,10 @@ package body Deck_IO is
while Next /= 0 and Position <= SU.Length (Raw_Data) loop
Next := SU.Index (Raw_Data, Charset, Position);
if Position <= Next then
- Fields.Append (Datatypes.Field (SU.Unbounded_Slice
- (Raw_Data, Position, Next - 1)));
+ Fields.Append (Field (SU.Unbounded_Slice (Raw_Data, Position, Next - 1)));
else
- Fields.Append (Datatypes.Field (SU.Unbounded_Slice
- (Raw_Data, Position, SU.Length (Raw_Data))));
+ Fields.Append (Field (SU.Unbounded_Slice
+ (Raw_Data, Position, SU.Length (Raw_Data))));
end if;
Position := Next + 1;
end loop;
@@ -369,7 +354,7 @@ package body Deck_IO is
procedure Extract_Images
- (Texts : in out Datatypes.Field_Vector;
+ (Texts : in out Field_Vector;
Outdir : in SU.Unbounded_String;
Media : in Media_Collection)
is
@@ -462,7 +447,7 @@ package body Deck_IO is
Counter : Positive := 1;
Outname, Outdir : SU.Unbounded_String;
File_Handle : TIO.File_Type;
- Current_Entry : Datatypes.Field_Vector;
+ Current_Entry : Field_Vector;
Entry_Size : Positive;
begin
for C in Models.Iterate loop
@@ -503,6 +488,6 @@ package body Deck_IO is
end Write_FMD;
-end Deck_IO;
+end Deckdata.IO;
diff --git a/src/deck_io.ads b/src/deckdata-io.ads
index e5d698a..acdcda3 100644
--- a/src/deck_io.ads
+++ b/src/deckdata-io.ads
@@ -3,23 +3,15 @@
-- This source is licensed under the Sunset License v1.0
-with
-
- Ada.Containers.Vectors,
- Ada.Containers.Ordered_Maps,
- Ada.Strings.Unbounded,
- Datatypes;
-
private with
Ada.Finalization,
SQLite3;
-package Deck_IO is
+package Deckdata.IO is
- package SU renames Ada.Strings.Unbounded;
use type SU.Unbounded_String;
@@ -27,14 +19,14 @@ package Deck_IO is
function Matches
- (Models : in Datatypes.Model_Map;
- Notes : in Datatypes.Note_Vector)
+ (Models : in Model_Map;
+ Notes : in Note_Vector)
return Boolean;
procedure Read_Media_Collection
(Filename : in String;
- Media : out Datatypes.Media_Collection);
+ Media : out Media_Collection);
procedure Open_Database
@@ -52,29 +44,29 @@ package Deck_IO is
procedure Query_Models
(Deck : in out Deck_Handle;
- Models : out Datatypes.Model_Map)
+ Models : out Model_Map)
with Pre => Is_Open (Deck);
procedure Query_Notes
(Deck : in out Deck_Handle;
- Notes : out Datatypes.Note_Vector)
+ Notes : out Note_Vector)
with Pre => Is_Open (Deck);
procedure Write_CSV
(Directory : in String;
Basename : in String;
- Models : in Datatypes.Model_Map;
- Notes : in Datatypes.Note_Vector;
+ Models : in Model_Map;
+ Notes : in Note_Vector;
Overwrite : in Boolean := False)
with Pre => Matches (Models, Notes);
procedure Write_FMD
(Directory : in String;
Basename : in String;
- Models : in Datatypes.Model_Map;
- Notes : in Datatypes.Note_Vector;
- Media : in Datatypes.Media_Collection;
+ Models : in Model_Map;
+ Notes : in Note_Vector;
+ Media : in Media_Collection;
Overwrite : in Boolean := False)
with Pre => Matches (Models, Notes);
@@ -95,6 +87,6 @@ private
(This : in out Deck_Handle);
-end Deck_IO;
+end Deckdata.IO;
diff --git a/src/deckdata-process.adb b/src/deckdata-process.adb
new file mode 100644
index 0000000..e7756a1
--- /dev/null
+++ b/src/deckdata-process.adb
@@ -0,0 +1,54 @@
+
+
+-- This source is licensed under the Sunset License v1.0
+
+
+with
+
+ Ada.Characters.Handling;
+
+
+package body Deckdata.Process is
+
+
+ package Charhand renames Ada.Characters.Handling;
+
+
+ procedure Strip_Formatting
+ (Notes : in out Note_Vector)
+ is
+ procedure Strip
+ (Text : in out Note;
+ Item : in String)
+ is
+ Position : Natural;
+ begin
+ for F of Text.Fields loop
+ loop
+ Position := SU.Index
+ (Source => SU.Unbounded_String (F),
+ Pattern => Item,
+ Going => Ada.Strings.Forward,
+ Mapping => Charhand.To_Lower'Access);
+ exit when Position = 0;
+ SU.Delete (SU.Unbounded_String (F), Position, Position + Item'Length - 1);
+ end loop;
+ end loop;
+ end Strip;
+
+ Formatting : array (Positive range <>) of SU.Unbounded_String :=
+ (+"<b>", +"</b>", +"<strong>", +"</strong>", +"<i>", +"</i>", +"<em>", +"</em>",
+ +"<mark>", +"</mark>", +"<small>", +"</small>", +"<del>", +"</del>",
+ +"<ins>", +"</ins>", +"<sub>", +"</sub>", +"<sup>", +"</sup>");
+ begin
+ for N of Notes loop
+ for S of Formatting loop
+ Strip (N, -S);
+ end loop;
+ end loop;
+ end Strip_Formatting;
+
+
+end Deckdata.Process;
+
+
diff --git a/src/deckdata-process.ads b/src/deckdata-process.ads
new file mode 100644
index 0000000..f0f16cf
--- /dev/null
+++ b/src/deckdata-process.ads
@@ -0,0 +1,15 @@
+
+
+-- This source is licensed under the Sunset License v1.0
+
+
+package Deckdata.Process is
+
+
+ procedure Strip_Formatting
+ (Notes : in out Note_Vector);
+
+
+end Deckdata.Process;
+
+
diff --git a/src/datatypes.ads b/src/deckdata.ads
index 5ad2f75..ae73ef2 100644
--- a/src/datatypes.ads
+++ b/src/deckdata.ads
@@ -10,7 +10,7 @@ with
Ada.Strings.Unbounded;
-package Datatypes is
+package Deckdata is
package SU renames Ada.Strings.Unbounded;
@@ -88,6 +88,20 @@ package Datatypes is
end record;
-end Datatypes;
+private
+
+
+ function "+"
+ (S : in String)
+ return SU.Unbounded_String
+ renames SU.To_Unbounded_String;
+
+ function "-"
+ (US : in SU.Unbounded_String)
+ return String
+ renames SU.To_String;
+
+
+end Deckdata;