unit Chilkat.Cache;

{
  Pascal wrapper for Chilkat Cache.
  Auto-generated by PascalWrapperGenerator -- do not edit manually.
}

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { TCache wraps CkCache via the C bridge layer. }
  TCache = class(TChilkatBase)
  private
    function  GetLastErrorHtml: string;
    function  GetLastErrorText: string;
    function  GetLastErrorXml: string;
    function  GetVersion: string;
    function  GetDebugLogFilePath: string;
    procedure SetDebugLogFilePath(AValue: string);
    function  GetVerboseLogging: Boolean;
    procedure SetVerboseLogging(AValue: Boolean);
    function  GetLastMethodSuccess: Boolean;
    procedure SetLastMethodSuccess(AValue: Boolean);
    function  GetLastEtagFetched: string;
    function  GetLastExpirationFetchedStr: string;
    function  GetLastHitExpired: Boolean;
    function  GetLastKeyFetched: string;
    function  GetLevel: Integer;
    procedure SetLevel(AValue: Integer);
    function  GetNumRoots: Integer;
  public
    constructor Create;
    destructor  Destroy; override;

    property LastErrorHtml: string read GetLastErrorHtml;
    property LastErrorText: string read GetLastErrorText;
    property LastErrorXml: string read GetLastErrorXml;
    property Version: string read GetVersion;
    property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;
    property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;
    property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;
    property LastEtagFetched: string read GetLastEtagFetched;
    property LastExpirationFetchedStr: string read GetLastExpirationFetchedStr;
    property LastHitExpired: Boolean read GetLastHitExpired;
    property LastKeyFetched: string read GetLastKeyFetched;
    property Level: Integer read GetLevel write SetLevel;
    property NumRoots: Integer read GetNumRoots;

    procedure AddRoot(const path: string);
    function  DeleteAll: Integer;
    function  DeleteAllExpired: Integer;
    function  DeleteFromCache(const key: string): Boolean;
    function  DeleteOlderDt(dateTime: TChilkatBase): Integer;
    function  DeleteOlderStr(const dateTimeStr: string): Integer;
    function  FetchText(const key: string): string;
    function  GetEtag(const key: string): string;
    function  GetExpirationStr(const url: string): string;
    function  GetFilename(const key: string): string;
    function  GetRoot(index: Integer): string;
    function  IsCached(const key: string): Boolean;
    function  SaveTextDt(const key: string; expireDateTime: TChilkatBase; const eTag: string; const itemTextData: string): Boolean;
    function  SaveTextNoExpire(const key: string; const eTag: string; const itemTextData: string): Boolean;
    function  SaveTextStr(const key: string; const expireDateTime: string; const eTag: string; const itemTextData: string): Boolean;
    function  UpdateExpirationDt(const key: string; expireDateTime: TChilkatBase): Boolean;
    function  UpdateExpirationStr(const key: string; const expireDateTime: string): Boolean;
    function  FetchBd(const key: string; bd: TChilkatBase): Boolean;
    function  FetchSb(const key: string; sb: TChilkatBase): Boolean;
    function  SaveBd(const key: string; const expiration: string; const etag: string; bd: TChilkatBase): Boolean;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkCache_Create  = function(): Pointer; cdecl;
  TCkCache_Dispose = procedure(handle: Pointer); cdecl;
  TCkCache_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkCache_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkCache_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCache_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkCache_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkCache_get_LastEtagFetched = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_LastExpirationFetchedStr = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_LastHitExpired = function(handle: Pointer): LongBool; cdecl;
  TCkCache_get_LastKeyFetched = function(handle: Pointer): PAnsiChar; cdecl;
  TCkCache_get_Level = function(handle: Pointer): Integer; cdecl;
  TCkCache_put_Level = procedure(handle: Pointer; value: Integer); cdecl;
  TCkCache_get_NumRoots = function(handle: Pointer): Integer; cdecl;
  TCkCache_AddRoot = procedure(handle: Pointer; path: PAnsiChar); cdecl;
  TCkCache_DeleteAll = function(handle: Pointer): Integer; cdecl;
  TCkCache_DeleteAllExpired = function(handle: Pointer): Integer; cdecl;
  TCkCache_DeleteFromCache = function(handle: Pointer; key: PAnsiChar): LongBool; cdecl;
  TCkCache_DeleteOlderDt = function(handle: Pointer; dateTime: Pointer): Integer; cdecl;
  TCkCache_DeleteOlderStr = function(handle: Pointer; dateTimeStr: PAnsiChar): Integer; cdecl;
  TCkCache_FetchText = function(handle: Pointer; key: PAnsiChar): PAnsiChar; cdecl;
  TCkCache_GetEtag = function(handle: Pointer; key: PAnsiChar): PAnsiChar; cdecl;
  TCkCache_GetExpirationStr = function(handle: Pointer; url: PAnsiChar): PAnsiChar; cdecl;
  TCkCache_GetFilename = function(handle: Pointer; key: PAnsiChar): PAnsiChar; cdecl;
  TCkCache_GetRoot = function(handle: Pointer; index: Integer): PAnsiChar; cdecl;
  TCkCache_IsCached = function(handle: Pointer; key: PAnsiChar): LongBool; cdecl;
  TCkCache_SaveTextDt = function(handle: Pointer; key: PAnsiChar; expireDateTime: Pointer; eTag: PAnsiChar; itemTextData: PAnsiChar): LongBool; cdecl;
  TCkCache_SaveTextNoExpire = function(handle: Pointer; key: PAnsiChar; eTag: PAnsiChar; itemTextData: PAnsiChar): LongBool; cdecl;
  TCkCache_SaveTextStr = function(handle: Pointer; key: PAnsiChar; expireDateTime: PAnsiChar; eTag: PAnsiChar; itemTextData: PAnsiChar): LongBool; cdecl;
  TCkCache_UpdateExpirationDt = function(handle: Pointer; key: PAnsiChar; expireDateTime: Pointer): LongBool; cdecl;
  TCkCache_UpdateExpirationStr = function(handle: Pointer; key: PAnsiChar; expireDateTime: PAnsiChar): LongBool; cdecl;
  TCkCache_FetchBd = function(handle: Pointer; key: PAnsiChar; bd: Pointer): LongBool; cdecl;
  TCkCache_FetchSb = function(handle: Pointer; key: PAnsiChar; sb: Pointer): LongBool; cdecl;
  TCkCache_SaveBd = function(handle: Pointer; key: PAnsiChar; expiration: PAnsiChar; etag: PAnsiChar; bd: Pointer): LongBool; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkCache_Create:  TCkCache_Create  = nil;
  CkCache_Dispose: TCkCache_Dispose = nil;
  CkCache_get_LastErrorHtml: TCkCache_get_LastErrorHtml = nil;
  CkCache_get_LastErrorText: TCkCache_get_LastErrorText = nil;
  CkCache_get_LastErrorXml: TCkCache_get_LastErrorXml = nil;
  CkCache_get_Version: TCkCache_get_Version = nil;
  CkCache_get_DebugLogFilePath: TCkCache_get_DebugLogFilePath = nil;
  CkCache_put_DebugLogFilePath: TCkCache_put_DebugLogFilePath = nil;
  CkCache_get_VerboseLogging: TCkCache_get_VerboseLogging = nil;
  CkCache_put_VerboseLogging: TCkCache_put_VerboseLogging = nil;
  CkCache_get_LastMethodSuccess: TCkCache_get_LastMethodSuccess = nil;
  CkCache_put_LastMethodSuccess: TCkCache_put_LastMethodSuccess = nil;
  CkCache_get_LastEtagFetched: TCkCache_get_LastEtagFetched = nil;
  CkCache_get_LastExpirationFetchedStr: TCkCache_get_LastExpirationFetchedStr = nil;
  CkCache_get_LastHitExpired: TCkCache_get_LastHitExpired = nil;
  CkCache_get_LastKeyFetched: TCkCache_get_LastKeyFetched = nil;
  CkCache_get_Level: TCkCache_get_Level = nil;
  CkCache_put_Level: TCkCache_put_Level = nil;
  CkCache_get_NumRoots: TCkCache_get_NumRoots = nil;
  CkCache_AddRoot: TCkCache_AddRoot = nil;
  CkCache_DeleteAll: TCkCache_DeleteAll = nil;
  CkCache_DeleteAllExpired: TCkCache_DeleteAllExpired = nil;
  CkCache_DeleteFromCache: TCkCache_DeleteFromCache = nil;
  CkCache_DeleteOlderDt: TCkCache_DeleteOlderDt = nil;
  CkCache_DeleteOlderStr: TCkCache_DeleteOlderStr = nil;
  CkCache_FetchText: TCkCache_FetchText = nil;
  CkCache_GetEtag: TCkCache_GetEtag = nil;
  CkCache_GetExpirationStr: TCkCache_GetExpirationStr = nil;
  CkCache_GetFilename: TCkCache_GetFilename = nil;
  CkCache_GetRoot: TCkCache_GetRoot = nil;
  CkCache_IsCached: TCkCache_IsCached = nil;
  CkCache_SaveTextDt: TCkCache_SaveTextDt = nil;
  CkCache_SaveTextNoExpire: TCkCache_SaveTextNoExpire = nil;
  CkCache_SaveTextStr: TCkCache_SaveTextStr = nil;
  CkCache_UpdateExpirationDt: TCkCache_UpdateExpirationDt = nil;
  CkCache_UpdateExpirationStr: TCkCache_UpdateExpirationStr = nil;
  CkCache_FetchBd: TCkCache_FetchBd = nil;
  CkCache_FetchSb: TCkCache_FetchSb = nil;
  CkCache_SaveBd: TCkCache_SaveBd = nil;

constructor TCache.Create;
begin
  inherited Create;
  FHandle := CkCache_Create();
end;

destructor TCache.Destroy;
begin
  if FHandle <> nil then
    CkCache_Dispose(FHandle);
  FHandle := nil;
  inherited;
end;

function TCache.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkCache_get_LastErrorHtml(FHandle));
end;

function TCache.GetLastErrorText: string;
begin
  Result := CkToStr(CkCache_get_LastErrorText(FHandle));
end;

function TCache.GetLastErrorXml: string;
begin
  Result := CkToStr(CkCache_get_LastErrorXml(FHandle));
end;

function TCache.GetVersion: string;
begin
  Result := CkToStr(CkCache_get_Version(FHandle));
end;

function TCache.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkCache_get_DebugLogFilePath(FHandle));
end;

procedure TCache.SetDebugLogFilePath(AValue: string);
begin
  CkCache_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function TCache.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkCache_get_VerboseLogging(FHandle));
end;

procedure TCache.SetVerboseLogging(AValue: Boolean);
begin
  CkCache_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function TCache.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkCache_get_LastMethodSuccess(FHandle));
end;

procedure TCache.SetLastMethodSuccess(AValue: Boolean);
begin
  CkCache_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function TCache.GetLastEtagFetched: string;
begin
  Result := CkToStr(CkCache_get_LastEtagFetched(FHandle));
end;

function TCache.GetLastExpirationFetchedStr: string;
begin
  Result := CkToStr(CkCache_get_LastExpirationFetchedStr(FHandle));
end;

function TCache.GetLastHitExpired: Boolean;
begin
  Result := Boolean(CkCache_get_LastHitExpired(FHandle));
end;

function TCache.GetLastKeyFetched: string;
begin
  Result := CkToStr(CkCache_get_LastKeyFetched(FHandle));
end;

function TCache.GetLevel: Integer;
begin
  Result := CkCache_get_Level(FHandle);
end;

procedure TCache.SetLevel(AValue: Integer);
begin
  CkCache_put_Level(FHandle, AValue);
end;

function TCache.GetNumRoots: Integer;
begin
  Result := CkCache_get_NumRoots(FHandle);
end;

procedure TCache.AddRoot(const path: string);
begin
  CkCache_AddRoot(FHandle, PAnsiChar(StrToCk(path)));
end;

function TCache.DeleteAll: Integer;
begin
  Result := CkCache_DeleteAll(FHandle);
end;

function TCache.DeleteAllExpired: Integer;
begin
  Result := CkCache_DeleteAllExpired(FHandle);
end;

function TCache.DeleteFromCache(const key: string): Boolean;
begin
  Result := Boolean(CkCache_DeleteFromCache(FHandle, PAnsiChar(StrToCk(key))));
end;

function TCache.DeleteOlderDt(dateTime: TChilkatBase): Integer;
begin
  Result := CkCache_DeleteOlderDt(FHandle, dateTime.Handle);
end;

function TCache.DeleteOlderStr(const dateTimeStr: string): Integer;
begin
  Result := CkCache_DeleteOlderStr(FHandle, PAnsiChar(StrToCk(dateTimeStr)));
end;

function TCache.FetchText(const key: string): string;
begin
  Result := CkToStr(CkCache_FetchText(FHandle, PAnsiChar(StrToCk(key))));
end;

function TCache.GetEtag(const key: string): string;
begin
  Result := CkToStr(CkCache_GetEtag(FHandle, PAnsiChar(StrToCk(key))));
end;

function TCache.GetExpirationStr(const url: string): string;
begin
  Result := CkToStr(CkCache_GetExpirationStr(FHandle, PAnsiChar(StrToCk(url))));
end;

function TCache.GetFilename(const key: string): string;
begin
  Result := CkToStr(CkCache_GetFilename(FHandle, PAnsiChar(StrToCk(key))));
end;

function TCache.GetRoot(index: Integer): string;
begin
  Result := CkToStr(CkCache_GetRoot(FHandle, index));
end;

function TCache.IsCached(const key: string): Boolean;
begin
  Result := Boolean(CkCache_IsCached(FHandle, PAnsiChar(StrToCk(key))));
end;

function TCache.SaveTextDt(const key: string; expireDateTime: TChilkatBase; const eTag: string; const itemTextData: string): Boolean;
begin
  Result := Boolean(CkCache_SaveTextDt(FHandle, PAnsiChar(StrToCk(key)), expireDateTime.Handle, PAnsiChar(StrToCk(eTag)), PAnsiChar(StrToCk(itemTextData))));
end;

function TCache.SaveTextNoExpire(const key: string; const eTag: string; const itemTextData: string): Boolean;
begin
  Result := Boolean(CkCache_SaveTextNoExpire(FHandle, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(eTag)), PAnsiChar(StrToCk(itemTextData))));
end;

function TCache.SaveTextStr(const key: string; const expireDateTime: string; const eTag: string; const itemTextData: string): Boolean;
begin
  Result := Boolean(CkCache_SaveTextStr(FHandle, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(expireDateTime)), PAnsiChar(StrToCk(eTag)), PAnsiChar(StrToCk(itemTextData))));
end;

function TCache.UpdateExpirationDt(const key: string; expireDateTime: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCache_UpdateExpirationDt(FHandle, PAnsiChar(StrToCk(key)), expireDateTime.Handle));
end;

function TCache.UpdateExpirationStr(const key: string; const expireDateTime: string): Boolean;
begin
  Result := Boolean(CkCache_UpdateExpirationStr(FHandle, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(expireDateTime))));
end;

function TCache.FetchBd(const key: string; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCache_FetchBd(FHandle, PAnsiChar(StrToCk(key)), bd.Handle));
end;

function TCache.FetchSb(const key: string; sb: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCache_FetchSb(FHandle, PAnsiChar(StrToCk(key)), sb.Handle));
end;

function TCache.SaveBd(const key: string; const expiration: string; const etag: string; bd: TChilkatBase): Boolean;
begin
  Result := Boolean(CkCache_SaveBd(FHandle, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(expiration)), PAnsiChar(StrToCk(etag)), bd.Handle));
end;

initialization
  Chilkat_GetProcedureAddress(CkCache_Create,  'CkCache_Create');
  Chilkat_GetProcedureAddress(CkCache_Dispose, 'CkCache_Dispose');
  Chilkat_GetProcedureAddress(CkCache_get_LastErrorHtml, 'CkCache_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkCache_get_LastErrorText, 'CkCache_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkCache_get_LastErrorXml, 'CkCache_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkCache_get_Version, 'CkCache_get_Version');
  Chilkat_GetProcedureAddress(CkCache_get_DebugLogFilePath, 'CkCache_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCache_put_DebugLogFilePath, 'CkCache_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkCache_get_VerboseLogging, 'CkCache_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCache_put_VerboseLogging, 'CkCache_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkCache_get_LastMethodSuccess, 'CkCache_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCache_put_LastMethodSuccess, 'CkCache_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkCache_get_LastEtagFetched, 'CkCache_get_LastEtagFetched');
  Chilkat_GetProcedureAddress(CkCache_get_LastExpirationFetchedStr, 'CkCache_get_LastExpirationFetchedStr');
  Chilkat_GetProcedureAddress(CkCache_get_LastHitExpired, 'CkCache_get_LastHitExpired');
  Chilkat_GetProcedureAddress(CkCache_get_LastKeyFetched, 'CkCache_get_LastKeyFetched');
  Chilkat_GetProcedureAddress(CkCache_get_Level, 'CkCache_get_Level');
  Chilkat_GetProcedureAddress(CkCache_put_Level, 'CkCache_put_Level');
  Chilkat_GetProcedureAddress(CkCache_get_NumRoots, 'CkCache_get_NumRoots');
  Chilkat_GetProcedureAddress(CkCache_AddRoot, 'CkCache_AddRoot');
  Chilkat_GetProcedureAddress(CkCache_DeleteAll, 'CkCache_DeleteAll');
  Chilkat_GetProcedureAddress(CkCache_DeleteAllExpired, 'CkCache_DeleteAllExpired');
  Chilkat_GetProcedureAddress(CkCache_DeleteFromCache, 'CkCache_DeleteFromCache');
  Chilkat_GetProcedureAddress(CkCache_DeleteOlderDt, 'CkCache_DeleteOlderDt');
  Chilkat_GetProcedureAddress(CkCache_DeleteOlderStr, 'CkCache_DeleteOlderStr');
  Chilkat_GetProcedureAddress(CkCache_FetchText, 'CkCache_FetchText');
  Chilkat_GetProcedureAddress(CkCache_GetEtag, 'CkCache_GetEtag');
  Chilkat_GetProcedureAddress(CkCache_GetExpirationStr, 'CkCache_GetExpirationStr');
  Chilkat_GetProcedureAddress(CkCache_GetFilename, 'CkCache_GetFilename');
  Chilkat_GetProcedureAddress(CkCache_GetRoot, 'CkCache_GetRoot');
  Chilkat_GetProcedureAddress(CkCache_IsCached, 'CkCache_IsCached');
  Chilkat_GetProcedureAddress(CkCache_SaveTextDt, 'CkCache_SaveTextDt');
  Chilkat_GetProcedureAddress(CkCache_SaveTextNoExpire, 'CkCache_SaveTextNoExpire');
  Chilkat_GetProcedureAddress(CkCache_SaveTextStr, 'CkCache_SaveTextStr');
  Chilkat_GetProcedureAddress(CkCache_UpdateExpirationDt, 'CkCache_UpdateExpirationDt');
  Chilkat_GetProcedureAddress(CkCache_UpdateExpirationStr, 'CkCache_UpdateExpirationStr');
  Chilkat_GetProcedureAddress(CkCache_FetchBd, 'CkCache_FetchBd');
  Chilkat_GetProcedureAddress(CkCache_FetchSb, 'CkCache_FetchSb');
  Chilkat_GetProcedureAddress(CkCache_SaveBd, 'CkCache_SaveBd');

end.
