
//////////////////////////////////////////////////
//  DBF Data Access Components
//  Copyright © 2008-2014 Devart. All right reserved.
//////////////////////////////////////////////////

{$IFNDEF CLR}

{$I DBFDac.inc}
unit DBFDataTypeMapUni;
{$ENDIF}

interface

uses
  DB, CRDataTypeMap,
{$IFNDEF UNIDACPRO}
  ODBCCall, ODBCDataTypeMap;
{$ELSE}
  ODBCCallUni, ODBCDataTypeMapUni;
{$ENDIF}

const
  dbfOffset              = 500;
  dbfBase                = odbcBase + dbfOffset;

  dbfChar                = odbcVarChar     + dbfOffset;
  dbfMemo                = odbcLongVarChar + dbfOffset;
  dbfNumeric             = odbcDouble      + dbfOffset;
  dbfDate                = odbcDate        + dbfOffset;
  dbfLogical             = odbcBit         + dbfOffset;

type

  TDBFMapRules = class (TCRMapRules)
  public
    class function GetConverterManager: TConverterManager; override;
  end;

  TDBFConverterManager = class(TODBCConverterManager)
  public
    class function GetDBProvider: Word; override;
    class function GetDBType(SQLType: Integer): Word; override;
  end;

  procedure InitDBFTypes;

implementation

uses
  MemData,
{$IFNDEF UNIDACPRO}
  DBFClasses;
{$ELSE}
  DBFClassesUni;
{$ENDIF}

var
  DBFConverterManager: TDBFConverterManager;

{ Function }

procedure InitDBFTypes;
begin
  DBTypeInfos.Add(dbfChar,              'Char',              True,  False);
  DBTypeInfos.Add(dbfMemo,              'Memo',              False, False);
  DBTypeInfos.Add(dbfNumeric,           'Numeric',           True,  True);
  DBTypeInfos.Add(dbfDate,              'Date',              False, False);
  DBTypeInfos.Add(dbfLogical,           'Logical',           False, False);
end;

{ TDBFDataMapRules }

class function TDBFMapRules.GetConverterManager: TConverterManager;
begin
  Result := DBFConverterManager;
end;

{ TDBFConverterManager }

class function TDBFConverterManager.GetDBProvider: Word;
begin
  Result := dbfBase;
end;

class function TDBFConverterManager.GetDBType(SQLType: Integer): Word;
begin
  Result := inherited GetDBType(SQLType) + dbfOffset;
end;

initialization
  InitDBFTypes;
  DBFConverterManager := TDBFConverterManager.Create;

finalization
  DBFConverterManager.Free;

end.
