ada_language_server_23.0.0_66f2e7fb/source/protocol/vss-json-pull_readers-look_ahead.ads

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
------------------------------------------------------------------------------
--                         Language Server Protocol                         --
--                                                                          --
--                    Copyright (C) 2020-2021, AdaCore                      --
--                                                                          --
-- This is free software;  you can redistribute it  and/or modify it  under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion.  This software is distributed in the hope  that it will be useful, --
-- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- --
-- TABILITY 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  distributed  with  this  software;   see  file --
-- COPYING3.  If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license.                                                          --
------------------------------------------------------------------------------

private with Ada.Containers.Vectors;

package VSS.JSON.Pull_Readers.Look_Ahead is

   type JSON_Look_Ahead_Reader
     (Parent : not null access JSON_Pull_Reader'Class)
       is limited new JSON_Pull_Reader with private;
   --  This type provides a limited capability to look ahead into some JSON
   --  stream by remembering observed events. After end of look ahead phase
   --  the user "rewind" the stream and is able to read all events againg.

   procedure Rewind (Self : in out JSON_Look_Ahead_Reader'Class);
   --  Restore JSON stream position to the very beginning, so it can be read
   --  again.

private

   type JSON_Event
     (Event_Kind : JSON_Event_Kind := JSON_Event_Kind'First) is
   record
      case Event_Kind is
         when No_Token | Invalid | Start_Document | End_Document |
              Start_Array | End_Array | Start_Object | End_Object |
              Null_Value =>
            null;
         when Key_Name =>
            Key_Name : VSS.Strings.Virtual_String;
         when String_Value =>
            String_Value : VSS.Strings.Virtual_String;
         when Number_Value =>
            Number_Value : VSS.JSON.JSON_Number;
         when Boolean_Value =>
            Boolean_Value : Boolean;
      end case;
   end record;

   package JSON_Event_Vectors is
     new Ada.Containers.Vectors (Positive, JSON_Event);

   type JSON_Look_Ahead_Reader
     (Parent : not null access JSON_Pull_Reader'Class)
   is limited new JSON_Pull_Reader with record
      Data      : JSON_Event_Vectors.Vector;
      Index     : Natural := 1;
      Save_Mode : Boolean := True;
   end record;

   overriding function At_End (Self : JSON_Look_Ahead_Reader) return Boolean;

   overriding function Read_Next
     (Self : in out JSON_Look_Ahead_Reader) return JSON_Event_Kind;

   overriding procedure Clear (Self : in out JSON_Look_Ahead_Reader);

   overriding function Error
     (Self : JSON_Look_Ahead_Reader) return JSON_Reader_Error;

   overriding function Error_Message
     (Self : JSON_Look_Ahead_Reader) return VSS.Strings.Virtual_String;

   overriding procedure Raise_Error
     (Self    : in out JSON_Look_Ahead_Reader;
      Message : VSS.Strings.Virtual_String);

   overriding function Event_Kind
     (Self : JSON_Look_Ahead_Reader) return JSON_Event_Kind;

   overriding function Key_Name
     (Self : JSON_Look_Ahead_Reader) return VSS.Strings.Virtual_String;

   overriding function String_Value
     (Self : JSON_Look_Ahead_Reader) return VSS.Strings.Virtual_String;

   overriding function Number_Value
     (Self : JSON_Look_Ahead_Reader) return VSS.JSON.JSON_Number;

   overriding function Boolean_Value
     (Self : JSON_Look_Ahead_Reader) return Boolean;

   overriding procedure Skip_Current_Array
     (Self : in out JSON_Look_Ahead_Reader);

   overriding procedure Skip_Current_Object
     (Self : in out JSON_Look_Ahead_Reader);

   overriding procedure Skip_Current_Value
     (Self : in out JSON_Look_Ahead_Reader);

end VSS.JSON.Pull_Readers.Look_Ahead;