--------------------------------------------------------------- {{{1 ---------- --: Copyright © 2003 … 2023 Martin Krischik «krischik@users.sourceforge.net» ------------------------------------------------------------------------------ --: This library is free software; you can redistribute it and/or modify it --: under the terms of the GNU Library General Public License as published by --: the Free Software Foundation; either version 2 of the License, or (at your --: option) any later version. --: --: This library 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 Library General Public --: License for more details. --: --: You should have received a copy of the GNU Library General Public License --: along with this library; if not, write to the Free Software Foundation, --: Inc., 675 Mass Ave, Cambridge, MA 02139, USA. --------------------------------------------------------------- }}}1 ---------- pragma License (Modified_Gpl); pragma Ada_2022; with Ada.Strings.Wide_Unbounded; with Ada.Strings.Wide_Maps; with Ada.Containers; --- -- @summary -- -- @description -- No, I have not created some new Wide_String class - yet. Just a few string tools. -- package AdaCL.Wide_Strings is --- -- Replace all Search with Replace -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param Replace Wide_String we want to have --: @param Mapping Search mapping procedure Change_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Replace all Search with Replace and Count how often it was done. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param Replace Wide_String we want to have --: @param Mapping Search mapping --: @param Count Count of replaces done procedure Change_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Count : out Natural); --- -- Replace all Search with Replace -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param Replace Wide_String we want to have --: @param Mapping Search mapping procedure Change_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Replace First Search with Replace and return success flag. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param Replace Wide_String we want to have --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Change_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Replace Last Search with Replace -- --: @param Source : Wide_String we look for --: @param Search : Wide_String to be changed --: @param Replace : Wide_String we want to have --: @param Mapping : Search mapping procedure Change_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Replace Last Search with Replace and return success flag. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param Replace Wide_String we want to have --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Change_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; Replace : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Searches for all occurences of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping procedure Append_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for all occurences of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Count Count of replaces done procedure Append_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Count : out Natural); --- -- Searches for first occurence of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping procedure Append_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for first occurence of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Append_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Searches for last occurence of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping procedure Append_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for last occurence of text "Search" and Inserts text "Insert" after the found text but only when -- "Insert" is not allready there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Append_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Return the end-of-field position in Data after "Starting_Index", assuming that fields are separated by the -- Field_Separator. If there's no Field_Separator, return the end of the Data. --: @param Source Wide_String to search in --: @param Field_Separator Field seperator. --: @param Starting_At Start search at. function Field_End (Source : in Wide_String; Field_Separator : in Wide_Character; Starting_At : Positive) return Natural; pragma Pure_Function (Field_End); --- -- Searches for first occurence of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping procedure Insert_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for first occurence of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Insert_First (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Searches for all occurences of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Search mapping --: @param Search Wide_String we want to insert --: @param New_Item Wide_String we look for --: @param Mapping Wide_String to be changed procedure Insert_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for all occurences of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Count Count of replaces done procedure Insert_All (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Count : out Natural); --- -- Searches for last occurence of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping procedure Insert_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity); --- -- Searches for last occurence of text "Search" and Inserts text "Insert" bevore when "Insert" is there. -- --: @param Source Wide_String to be changed --: @param Search Wide_String we look for --: @param New_Item Wide_String we want to insert --: @param Mapping Search mapping --: @param Found Count of replaces done procedure Insert_Last (Source : in out Ada.Strings.Wide_Unbounded.Unbounded_Wide_String; Search : in Wide_String; New_Item : in Wide_String; Mapping : in Ada.Strings.Wide_Maps.Wide_Character_Mapping := Ada.Strings.Wide_Maps.Identity; Found : out Boolean); --- -- Hash function for booch components. -- --: @param Key Wide_String to calculate a hash value form --: @return hash value function Hash (Key : Wide_String) return Natural; pragma Pure_Function (Hash); --- -- Hash function for booch components. -- --: @param Key Wide_String to calculate a hash value form --: @return hash value function Hash (Key : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String) return Natural; pragma Pure_Function (Hash); --- -- Hash function for Ada components. -- --: @param Key Wide_String to calculate a hash value form --: @return hash value function Hash (Key : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String) return Ada.Containers.Hash_Type; pragma Pure_Function (Hash); --- -- Hash function for Ada components. -- --: @param Key Wide_String to calculate a hash value form --: @return hash value function Hash (Key : Wide_String) return Ada.Containers.Hash_Type; pragma Pure_Function (Hash); --- -- convert Wide_String into Integer -- --: @param Image Wide_String to to be shown as Integer --: @return pased integer value function Value (Image : Ada.Strings.Wide_Unbounded.Unbounded_Wide_String) return Integer; pragma Pure_Function (Value); end AdaCL.Wide_Strings; ---------------------------------------------------------------- {{{ ---------- --: vim: set textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab : --: vim: set filetype=ada fileencoding=utf-8 fileformat=unix foldmethod=expr : --: vim: set spell spelllang=en_gb