unit uCharBuf;

      {=================================================================}
      {                                                                 }
      {  SW pro terminaly SofCon                V2.51   17.03.2003 Bu   }
      {                                                                 }
      {  Objekty slouzici pro praci se znakovym buffrem a strings       }
      {                                                                 }
      {  (C) 1996-1997, SofCon s.r.o., Stresovicka 49, Praha 6          }
      {                 Vypracoval: R.Bukovsky                          }
      {=================================================================}

{$ifdef USE_SETS_INC} { Pokud chces tak nastav v Compiler Options/Conditional defines }
   {$I Sets.inc}
{$endif}

interface
uses
 {$IFDEF DEBUGSYSFC}
  uSysf,
 {$ENDIF}
  Objects,
  uString,
  NumToStr;

const
  cVerNo = $0251; { BCD format }
  cVer   = '02.51,17.03.2003';

type
pAbstractCharBuf = ^tAbstractCharBuf;
tAbstractCharBuf = array[0..$fff0] of char;

PCharBufMan =^TCharBufMan;
TCharBufMan = object
  CharBufPtr  :pAbstractCharBuf; { ref_only }
  CharBufSize :word;
  CharIndex   :word;    { index prvni volne pozice }
  procedure AssignCharBuf(RefBufPtr:pointer;RefBufSize:word);
  procedure ClearCharBuf;
  procedure AddStrToEnd(AddStr:string;var FilledLng:word);
  procedure AddSize(AddLng:word);
  function GetFreeBufPtr:pointer;
  function GetFreeBufSize:word;
  function GetFilledBufSize:word;
end;


{ Funkce porovna obsah Buf1^ a Buf2^ jako strings:
  if Buf1^ = Buf2^ then BufLComp:= 0;
  if Buf1^ < Buf2^ then BufLComp:=-1'
  if Buf1^ > Buf2^ then BufLComp:=+1;  }
function BufLComp(Buf1,Buf2:pointer;BufLng:word):integer;

type TPropertyStr=string[5];

{$ifdef Ver60}
function GetNextNumber(var j:integer; S:string;var NumVal:integer;LLim,HLim:integer):Boolean;
function SepPropertyNumberStr(var i:integer; S:string):TPropertyStr;
{$endif}
{$ifdef Ver70}
function GetNextNumber(var j:integer;const S:string;var NumVal:integer;LLim,HLim:integer):Boolean;
function SepPropertyNumberStr(var i:integer;const S:string):TPropertyStr;
{$endif}

type
PPropertyReaderWriter =^TPropertyReaderWriter;
TPropertyReaderWriter = object(TObject)
  Err                :Boolean;
  constructor Init;
{$ifdef Ver60}
  procedure ReadProperty(var j:integer; S:string);            virtual;
{$endif}
{$ifdef Ver70}
  procedure ReadProperty(var j:integer;const S:string);       virtual;
{$endif}
  procedure WriteProperty(DestBuf:pointer;DestSize:word);     virtual;
end;


const
      MaxNumWd       = 20;              { maximalni sirka ciselneho parametru }
   {$IFOPT N+}
      MaxRealpDesMist= 14;
   {$ELSE}
      MaxRealpDesMist= 10;
   {$ENDIF}
type
   {$IFOPT N+}
      realp      = single;
   {$ELSE}
      realp      = real;
   {$ENDIF}
      NumString  = string[MaxNumWd];

function AddLeadingZeros(S:string):string;
{$ifdef Ver60}
function AddSpacesToWd(S:string;wd:byte):string;
function AddLdCharWd(S:string;Ch:Char;wd:byte):string;
function AddCharToWd(S:string;Ch:Char;wd:byte):string;
{$endif}
{$ifdef Ver70}
function AddSpacesToWd(const S:string;wd:byte):string;
function AddLdCharWd(const S:string;Ch:Char;wd:byte):string;
function AddCharToWd(const S:string;Ch:Char;wd:byte):string;
{$endif}

{$IFDEF DEBUGSYSFC}
function CharBuf_ToStr(BufPtr:pointer;BufSize:word):string;
{$ENDIF}

{###############################################################################}
implementation
