------------------------------------------------------------------------------
--                                                                          --
--                            Matreshka Project                             --
--                                                                          --
--         Localization, Internationalization, Globalization for Ada        --
--                                                                          --
--                        Runtime Library Component                         --
--                                                                          --
------------------------------------------------------------------------------
--                                                                          --
-- Copyright © 2010-2012, Vadim Godunko <vgodunko@gmail.com>                --
-- All rights reserved.                                                     --
--                                                                          --
-- Redistribution and use in source and binary forms, with or without       --
-- modification, are permitted provided that the following conditions       --
-- are met:                                                                 --
--                                                                          --
--  * Redistributions of source code must retain the above copyright        --
--    notice, this list of conditions and the following disclaimer.         --
--                                                                          --
--  * Redistributions in binary form must reproduce the above copyright     --
--    notice, this list of conditions and the following disclaimer in the   --
--    documentation and/or other materials provided with the distribution.  --
--                                                                          --
--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
--    contributors may be used to endorse or promote products derived from  --
--    this software without specific prior written permission.              --
--                                                                          --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
--                                                                          --
------------------------------------------------------------------------------
--  $Revision: 3003 $ $Date: 2012-05-17 19:49:39 +0400 (Thu, 17 May 2012) $
------------------------------------------------------------------------------

package Matreshka.Internals.Strings.Operations is

   pragma Preelaborate;

   procedure Append
    (Self : in out not null Shared_String_Access;
     Code : Matreshka.Internals.Unicode.Code_Point);
   --  Appends character to the string, reallocate memory if needed.

   procedure Unterminated_Append
    (Self : in out not null Shared_String_Access;
     Code : Matreshka.Internals.Unicode.Code_Point);
   --  Appends character to the string, reallocate memory if needed. Null
   --  terminator is not filled.

   procedure Append
    (Self : in out not null Shared_String_Access;
     Item : Shared_String_Access);
   --  Appends data from to Item to the string, reallocate string when needed.

   procedure Prepend
    (Target : in out not null Shared_String_Access;
     Code   : Matreshka.Internals.Unicode.Code_Point);
   --  Prepends character to the string, reallocate memory if needed.

   procedure Prepend
    (Target : in out not null Shared_String_Access;
     Item   : Shared_String_Access);
   --  Prepends data from to Item to the string, reallocate string when needed.

   procedure Copy_Slice
    (Self   : in out not null Shared_String_Access;
     Source : not null Shared_String_Access;
     First  : Matreshka.Internals.Utf16.Utf16_String_Index;
     Size   : Matreshka.Internals.Utf16.Utf16_String_Index;
     Length : Natural);
   --  Copy slice from the Source string into the string, reallocate string
   --  when needed.

   function Slice
    (Source : not null Shared_String_Access;
     First  : Matreshka.Internals.Utf16.Utf16_String_Index;
     Size   : Matreshka.Internals.Utf16.Utf16_String_Index;
     Length : Natural)
       return not null Shared_String_Access;
   --  Returns slice from First to First + Size - 1. Length specify expected
   --  length of the result.

   procedure Slice
    (Item   : in out not null Shared_String_Access;
     First  : Matreshka.Internals.Utf16.Utf16_String_Index;
     Size   : Matreshka.Internals.Utf16.Utf16_String_Index;
     Length : Natural);
   --  Sets Item to its slice from First to First + Size - 1. Length specify
   --  expected length of the result.

   procedure Replace
    (String : in out not null Shared_String_Access;
     First  : Matreshka.Internals.Utf16.Utf16_String_Index;
     Size   : Matreshka.Internals.Utf16.Utf16_String_Index;
     Length : Natural;
     By     : not null Shared_String_Access);

   procedure Reset (Self : in out not null Shared_String_Access);
   --  Resets specified shared string to have empty length or sets it to
   --  shared empty string when shared string is used.

--   function Copy (Source : not null String_Private_Data_Access)
--     return not null String_Private_Data_Access;
   --  Creates copy of string data.

end Matreshka.Internals.Strings.Operations;
