unit Chilkat.Hashtable;

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

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

interface

uses
  SysUtils,
  Chilkat.Base;

type

  { THashtable wraps CkHashtable via the C bridge layer. }
  THashtable = 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  GetCount: 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 Count: Integer read GetCount;

    function  AddInt(const key: string; value: Integer): Boolean;
    function  AddStr(const key: string; const value: string): Boolean;
    procedure Clear;
    function  ClearWithNewCapacity(capacity: Integer): Boolean;
    function  Contains(const key: string): Boolean;
    function  LookupInt(const key: string): Integer;
    function  LookupStr(const key: string): string;
    function  Remove(const key: string): Boolean;
    function  GetKeys(strTable: TChilkatBase): Boolean;
    function  AddQueryParams(const queryParams: string): Boolean;
    function  ToXmlSb(sbXml: TChilkatBase): Boolean;
    function  AddFromXmlSb(sbXml: TChilkatBase): Boolean;
    function  ContainsIntKey(key: Integer): Boolean;
    function  ToQueryString: string;
  end;

implementation

uses
  CkDllLoader,
  Chilkat.Utils;

{ ---- C bridge function pointer types ---- }
type
  TCkHashtable_Create  = function(): Pointer; cdecl;
  TCkHashtable_Dispose = procedure(handle: Pointer); cdecl;
  TCkHashtable_get_LastErrorHtml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkHashtable_get_LastErrorText = function(handle: Pointer): PAnsiChar; cdecl;
  TCkHashtable_get_LastErrorXml = function(handle: Pointer): PAnsiChar; cdecl;
  TCkHashtable_get_Version = function(handle: Pointer): PAnsiChar; cdecl;
  TCkHashtable_get_DebugLogFilePath = function(handle: Pointer): PAnsiChar; cdecl;
  TCkHashtable_put_DebugLogFilePath = procedure(handle: Pointer; value: PAnsiChar); cdecl;
  TCkHashtable_get_VerboseLogging = function(handle: Pointer): LongBool; cdecl;
  TCkHashtable_put_VerboseLogging = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkHashtable_get_LastMethodSuccess = function(handle: Pointer): LongBool; cdecl;
  TCkHashtable_put_LastMethodSuccess = procedure(handle: Pointer; value: LongBool); cdecl;
  TCkHashtable_get_Count = function(handle: Pointer): Integer; cdecl;
  TCkHashtable_AddInt = function(handle: Pointer; key: PAnsiChar; value: Integer): LongBool; cdecl;
  TCkHashtable_AddStr = function(handle: Pointer; key: PAnsiChar; value: PAnsiChar): LongBool; cdecl;
  TCkHashtable_Clear = procedure(handle: Pointer); cdecl;
  TCkHashtable_ClearWithNewCapacity = function(handle: Pointer; capacity: Integer): LongBool; cdecl;
  TCkHashtable_Contains = function(handle: Pointer; key: PAnsiChar): LongBool; cdecl;
  TCkHashtable_LookupInt = function(handle: Pointer; key: PAnsiChar): Integer; cdecl;
  TCkHashtable_LookupStr = function(handle: Pointer; key: PAnsiChar): PAnsiChar; cdecl;
  TCkHashtable_Remove = function(handle: Pointer; key: PAnsiChar): LongBool; cdecl;
  TCkHashtable_GetKeys = function(handle: Pointer; strTable: Pointer): LongBool; cdecl;
  TCkHashtable_AddQueryParams = function(handle: Pointer; queryParams: PAnsiChar): LongBool; cdecl;
  TCkHashtable_ToXmlSb = function(handle: Pointer; sbXml: Pointer): LongBool; cdecl;
  TCkHashtable_AddFromXmlSb = function(handle: Pointer; sbXml: Pointer): LongBool; cdecl;
  TCkHashtable_ContainsIntKey = function(handle: Pointer; key: Integer): LongBool; cdecl;
  TCkHashtable_ToQueryString = function(handle: Pointer): PAnsiChar; cdecl;

{ ---- C bridge function pointer variables ---- }
var
  CkHashtable_Create:  TCkHashtable_Create  = nil;
  CkHashtable_Dispose: TCkHashtable_Dispose = nil;
  CkHashtable_get_LastErrorHtml: TCkHashtable_get_LastErrorHtml = nil;
  CkHashtable_get_LastErrorText: TCkHashtable_get_LastErrorText = nil;
  CkHashtable_get_LastErrorXml: TCkHashtable_get_LastErrorXml = nil;
  CkHashtable_get_Version: TCkHashtable_get_Version = nil;
  CkHashtable_get_DebugLogFilePath: TCkHashtable_get_DebugLogFilePath = nil;
  CkHashtable_put_DebugLogFilePath: TCkHashtable_put_DebugLogFilePath = nil;
  CkHashtable_get_VerboseLogging: TCkHashtable_get_VerboseLogging = nil;
  CkHashtable_put_VerboseLogging: TCkHashtable_put_VerboseLogging = nil;
  CkHashtable_get_LastMethodSuccess: TCkHashtable_get_LastMethodSuccess = nil;
  CkHashtable_put_LastMethodSuccess: TCkHashtable_put_LastMethodSuccess = nil;
  CkHashtable_get_Count: TCkHashtable_get_Count = nil;
  CkHashtable_AddInt: TCkHashtable_AddInt = nil;
  CkHashtable_AddStr: TCkHashtable_AddStr = nil;
  CkHashtable_Clear: TCkHashtable_Clear = nil;
  CkHashtable_ClearWithNewCapacity: TCkHashtable_ClearWithNewCapacity = nil;
  CkHashtable_Contains: TCkHashtable_Contains = nil;
  CkHashtable_LookupInt: TCkHashtable_LookupInt = nil;
  CkHashtable_LookupStr: TCkHashtable_LookupStr = nil;
  CkHashtable_Remove: TCkHashtable_Remove = nil;
  CkHashtable_GetKeys: TCkHashtable_GetKeys = nil;
  CkHashtable_AddQueryParams: TCkHashtable_AddQueryParams = nil;
  CkHashtable_ToXmlSb: TCkHashtable_ToXmlSb = nil;
  CkHashtable_AddFromXmlSb: TCkHashtable_AddFromXmlSb = nil;
  CkHashtable_ContainsIntKey: TCkHashtable_ContainsIntKey = nil;
  CkHashtable_ToQueryString: TCkHashtable_ToQueryString = nil;

constructor THashtable.Create;
begin
  inherited Create;
  FHandle := CkHashtable_Create();
end;

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

function THashtable.GetLastErrorHtml: string;
begin
  Result := CkToStr(CkHashtable_get_LastErrorHtml(FHandle));
end;

function THashtable.GetLastErrorText: string;
begin
  Result := CkToStr(CkHashtable_get_LastErrorText(FHandle));
end;

function THashtable.GetLastErrorXml: string;
begin
  Result := CkToStr(CkHashtable_get_LastErrorXml(FHandle));
end;

function THashtable.GetVersion: string;
begin
  Result := CkToStr(CkHashtable_get_Version(FHandle));
end;

function THashtable.GetDebugLogFilePath: string;
begin
  Result := CkToStr(CkHashtable_get_DebugLogFilePath(FHandle));
end;

procedure THashtable.SetDebugLogFilePath(AValue: string);
begin
  CkHashtable_put_DebugLogFilePath(FHandle, PAnsiChar(StrToCk(AValue)));
end;

function THashtable.GetVerboseLogging: Boolean;
begin
  Result := Boolean(CkHashtable_get_VerboseLogging(FHandle));
end;

procedure THashtable.SetVerboseLogging(AValue: Boolean);
begin
  CkHashtable_put_VerboseLogging(FHandle, LongBool(AValue));
end;

function THashtable.GetLastMethodSuccess: Boolean;
begin
  Result := Boolean(CkHashtable_get_LastMethodSuccess(FHandle));
end;

procedure THashtable.SetLastMethodSuccess(AValue: Boolean);
begin
  CkHashtable_put_LastMethodSuccess(FHandle, LongBool(AValue));
end;

function THashtable.GetCount: Integer;
begin
  Result := CkHashtable_get_Count(FHandle);
end;

function THashtable.AddInt(const key: string; value: Integer): Boolean;
begin
  Result := Boolean(CkHashtable_AddInt(FHandle, PAnsiChar(StrToCk(key)), value));
end;

function THashtable.AddStr(const key: string; const value: string): Boolean;
begin
  Result := Boolean(CkHashtable_AddStr(FHandle, PAnsiChar(StrToCk(key)), PAnsiChar(StrToCk(value))));
end;

procedure THashtable.Clear;
begin
  CkHashtable_Clear(FHandle);
end;

function THashtable.ClearWithNewCapacity(capacity: Integer): Boolean;
begin
  Result := Boolean(CkHashtable_ClearWithNewCapacity(FHandle, capacity));
end;

function THashtable.Contains(const key: string): Boolean;
begin
  Result := Boolean(CkHashtable_Contains(FHandle, PAnsiChar(StrToCk(key))));
end;

function THashtable.LookupInt(const key: string): Integer;
begin
  Result := CkHashtable_LookupInt(FHandle, PAnsiChar(StrToCk(key)));
end;

function THashtable.LookupStr(const key: string): string;
begin
  Result := CkToStr(CkHashtable_LookupStr(FHandle, PAnsiChar(StrToCk(key))));
end;

function THashtable.Remove(const key: string): Boolean;
begin
  Result := Boolean(CkHashtable_Remove(FHandle, PAnsiChar(StrToCk(key))));
end;

function THashtable.GetKeys(strTable: TChilkatBase): Boolean;
begin
  Result := Boolean(CkHashtable_GetKeys(FHandle, strTable.Handle));
end;

function THashtable.AddQueryParams(const queryParams: string): Boolean;
begin
  Result := Boolean(CkHashtable_AddQueryParams(FHandle, PAnsiChar(StrToCk(queryParams))));
end;

function THashtable.ToXmlSb(sbXml: TChilkatBase): Boolean;
begin
  Result := Boolean(CkHashtable_ToXmlSb(FHandle, sbXml.Handle));
end;

function THashtable.AddFromXmlSb(sbXml: TChilkatBase): Boolean;
begin
  Result := Boolean(CkHashtable_AddFromXmlSb(FHandle, sbXml.Handle));
end;

function THashtable.ContainsIntKey(key: Integer): Boolean;
begin
  Result := Boolean(CkHashtable_ContainsIntKey(FHandle, key));
end;

function THashtable.ToQueryString: string;
begin
  Result := CkToStr(CkHashtable_ToQueryString(FHandle));
end;

initialization
  Chilkat_GetProcedureAddress(CkHashtable_Create,  'CkHashtable_Create');
  Chilkat_GetProcedureAddress(CkHashtable_Dispose, 'CkHashtable_Dispose');
  Chilkat_GetProcedureAddress(CkHashtable_get_LastErrorHtml, 'CkHashtable_get_LastErrorHtml');
  Chilkat_GetProcedureAddress(CkHashtable_get_LastErrorText, 'CkHashtable_get_LastErrorText');
  Chilkat_GetProcedureAddress(CkHashtable_get_LastErrorXml, 'CkHashtable_get_LastErrorXml');
  Chilkat_GetProcedureAddress(CkHashtable_get_Version, 'CkHashtable_get_Version');
  Chilkat_GetProcedureAddress(CkHashtable_get_DebugLogFilePath, 'CkHashtable_get_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkHashtable_put_DebugLogFilePath, 'CkHashtable_put_DebugLogFilePath');
  Chilkat_GetProcedureAddress(CkHashtable_get_VerboseLogging, 'CkHashtable_get_VerboseLogging');
  Chilkat_GetProcedureAddress(CkHashtable_put_VerboseLogging, 'CkHashtable_put_VerboseLogging');
  Chilkat_GetProcedureAddress(CkHashtable_get_LastMethodSuccess, 'CkHashtable_get_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkHashtable_put_LastMethodSuccess, 'CkHashtable_put_LastMethodSuccess');
  Chilkat_GetProcedureAddress(CkHashtable_get_Count, 'CkHashtable_get_Count');
  Chilkat_GetProcedureAddress(CkHashtable_AddInt, 'CkHashtable_AddInt');
  Chilkat_GetProcedureAddress(CkHashtable_AddStr, 'CkHashtable_AddStr');
  Chilkat_GetProcedureAddress(CkHashtable_Clear, 'CkHashtable_Clear');
  Chilkat_GetProcedureAddress(CkHashtable_ClearWithNewCapacity, 'CkHashtable_ClearWithNewCapacity');
  Chilkat_GetProcedureAddress(CkHashtable_Contains, 'CkHashtable_Contains');
  Chilkat_GetProcedureAddress(CkHashtable_LookupInt, 'CkHashtable_LookupInt');
  Chilkat_GetProcedureAddress(CkHashtable_LookupStr, 'CkHashtable_LookupStr');
  Chilkat_GetProcedureAddress(CkHashtable_Remove, 'CkHashtable_Remove');
  Chilkat_GetProcedureAddress(CkHashtable_GetKeys, 'CkHashtable_GetKeys');
  Chilkat_GetProcedureAddress(CkHashtable_AddQueryParams, 'CkHashtable_AddQueryParams');
  Chilkat_GetProcedureAddress(CkHashtable_ToXmlSb, 'CkHashtable_ToXmlSb');
  Chilkat_GetProcedureAddress(CkHashtable_AddFromXmlSb, 'CkHashtable_AddFromXmlSb');
  Chilkat_GetProcedureAddress(CkHashtable_ContainsIntKey, 'CkHashtable_ContainsIntKey');
  Chilkat_GetProcedureAddress(CkHashtable_ToQueryString, 'CkHashtable_ToQueryString');

end.
