Top Prev Next Up Down

Y2018.Text.Util.InFileUTF8


001| with Ada.Direct_IO;
002| with Y2018.Text.Core; use Y2018.Text.Core;
003| with Y2018.Text.Core.Str; use Y2018.Text.Core.Str;
004| with Y2018.Text.Core.CVarPack; use Y2018.Text.Core.CVarPack;
005| package Y2018.Text.Util.InFileUTF8 is
006| __type self is tagged limited private;
007| __package DirectTY is new Ada.Direct_IO(Character);
008| __procedure open(base:in out Y2018.Text.Util.InFileUTF8.self;infilename:String);
009| __function read(base:in out Y2018.Text.Util.InFileUTF8.self;result:out CVar;replace:CodePoint:=CodePoint'Val(16#FFFD#);action:Boolean:=FALSE) return RS_TY;
010| __procedure close(base:in out Y2018.Text.Util.InFileUTF8.self);
011| __function eof(base:Y2018.Text.Util.InFileUTF8.self) return Boolean;
012| __function reason(base:in out Y2018.Text.Util.InFileUTF8.self) return RS_TY;
013| __function utf8cnt(base:in out Y2018.Text.Util.InFileUTF8.self) return Long_Long_Integer;
014| __function bytecnt(base:in out Y2018.Text.Util.InFileUTF8.self) return Long_Long_Integer;
015| __procedure Finalize(base: in out Y2018.Text.Util.InFileUTF8.self);
016| __procedure Initialize(base: in out Y2018.Text.Util.InFileUTF8.self);
017| __private type self is tagged limited
018| __record
019| _____infile:DirectTY.File_Type;
020| _____utf8cnt:Long_Long_Integer;
021| _____bytecnt:Long_Long_Integer;
022| _____reason:RS_TY;
023| __end record;
024| end Y2018.Text.Util.InFileUTF8;

Action taken by procedures or functions in the package:

procedure open(base:in out Y2018.Text.Util.InFileUTF8.self;infilename:String);

Open file.

function read(base:in out Y2018.Text.Util.InFileUTF8.self;result:out CVar; replace:CodePoint:=CodePoint'Val(16#FFFD#);action:Boolean:=FALSE) return RS_TY;

Read only one codepoint from the file. Result if any exists in parameter ‘result’. If problem specify what to do, return reason value or replace codepoint value with replace codepoint value.

procedure close(base:in out Y2018.Text.Util.InFileUTF8.self);

Close file.

function eof(base:Y2018.Text.Util.InFileUTF8.self) return Boolean;

Query if we have got end of file.

function reason(base:in out Y2018.Text.Util.InFileUTF8.self) return RS_TY;

Return reson state.

function utf8cnt(base:in out Y2018.Text.Util.InFileUTF8.self) return Long_Long_Integer;

Return number of codepoint read.

The file maybe long, that is the reason for using Long_Long_Integer.

function bytecnt(base:in out Y2018.Text.Util.InFileUTF8.self) return Long_Long_Integer;

Return number of bytes read. The file maybe long, that is the reason for using Long_Long_Integer.

RS_TY defined in parent package Util (RS_NONE, RS_MISS, RS_ILLEGAL, RS_EOF)